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
Fix the wrong suggestion to add a format literal "{}"
directly where a proc macro is invoked.
#116298
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @petrochenkov (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
I'm not done yet, sorry for the troubles. |
This comment has been minimized.
This comment has been minimized.
@rustbot review |
compiler/rustc_span/src/lib.rs
Outdated
@@ -587,6 +587,12 @@ impl Span { | |||
matches!(outer_expn.kind, ExpnKind::Macro(..)) && outer_expn.collapse_debuginfo | |||
} | |||
|
|||
/// Returns `true` if `span` originates in a macros 2.0 expansion |
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.
Why macros 2.0 specifically, why is it relevant to this error?
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.
Maybe I'm confused on nomenclature, the wrong help is emitted for proc macros only, with declarative macros the compiler puts the suggestion in the correct place. Aren't proc marcos and macros 2.0 the same thing essentially? If not this should probably just read proc macro expansion
instead of macros 2.0 expansion
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.
Aren't proc marcos and macros 2.0 the same thing essentially?
No, not at all.
Both declarative and procedural macros can use both old and macro 2.0 hygiene.
This situation is far from being unique, I suggest checking what other diagnostics do (fn in_external_macro
or something like that).
@@ -186,6 +186,8 @@ fn make_format_args( | |||
], | |||
Applicability::MaybeIncorrect, | |||
); | |||
} else if unexpanded_fmt_span.in_proc_macro_expansion() { | |||
err.help("you might be missing a string literal to format with in the definition of this macro"); |
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.
A lot of compiler suggestions are skipped for code from macros, but suggestions to look into the macro like this are typically not emitted in such cases.
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: you might be missing a string literal to format with in the definition of this macro | ||
= note: this error originates in the derive macro `format_in_macro::derive` (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.
I don't see the issue from #116190 (#[derive("{}", macros::bare_println)]
) in the test outputs.
Could you add all the tests and make them pass in one commit, and then apply compiler fixes and corresponding test updates in the second commit?
ping from triage - can you post your status on this PR? There hasn't been an update in a few weeks. Thanks! FYI: when a PR is ready for review, send a message containing |
Hi @JohnCSimon, I've started to work on the feedback from petrochenkov, unfortunately I didn't have too much time in the past few weeks. |
There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged. You can start a rebase with the following commands:
The following commits are merge commits: |
5b9af2d
to
9b2a36e
Compare
@cafce25 any updates on this? if this ready for review you can comment with |
Ping from triage: I'm closing this due to inactivity, Please reopen when you are ready to continue with this. @rustbot label: +S-inactive |
Fixes #116190