-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Give a better error message for duplicate built-in macros #76143
Conversation
Some changes occurred in diagnostic error codes |
c7dad7a
to
245ad9f
Compare
compiler/rustc_resolve/src/macros.rs
Outdated
let msg = "attempted to define built-in macro more than once"; | ||
self.session | ||
.struct_span_err_with_code(item.span, msg, error_code!(E0773)) | ||
.span_note(span, "previously defined here") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In practice the current span and the previous span are going to point to the same place though, if we are talking about issues like #75176.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For #75176, it would have been the same, yes. However that in itself would have been helpful debugging the issue: it shows that the same crate is being loaded twice. And for problems that are less obscure this will be very helpful since it points straight to the other location that conflicts.
r=me with #76143 (comment) addressed and commits squashed. |
Previously, this would say no such macro existed, but this was misleading, since the macro _did_ exist, it was just already seen. - Say where the macro was previously defined - Add long-form error message
65f25c2
to
be2947d
Compare
@bors r=petrochenkov |
📌 Commit be2947d has been approved by |
Rollup of 14 pull requests Successful merges: - rust-lang#74880 (Add trailing comma support to matches macro) - rust-lang#76074 (Add new `-Z dump-mir-spanview` option) - rust-lang#76088 (Add more examples to lexicographic cmp on Iterators.) - rust-lang#76099 (Add info about `!` and `impl Trait`) - rust-lang#76126 (Use "Fira Sans" for crate list font) - rust-lang#76132 (Factor out StmtKind::MacCall fields into `MacCallStmt` struct) - rust-lang#76143 (Give a better error message for duplicate built-in macros) - rust-lang#76158 (Stabilise link-self-contained option) - rust-lang#76201 (Move to intra-doc links for library/core/src/panic.rs) - rust-lang#76206 (Make all methods of `std::net::Ipv6Addr` const) - rust-lang#76207 (# Move to intra-doc links for library/core/src/clone.rs) - rust-lang#76212 (Document lint missing_doc_code_examples is nightly-only) - rust-lang#76218 (lexer: Tiny improvement to shebang detection) - rust-lang#76221 (Clean up header in `iter` docs for `for` loops) Failed merges: r? @ghost
Minor follow-up to #75176 giving a better error message for duplicate builtin macros. This would have made it a little easier to debug.
r? @petrochenkov