-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The tokens generated by proc_macro (e.g. from quote!()
) use Span::call_site()
, which makes some suggestions produce invalid output:
error[E0308]: mismatched types
--> src/main.rs:3:1
|
3 | #[hello]
| ^^^^^^^^
| |
| expected `&mut i32`, found integer
| help: consider mutably borrowing here: `&mut #[hello]`
It's a bit tricky, because this call_site span does point into the current crate (to #[hello]
), so this situaiton isn't detected in the same way as external macro_rules
.
Metadata
Metadata
Assignees
Labels
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
m-ou-se commentedon Jun 2, 2021
Looks like
rustc_middle::lint::in_external_macro
should be used in more places. That one detects thiscall_site
span by checking ifdef_site
is a dummy or imported.m-ou-se commentedon Jun 2, 2021
I'm working on a fix specifically for these typeck/borrowing suggestions. Not sure how many other suggestions have the same problem.
estebank commentedon Jun 3, 2021
@m-ou-se this is a prevalent problem. We need to add metadata to spans to distinguish call sites explicitly in an easy way and always ignore suggestions in them.
Rollup merge of rust-lang#85937 - m-ou-se:macro-ref-suggestions, r=es…
Rollup merge of rust-lang#85937 - m-ou-se:macro-ref-suggestions, r=es…