Skip to content

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)]
  |          ^^^^^

@rustbot
Copy link
Collaborator

rustbot commented Jan 15, 2026

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 15, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 15, 2026

r? @chenyukang

rustbot has assigned @chenyukang.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

@nik-rev nik-rev force-pushed the helper_attr_builtin branch 2 times, most recently from 54147eb to c9b7a07 Compare January 15, 2026 04:02
@rustbot

This comment has been minimized.

@nik-rev nik-rev requested a review from chenyukang January 18, 2026 02:14
@chenyukang
Copy link
Member

@bors r=chenyukang

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 18, 2026

📌 Commit 4dda363 has been approved by chenyukang

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 18, 2026
@petrochenkov
Copy link
Contributor

New deprecation lints go through language team process, and the lint name also doesn't follow naming conventions.

@chenyukang
Copy link
Member

@bors r-

@rust-bors rust-bors bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 18, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 18, 2026

Commit 4dda363 has been unapproved.

@rust-bors rust-bors bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 18, 2026
@nik-rev
Copy link
Contributor Author

nik-rev commented Jan 18, 2026

@rustbot label +I-lang-nominated

I am nominating this for lang-team attention.

What name should this lint have? The current name doesn't follow the naming conventions

My main idea is allow(derive_helper_attr_with_same_name_as_a_builtin_attr), but that's quite long

@rustbot rustbot added the I-lang-nominated Nominated for discussion during a lang team meeting. label Jan 18, 2026
@rust-bors

This comment has been minimized.

@traviscross traviscross added T-lang Relevant to the language team needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. labels Jan 21, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 10, 2026

Commit f4eca01 has been unapproved.

This PR was contained in a rollup (#152421), which was also unapproved.

@nik-rev nik-rev force-pushed the helper_attr_builtin branch from f4eca01 to 846e4ee Compare February 10, 2026 19:39
@rustbot
Copy link
Collaborator

rustbot commented Feb 10, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@nik-rev
Copy link
Contributor Author

nik-rev commented Feb 10, 2026

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 10, 2026

@nik-rev: 🔑 Insufficient privileges: not in review users

@nik-rev
Copy link
Contributor Author

nik-rev commented Feb 10, 2026

@bors r=JonathanBrouwer

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 10, 2026

@nik-rev: 🔑 Insufficient privileges: not in review users

@nik-rev
Copy link
Contributor Author

nik-rev commented Feb 10, 2026

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 10, 2026
@JonathanBrouwer
Copy link
Contributor

@bors try jobs=test-various

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Feb 10, 2026
Add FCW for derive helper attributes that will conflict with built-in attributes


try-job: test-various
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 10, 2026

☀️ Try build successful (CI)
Build commit: 8b451e4 (8b451e434ccbe03d091c882a267b1ee8474752b3, parent: d00ba922591daa3d0a8b0f3cdf54c610097c24ea)

@JonathanBrouwer
Copy link
Contributor

@bors r=chenyukang

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 10, 2026

📌 Commit 846e4ee has been approved by chenyukang

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 10, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Feb 11, 2026
…=chenyukang

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

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.

```rust
#![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:

```rust
#[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)]
  |          ^^^^^
```
Zalathar added a commit to Zalathar/rust that referenced this pull request Feb 11, 2026
…=chenyukang

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

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.

```rust
#![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:

```rust
#[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)]
  |          ^^^^^
```
Zalathar added a commit to Zalathar/rust that referenced this pull request Feb 12, 2026
…=chenyukang

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

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.

```rust
#![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:

```rust
#[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)]
  |          ^^^^^
```
rust-bors bot pushed a commit that referenced this pull request Feb 12, 2026
Rollup of 17 pull requests

Successful merges:

 - #142415 (Add note when inherent impl for a alias type defined outside of the crate)
 - #142680 (Fix passing/returning structs with the 64-bit SPARC ABI)
 - #150768 (Don't compute FnAbi for LLVM intrinsics in backends)
 - #151152 (Add FCW for derive helper attributes that will conflict with built-in attributes)
 - #151814 (layout: handle rigid aliases without params)
 - #151863 (Borrowck: simplify diagnostics for placeholders)
 - #152159 (Add note for `?Sized` params in int-ptr casts diag)
 - #152434 (Clarify names of `QueryVTable` functions for "executing" a query)
 - #152478 (Remove tm_factory field from CodegenContext)
 - #152498 (Partially revert "resolve: Update `NameBindingData::vis` in place")
 - #152316 (fix: add continue)
 - #152394 (Correctly check if a macro call is actually a macro call in rustdoc highlighter)
 - #152425 (Port #![test_runner] to the attribute parser)
 - #152481 (Use cg_ssa's produce_final_output_artifacts in cg_clif)
 - #152485 (fix issue#152482)
 - #152495 (Clean up some subdiagnostics)
 - #152502 (Implement `BinaryHeap::from_raw_vec`)
@rust-bors rust-bors bot merged commit 2dba560 into rust-lang:main Feb 12, 2026
12 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 12, 2026
rust-timer added a commit that referenced this pull request Feb 12, 2026
Rollup merge of #151152 - nik-contrib:helper_attr_builtin, r=chenyukang

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

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.

```rust
#![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:

```rust
#[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)]
  |          ^^^^^
```
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.