Skip to content

Incorrect clippy::useless_attribute for unused_braces #12223

@ickk

Description

@ickk

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

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