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 unused_braces #12223

Closed
ickk opened this issue Feb 4, 2024 · 1 comment · Fixed by #12333
Closed

Incorrect clippy::useless_attribute for unused_braces #12223

ickk opened this issue Feb 4, 2024 · 1 comment · Fixed by #12333
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

@ickk
Copy link

ickk commented Feb 4, 2024

Summary

unused_braces is valid on use items.

Lint Name

useless_attribute

Reproducer

I tried this code:

mod module {
  pub struct Struct;
}

#[allow(unused_braces)]
use module::{Struct};

I saw this happen:

error: useless lint attribute
  --> package\src\lib.rs:12:1
   |
12 | #[allow(unused_braces)]
   | ^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(unused_braces)]`
   |
   = 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

warning: `render` (lib) generated 1 warning
error: could not compile `render` (lib) due to 1 previous error; 1 warning emitted

I expected to see this happen:

No errors. #[allow(unused_braces)] is a valid attribute on use statements, to avoid rust-analyzer triggering unused_braces

Version

rustc 1.77.0-nightly (89e2160c4 2023-12-27)
binary: rustc
commit-hash: 89e2160c4ca5808657ed55392620ed1dbbce78d1
commit-date: 2023-12-27
host: x86_64-pc-windows-msvc
release: 1.77.0-nightly
LLVM version: 17.0.6

Additional Labels

No response

@ickk ickk 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 Feb 4, 2024
@MarcusGrass
Copy link
Contributor

You would have encountered the same error, but you should be using #[allow(unused_import_braces)] , made a PR with a fix for that

@bors bors closed this as completed in 5a52c8a Feb 22, 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.

2 participants