Skip to content
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

Merged
merged 1 commit into from
May 13, 2021

Conversation

Aaron1011
Copy link
Member

When there are multiple macros in use, it can be difficult to tell
which one was responsible for producing an error.

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 13, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@jyn514 jyn514 added A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 13, 2021
@@ -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)
Copy link
Member

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?

Copy link
Member

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!

Copy link
Member Author

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.

Copy link
Contributor

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.

@bors
Copy link
Contributor

bors commented Feb 18, 2021

☔ The latest upstream changes (presumably #82249) made this pull request unmergeable. Please resolve the merge conflicts.

@henryboisdequin
Copy link
Contributor

@rustbot label +S-waiting-on-author -S-waiting-on-review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 3, 2021
@Aaron1011
Copy link
Member Author

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.

@Aaron1011 Aaron1011 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 4, 2021
@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 20, 2021
@Dylan-DPC-zz
Copy link

r? @estebank

@JohnCSimon
Copy link
Member

JohnCSimon commented Apr 4, 2021

Triage:
Assigning back to author for build failure.

@rustbot label: -S-waiting-on-review +S-waiting-on-author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 4, 2021
@Aaron1011
Copy link
Member Author

Aaron1011 commented Apr 4, 2021

@JohnCSimon: The build failure is expected - I'll rebase and bless the tests once the overall concept is approved, due to the bitrot potential.

@Aaron1011 Aaron1011 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 4, 2021
@@ -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)
Copy link
Contributor

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?

Copy link
Member Author

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.

@crlf0710 crlf0710 added the I-needs-decision Issue: In need of a decision. label Apr 23, 2021
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label May 12, 2021
@rust-log-analyzer

This comment has been minimized.

@JohnTitor
Copy link
Member

@bors r- --^

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 12, 2021
When there are multiple macros in use, it can be difficult to tell
which one was responsible for producing an error.
@Aaron1011 Aaron1011 removed the I-needs-decision Issue: In need of a decision. label May 12, 2021
@Aaron1011
Copy link
Member Author

@bors r=estebank p=1 rollup=never

@bors
Copy link
Contributor

bors commented May 12, 2021

📌 Commit 0dd9f11 has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 12, 2021
@bors
Copy link
Contributor

bors commented May 13, 2021

⌛ Testing commit 0dd9f11 with merge 9daf546...

@bors
Copy link
Contributor

bors commented May 13, 2021

☀️ Test successful - checks-actions
Approved by: estebank
Pushing 9daf546 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 13, 2021
@bors bors merged commit 9daf546 into rust-lang:master May 13, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 13, 2021
djc pushed a commit to djc/askama that referenced this pull request Jul 2, 2021
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.
MauriceKayser added a commit to MauriceKayser/rs-bitfield that referenced this pull request Oct 17, 2021
djc pushed a commit to djc/askama that referenced this pull request Feb 16, 2022
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.
djc pushed a commit to djc/askama that referenced this pull request Feb 16, 2022
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.
MauriceKayser added a commit to MauriceKayser/rs-bitfield that referenced this pull request Oct 4, 2022
MauriceKayser added a commit to MauriceKayser/rs-bitfield that referenced this pull request Jan 3, 2024
MauriceKayser added a commit to MauriceKayser/rs-bitfield that referenced this pull request Jan 4, 2024
busgaidw2 added a commit to busgaidw2/askama that referenced this pull request Aug 6, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.