-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad macro usage error message does not include correct error location #31022
Comments
Change the usage syntax to require a comma on the last non-fallback arm, which is a [breaking-change]. The old definition has started to emit a warning in recent nightlies and is likely to be an error in future versions: rust-lang/rfcs#1384 The new definition is recursive to resolve ambiguities. Unfortunately this makes error reporting terrible: rust-lang/rust#31022
Make match_ignore_ascii_case! future-proof. Change the usage syntax to require a comma on the last non-fallback arm, which is a [breaking-change]. The old definition has started to emit a warning in recent nightlies and is likely to be an error in future versions: rust-lang/rfcs#1384 The new definition is recursive to resolve ambiguities. Unfortunately this makes error reporting terrible: rust-lang/rust#31022 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/rust-cssparser/91) <!-- Reviewable:end -->
When the expanded code contains a non-macro-related error (say, a type mismatch), it at least shows a macro expansion backtrace. It's very hard to read, but gives spans at least. I guess that would be a start. |
The trouble is you get the same error if you screw up writing the macro, e.g. misspell |
Yes, I don’t have an example at hand to copy/past but I see the kind of error message you mean. It may be the caller’s fault even if it isn’t necessarily. A macro expansion backtrace would be useful here. |
Current output:
|
Triage: no change. |
Triage: no change. |
Triage: no change. |
Consider this reduced test case:
The
@inner
indirection exists because the non-reduced macro is recursive:This fails to compile (as it should) but the error message does not include the real location of the error, which is line 12. It can be hard to track down in a large crate with many users of the macro.
The error message looks even worse when the macro is used (with incorrect syntax) from another crate
The text was updated successfully, but these errors were encountered: