@@ -17,6 +17,7 @@ declare_lint_pass! {
1717 AARCH64_SOFTFLOAT_NEON ,
1818 ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE ,
1919 AMBIGUOUS_ASSOCIATED_ITEMS ,
20+ AMBIGUOUS_DERIVE_HELPERS ,
2021 AMBIGUOUS_GLOB_IMPORTED_TRAITS ,
2122 AMBIGUOUS_GLOB_IMPORTS ,
2223 AMBIGUOUS_GLOB_REEXPORTS ,
@@ -4267,6 +4268,75 @@ declare_lint! {
42674268 } ;
42684269}
42694270
4271+ declare_lint ! {
4272+ /// The `ambiguous_derive_helpers` lint detects cases where a derive macro's helper attribute
4273+ /// is the same name as that of a built-in attribute.
4274+ ///
4275+ /// ### Example
4276+ ///
4277+ /// ```rust,ignore (proc-macro)
4278+ /// #![crate_type = "proc-macro"]
4279+ /// #![deny(ambiguous_derive_helpers)]
4280+ ///
4281+ /// use proc_macro::TokenStream;
4282+ ///
4283+ /// #[proc_macro_derive(Trait, attributes(ignore))]
4284+ /// pub fn example(input: TokenStream) -> TokenStream {
4285+ /// TokenStream::new()
4286+ /// }
4287+ /// ```
4288+ ///
4289+ /// Produces:
4290+ ///
4291+ /// ```text
4292+ /// warning: there exists a built-in attribute with the same name
4293+ /// --> file.rs:5:39
4294+ /// |
4295+ /// 5 | #[proc_macro_derive(Trait, attributes(ignore))]
4296+ /// | ^^^^^^
4297+ /// |
4298+ /// = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4299+ /// = note: for more information, see issue #151152 <https://github.com/rust-lang/rust/issues/151152>
4300+ /// = note: `#[deny(ambiguous_derive_helpers)]` (part of `#[deny(future_incompatible)]`) on by default
4301+ /// ```
4302+ ///
4303+ /// ### Explanation
4304+ ///
4305+ /// Attempting to use this helper attribute will throw an error:
4306+ ///
4307+ /// ```rust,ignore (needs-dependency)
4308+ /// #[derive(Trait)]
4309+ /// struct Example {
4310+ /// #[ignore]
4311+ /// fields: ()
4312+ /// }
4313+ /// ```
4314+ ///
4315+ /// Produces:
4316+ ///
4317+ /// ```text
4318+ /// error[E0659]: `ignore` is ambiguous
4319+ /// --> src/lib.rs:5:7
4320+ /// |
4321+ /// 5 | #[ignore]
4322+ /// | ^^^^^^ ambiguous name
4323+ /// |
4324+ /// = note: ambiguous because of a name conflict with a builtin attribute
4325+ /// = note: `ignore` could refer to a built-in attribute
4326+ /// note: `ignore` could also refer to the derive helper attribute defined here
4327+ /// --> src/lib.rs:3:10
4328+ /// |
4329+ /// 3 | #[derive(Trait)]
4330+ /// | ^^^^^
4331+ /// ```
4332+ pub AMBIGUOUS_DERIVE_HELPERS ,
4333+ Warn ,
4334+ "detects derive helper attributes that are ambiguous with built-in attributes" ,
4335+ @future_incompatible = FutureIncompatibleInfo {
4336+ reason: fcw!( FutureReleaseError #151276 ) ,
4337+ } ;
4338+ }
4339+
42704340declare_lint ! {
42714341 /// The `private_interfaces` lint detects types in a primary interface of an item,
42724342 /// that are more private than the item itself. Primary interface of an item is all
0 commit comments