Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect clippy::useless_attribute for disallowed_types #12753

Closed
9999years opened this issue May 2, 2024 · 0 comments · Fixed by #12755
Closed

Incorrect clippy::useless_attribute for disallowed_types #12753

9999years opened this issue May 2, 2024 · 0 comments · Fixed by #12755
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@9999years
Copy link
Contributor

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

@9999years 9999years added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels May 2, 2024
bors added a commit that referenced this issue May 6, 2024
…umeGomez

Allow more attributes in `clippy::useless_attribute`

Fixes #12753
Fixes #4467
Fixes #11595
Fixes #10878

changelog: [`useless_attribute`]: Attributes allowed on `use` items now include `ambiguous_glob_exports`, `hidden_glob_reexports`, `dead_code`, `unused_braces`, and `clippy::disallowed_types`.
@bors bors closed this as completed in 8d8c0bf May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant