rust-lang / rust-lang/rust-clippy

`lint_groups_priority` clippy lint seems to misattribute lints to groups

Open
#12,920 9 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug D-confusing I-false-positive
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

I’m using the following Cargo.toml:

[package]
name = "testing"
version = "0.1.0"
edition = "2021"

[lints.clippy]
lint_groups_priority = "warn"

[lints.rust]
keyword_idents = "deny"
macro_use_extern_crate = "deny"
rust_2018_idioms = "deny"
single_use_lifetimes = "deny"

Running cargo clippy produces two warnings here:

warning: lint group `keyword_idents` has the same priority (0) as a lint
  --> Cargo.toml:10:1
   |
10 | keyword_idents = "deny"
   | ^^^^^^^^^^^^^^   ------ has an implicit priority of 0
11 | macro_use_extern_crate = "deny"
   | ---------------------- has the same priority as this lint
   |
   = note: the order of the lints in the table is ignored by Cargo
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#lint_groups_priority
   = note: requested on the command line with `-W clippy::lint-groups-priority`
help: to have lints override the group set `keyword_idents` to a lower priority
   |
10 | keyword_idents = { level = "deny", priority = -1 }
   |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

warning: lint group `rust_2018_idioms` has the same priority (0) as a lint
  --> Cargo.toml:12:1
   |
12 | rust_2018_idioms = "deny"
   | ^^^^^^^^^^^^^^^^   ------ has an implicit priority of 0
13 | single_use_lifetimes = "deny"
   | -------------------- has the same priority as this lint
   |
   = note: the order of the lints in the table is ignored by Cargo
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#lint_groups_priority
help: to have lints override the group set `rust_2018_idioms` to a lower priority
   |
12 | rust_2018_idioms = { level = "deny", priority = -1 }
   |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

While making the proposed changes silences the warnings, these look like false positives. According to documentation, single_use_lifetimes isn’t part of rust_2018_idioms, and keyword_idents isn’t a group at all.

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (d0227c6a1 2024-06-11)
binary: rustc
commit-hash: d0227c6a19c2d6e8dceb87c7a2776dc2b10d2a04
commit-date: 2024-06-11
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

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 report with the provided Cargo.toml using cargo clippy and the listed rustc 1.81.0-nightly version. Trace how lint_groups_priority identifies groups and compare its attribution with the documented membership of keyword_idents and rust_2018_idioms. Done means the lint no longer reports these false positives while still detecting genuine priority conflicts.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.