-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
A nonexistent inner attribute in lib.rs or main.rs breaks every procedural macro used within the entire crate #118455
Copy link
Copy link
Closed
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-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.
Metadata
Metadata
Assignees
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code
Current output
Desired output
Rationale and extra context
Having an inner nonexistent attribute in
lib.rsormain.rsshouldn't break every procedural macro in the entire crate.Usually, one would detect this error just after writing, but when contained within
#[cfg_attr(not(feature = "some-feature", invalid_attribute))]it can remain undetected for a while due to rust-analyzer not reporting errors for every feature combination, and causing the developer to have to deal with potentially several hundred errors without any clear lead on what caused it.When this bug is triggered while having and using, for example, a struct deriving
#[derive(Clone, Eq, PartialEq)]or any other trait, it'll make the compiler emit an error for every attempt to use them. For moderately large projects this means suddenly having hundreds to thousands of errors not related to the actual change from one commit to the next one.Other cases
No response
Anything else?
The bug exists at least in versions
1.72.1(stable) and1.76.0-nightly (a1a37735c 2023-11-23).Playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=45f3021f3d7420b1d8e76d3295d5e283