rust-lang / rust-lang/rust-clippy

The useless attribute lint doesn't put the ! in the right place.

Open
#1,522 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug E-hard
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

When the useless_attribute lint is activated, it says that you most likely forgot an exclamation mark (!). While this is true, it also suggests to stick the ! in the middle of the attribute:

warning: useless lint attribute, #[warn(useless_attribute)] on by default
 --> src/lib.rs:1:38
  |
1 | #[cfg_attr(feature = "cargo-clippy", allow(new_without_default))]
  |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
help: if you just forgot a `!`, use
  | #[cfg_attr(feature = "cargo-clippy", a!llow(new_without_default))]
  = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#useless_attribute

The correct response should be to suggest adding it after the #
I'm using the latest clippy on the latest nightly Rust.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the useless_attribute diagnostic from the issue using the cfg_attr example in src/lib.rs with the latest Clippy and Rust nightly. Trace the useless_attribute lint's help suggestion and update its reported insertion point so the ! is recommended after #; done when the diagnostic shows the corrected placement.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.