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
@nik-rev nik-rev force-pushed the helper_attr_builtin branch from 7903366 to f4eca01 Compare February 8, 2026 11:04
@chenyukang
Copy link
Member

Thanks!
@bors r=chenyukang

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 10, 2026

📌 Commit f4eca01 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
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 10, 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 10, 2026
Rollup of 7 pull requests

Successful merges:

 - #151152 (Add FCW for derive helper attributes that will conflict with built-in attributes)
 - #151954 (Add help message suggesting explicit reference cast for From/TryFrom)
 - #152148 (Move `impl Interner for TyCtxt` to its own submodule)
 - #152226 (Modernize diagnostic for indeterminate trait object lifetime bounds)
 - #150688 (typeck: Make it clearer that `check_pat_lit` only handles literal patterns)
 - #152293 (Format heterogeneous try blocks)
 - #152396 (Uplift `Predicate::allow_normalization` to `rustc_type_ir`)
@JonathanBrouwer
Copy link
Contributor

@bors r-
#152421 (comment)

@rust-bors rust-bors bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 10, 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
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.