Skip to content

Add FCW for derive helper attributes that will conflict with built-in attributes#151152

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nik-contrib:helper_attr_builtin
Feb 12, 2026
Merged

Add FCW for derive helper attributes that will conflict with built-in attributes#151152
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nik-contrib:helper_attr_builtin

Conversation

@nik-rev
Copy link
Contributor

@nik-rev nik-rev commented Jan 15, 2026

Adds a future-compatibility-warning deny-by-default lint that helps catch invalid derive helper attribute names early.

This issues the lint, saying that ignore helper will clash with the built-in ignore attribute.

#![crate_type = "proc-macro"]
#![deny(ambiguous_derive_helpers)] 
use proc_macro::TokenStream; 

#[proc_macro_derive(Trait, attributes(ignore))]
pub fn example(input: TokenStream) -> TokenStream {
    TokenStream::new()
}

If you actually tried to use that ignore helper attribute, you won't be able to due to the ambiguity:

#[derive(Trait)]
struct Foo {
    #[ignore]
    field: (),
}

Produces:

error[E0659]: `ignore` is ambiguous
 --> src/lib.rs:5:7
  |
5 |     #[ignore]
  |       ^^^^^^ ambiguous name
  |
  = note: ambiguous because of a name conflict with a builtin attribute
  = note: `ignore` could refer to a built-in attribute
note: `ignore` could also refer to the derive helper attribute defined here
 --> src/lib.rs:3:10
  |
3 | #[derive(Trait)]
  |          ^^^^^

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team to-announce Announce this issue on triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.