-
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
Show macro name in 'this error originates in macro' message #82069
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
150c412
to
4aa73f6
Compare
This comment has been minimized.
This comment has been minimized.
@@ -5,7 +5,7 @@ LL | static A: usize = 0; | |||
| ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize` | |||
| | |||
= note: required by `std::alloc::GlobalAlloc::alloc` | |||
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info) | |||
= note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info) |
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.
Unrelated to this PR, but would it be possible to only show "run with -Z macro-backtrace" in nightly builds, the same way the compiler only suggests #![feature]
on nightly?
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 months I've thought of suggesting this but kept forgetting, so thanks for suggesting it!
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.
This can be a very useful option for debugging macros, so I think it's good to make people aware of it. Unlike #![feature]
s, this option is something can be enabled just for local testing, without requiring that anyone else use a nightly compiler.
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.
@Aaron1011's observation is exactly the reason I didn't gate that suggestion on being in nightly.
☔ The latest upstream changes (presumably #82249) made this pull request unmergeable. Please resolve the merge conflicts. |
@rustbot label +S-waiting-on-author -S-waiting-on-review |
This PR is extremely prone to bit-rotting. Once @matthewjasper or someone else is ready to r+ the general concept, I'll rebase and immediately approve it with p=1. |
r? @estebank |
Triage: @rustbot label: -S-waiting-on-review +S-waiting-on-author |
@JohnCSimon: The build failure is expected - I'll rebase and bless the tests once the overall concept is approved, due to the bitrot potential. |
@@ -33,7 +33,7 @@ LL | assert_eq!(a, 0); | |||
= help: use parentheses to call the function: `a()` | |||
= note: required because of the requirements on the impl of `Debug` for `&fn() -> i32 {a}` | |||
= note: required by `std::fmt::Debug::fmt` | |||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) | |||
= note: this error originates in the macro `$crate::format_args` (in Nightly builds, run with -Z macro-backtrace for more info) |
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.
Is $crate
meant to be exposed this way?
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.
Probably not. I'll open an issue to track resolving this.
This comment has been minimized.
This comment has been minimized.
@bors r- --^ |
When there are multiple macros in use, it can be difficult to tell which one was responsible for producing an error.
01919db
to
0dd9f11
Compare
@bors r=estebank p=1 rollup=never |
📌 Commit 0dd9f11 has been approved by |
☀️ Test successful - checks-actions |
rust-lang/rust#82069 made error message that stem macro invocations more verbose. Since Rust 1.54 (currently in beta) the message includes the name of the offending macro. This PR uses version_check to select the appropriate expected error message.
rust-lang/rust#82069 made error message that stem macro invocations more verbose. Since Rust 1.54 (currently in beta) the message includes the name of the offending macro. This PR uses version_check to select the appropriate expected error message.
rust-lang/rust#82069 made error message that stem macro invocations more verbose. Since Rust 1.54 (currently in beta) the message includes the name of the offending macro. This PR uses version_check to select the appropriate expected error message.
rust-lang/rust#82069 made error message that stem macro invocations more verbose. Since Rust 1.54 (currently in beta) the message includes the name of the offending macro. This PR uses version_check to select the appropriate expected error message.
When there are multiple macros in use, it can be difficult to tell
which one was responsible for producing an error.