Skip to content

useless_attribute does not understand deprecated_in_future properly #15636

@cyrgani

Description

@cyrgani

Summary

Originally encountered in rust-lang/rust#146326 (comment).

This can only be triggered with deprecated_in_future; deprecated works fine.

Currently, adding the allow causes a clippy error, while removing it causes a rustc error.

(Additionally, it does not make that much sense to suggest removing the !, as the attribute is not at the top of the crate anyway.)

Lint Name

useless_attribute

Reproducer

I tried this code:

#![deny(deprecated_in_future)]
mod f {
    #[deprecated(since = "TBD")]
    pub mod deprec {}
}

#[allow(deprecated_in_future)]
pub use f::deprec;

I saw this happen:

error: useless lint attribute
 --> src/lib.rs:7:1
  |
7 | #[allow(deprecated_in_future)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(deprecated_in_future)]`
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_attribute
  = note: `#[deny(clippy::useless_attribute)]` on by default

I expected to see this happen:
no output

Version

rustc 1.91.0-nightly (1ed3cd703 2025-09-06)
binary: rustc
commit-hash: 1ed3cd7030718935a5c5e5c8f6581f36d8be179f
commit-date: 2025-09-06
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions