Open Alexendoo opened 1 year ago
This was left as a future possibility in the RFC.
To implement this, either cargo needs to pass the lints down to the tool in a way to communicate the priority batches, allow cargo to query the group memberships from the linter, or we hard code this at compile-time like rust-analyzer (lints, generate). One thing to keep in mind is the potential for custom tools in the future.
I'm confused by this.
[lints.rust]
dead-code = { level = "allow", priority = 1 }
warnings = { level = "deny", priority = 0 }
Does what I expect it to do
[lints.rust]
dead-code = { level = "allow", priority = 0 }
warnings = { level = "deny", priority = 1 }
Works just fine too.
I would expect that if I override a specific lint from a group that was included, that the override wins. Which is what Rust itself seems to do, regardless of sort order.
Only in the case of 2 groups disagreeing on a setting is when I would think to start using priorities.
warnings
is a dynamic group of everything that is currently set to warn
.
Is there a workaround for this in the meantime? I keep coming back around to this issue. I'm forced to just use -A flag on cargo directly and still can't seem to make anything work in config.toml or Cargo.toml.
There is a PR for a clippy lint for when groups are the same priority as lints.
For why you are having difficulty, its hard to say without a reproduction case.
i'm not sure if this is a bug in this new behavior, but after updating to 1.78 i'm getting
error: lint group `pedantic` has the same priority (0) as a lint
|
16 | pedantic = "warn"
| ^^^^^^^^ ------ has an implicit priority of 0
17 | wildcard_enum_match_arm = "warn"
| ----------------------- 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 `pedantic` to a lower priority
|
16 | pedantic = { level = "warn", priority = -1 }
these both have the same level, so i'm not sure why it would need a priority. pedantic
and wildcard_enum_match_arm
are both allow
by default, so i need this setting to enable them. wildcard_enum_match_arm
is not in the pedantic
group, so i'm not sure why i'd need to set a priority for one over the other.
FYI that is a clippy lint and there is at least rust-lang/rust-clippy#12270 opened against it which is similar to what you are seeing.
Problem
The sorting behaviour is causing confusion, me included as I thought this was a bug until I read the RFC
https://github.com/rust-lang/rust-clippy/issues/11751#issuecomment-1792620053 https://github.com/rust-lang/rust-clippy/issues/11237
Steps
No response
Possible Solution(s)
No response
Notes
No response
Version
No response