-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.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
Code
#[proc_macro_attribute]
pub fn attribute_macro(_metadata: TokenStream, input: TokenStream) -> TokenStream {
input
}
Current output
error: expected derive macro, found attribute macro `my_macro::attribute_macro`
|
1 | #[derive(my_macro::attribute_macro)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ not a derive macro
Desired output
(The actual desired output should have colours and minuses on the removed derive, but to give the idea)
error: expected derive macro, found attribute macro `my_macro::attribute_macro`
|
1 | #[derive(my_macro::attribute_macro)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ not a derive macro
= help: remove the "derive":
#[my_macro::attribute_macro]
Rationale and extra context
Many users are not familiar with the terminology being used by the compiler error (i.e. the different flavours of procedural macro, derive vs attribute) and might be confused as to what they need to do in order to fix the error.
Since the fix is straight-forward (i.e. remove the derive
), the compiler should show a code snippet that fixes the issue.
Other cases
No response
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.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.