-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of 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
Code
#[unsafe(nonexistent)]
fn foo() {}Current output
error: `nonexistent` is not an unsafe attribute
--> src/lib.rs:1:3
|
1 | #[unsafe(nonexistent)]
| ^^^^^^ this is not an unsafe attribute
|
= note: extraneous unsafe is not allowed in attributes
error: cannot find attribute `nonexistent` in this scope
--> src/lib.rs:1:10
|
1 | #[unsafe(nonexistent)]
| ^^^^^^^^^^^Desired output
error: cannot find attribute `nonexistent` in this scope
--> src/lib.rs:1:10
|
1 | #[unsafe(nonexistent)]
| ^^^^^^^^^^^Rationale and extra context
While it is true that an attribute that doesn't exist isn't unsafe, the diagnostic provides not much to no additional value, and is emitted first, pushing the real error down. If both diagnostics should be kept, the one about the attribute not existing should probably be emitted first.
Other cases
Rust Version
rustc 1.91.0, on the Playground
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of 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.