Suggestions for macro rules error "variable is still repeating at this depth"

The message "variable is still repeating at this depth" doesn't seem very clear. In fact, this error is mostly caused by forgetting to add a repeating groups outside, but I have serval time not realized this at first after making this error by oversight. rustc is known for providing suggestions with error, but this error seems to lack such suggestions. Some of the other marco rules errors seem to have this problem as well. Maybe it's because macro rules has too much freedom resulting in hard judgment?

If you have a good example for this, it would be great to be able to tell how possible it might be to make the diagnostic more useful. The problem with macros in general is that they can in effect do almost anything. We have some very conservative checks (like seeing if adding a comma before an unexpected token would have made the macro invocation work) that can work for a lot of macros in the wild, but it is quite hard to address everything that macro authors might attempt to do (unlike with the language itself where we have a much better understanding of what people might have tried to do). It is my goal to have a way for crate authors to customize errors themselves, for trait, type and macro errors, but this might take a while to hit stable. Hopefully we'll have it out the door before the 2024 edition is released.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.