Skip to content

Incorrect clippy::useless_attribute for disallowed_types #12753

Closed
@9999years

Description

@9999years

Summary

disallowed_types is valid on use items.

Lint Name

useless_attribute

Reproducer

With this clippy.toml:

[[disallowed-types]]
path = "std::io::Stdout"
reason = "Use my_crate::StdoutSafe"

I tried this code:

#[allow(clippy::disallowed_types)]
use std::io::Stdout;

I saw this happen:

error: useless lint attribute
 --> src/stdout.rs:5:1
  |
5 | #[allow(clippy::disallowed_types)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(clippy::disallowed_types)]`
  |
  = 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 failing lints)

Version

rustc 1.77.2 (25ef9e3d8 2024-04-09)
binary: rustc
commit-hash: 25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04
commit-date: 2024-04-09
host: aarch64-apple-darwin
release: 1.77.2
LLVM version: 17.0.6

Additional Labels

@rustbot label +C-bug
@rustbot label +I-false-positive

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