Closed Kriskras99 closed 2 weeks ago
This is more or less expected behavior with how lint tables are implemented in cargo currently. You need to give the lint group cargo
a lower priority so that the specific lint multiple_crate_versions
overrides it, e.g. cargo = { level = "warn", priority = -1 }
.
See also #12161 and #12093 for similar issues where this has caused confusion in the past.
Clippy does have a lint against this kind of mistake, but it does not work for workspaces.
error: lint group `cargo` has the same priority (0) as a lint
--> Cargo.toml:16:1
|
16 | cargo = "warn"
| ^^^^^ ------ has an implicit priority of 0
17 | multiple_crate_versions = "allow"
| ----------------------- 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: `#[deny(clippy::lint_groups_priority)]` on by default
help: to have lints override the group set `cargo` to a lower priority
|
16 | cargo = { level = "warn", priority = -1 }
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ah, that makes sense.
Should I open an issue for lint_groups_priority
not firing for workspaces? Or reuse this one?
Closing in favor of #12729
Summary
I like to set categories as
"warn"
or"deny"
, and then allow specific lints. For example"warn"
oncargo
lints, but"allow"
themultiple_crate_versions
. Currently this does not work, and I have to add an override when running Clippy on the command lineReproducer
I tried this code:
I expected to see this happen: Warnings for
cargo
lints, but not formultiple_crate_versions
Instead, this happened:
Version
Additional Labels
No response