fix(toml): deprecate hyphen lint names and error on duplicates#17051
fix(toml): deprecate hyphen lint names and error on duplicates#17051raushan728 wants to merge 4 commits into
Conversation
|
r? @epage rustbot has assigned @epage. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| )); | ||
| } | ||
| if let Some(existing) = seen_normalized.get(&normalized) { | ||
| anyhow::bail!( |
There was a problem hiding this comment.
When a commit has "and" in it, it is a good sign it isn't atomic. This is a separate change.
This is also a breaking change. We either need to start as a future incompat warning or deprecate and error in the next edition.
There was a problem hiding this comment.
Initially had edition-gated error for both but it broke existing crates on 2024 edition.Changed hyphen names to warnings.push only. For duplicates, kept bail! should this follow the same pattern as hyphen names warnings.push for now, error in future edition?
There was a problem hiding this comment.
If it is edition gated then it shouldn't affect 2024 edition.
Note: if we edition-gate an error, we need a hand-written migration in cargo fix
There was a problem hiding this comment.
Right, gating against 2024 was the bug since that's already shipped.
Which edition should the error land on, since 2024 is taken?
| for (name, config) in lints { | ||
| let normalized = name.replace('-', "_"); | ||
| if name.contains('-') { | ||
| warnings.push(format!( |
There was a problem hiding this comment.
The issue said we were suppose to error in the next edition.
There was a problem hiding this comment.
Why was this resolved when that error is not present and no reason is given for why it was resolved?
There was a problem hiding this comment.
That was resolved too early without addressing your point. Will
restore the edition-gated error once we settle on the edition.
| )); | ||
| } | ||
| if let Some(existing) = seen_normalized.get(&normalized) { | ||
| anyhow::bail!( |
There was a problem hiding this comment.
Should we generate an error or push an error?
fae8f97 to
5cf81cd
Compare
5cf81cd to
0f44606
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| let normalized_name = name.replace('-', "_"); | ||
| let option = if tool == "rust" { | ||
| format!("{flag}={name}") | ||
| format!("{flag}={normalized_name}") | ||
| } else { | ||
| format!("{flag}={tool}::{name}") | ||
| format!("{flag}={tool}::{normalized_name}") |
There was a problem hiding this comment.
Why does this commit exist?
There was a problem hiding this comment.
rustc already accepts both forms in flags, so this isn't a bug fix, just consistency. Can drop it if you'd rather keep the diff minimal.
| [WARNING] Cargo.toml: `lints.cargo.im-a-teapot` is deprecated in favor of `lints.cargo.im_a_teapot` and will not work in a future edition | ||
| [WARNING] unknown lint: `im-a-teapot` |
There was a problem hiding this comment.
Something isn't working right with this
| [WARNING] Cargo.toml: `lints.cargo.this-lint-does-not-exist` is deprecated in favor of `lints.cargo.this_lint_does_not_exist` and will not work in a future edition | ||
| [WARNING] unknown lint: `this-lint-does-not-exist` |
There was a problem hiding this comment.
This lint should likely be changed to this_lint_does_not_exist in a separate commit
There was a problem hiding this comment.
These use hyphens incidentally to test something unrelated. Will add a prep commit renaming them to underscore first.
|
|
||
| foo.cargo("check") | ||
| .with_stderr_data(str![[r#" | ||
| [WARNING] Cargo.toml: `lints.rust.confusable-idents` is deprecated in favor of `lints.rust.confusable_idents` and will not work in a future edition |
There was a problem hiding this comment.
In a separate commit, we should change this to confusable_idents
There was a problem hiding this comment.
Same here, will fold into the prep commit.
| unexpected-cfgs = "warn" | ||
| unexpected-cfgs = "allow" |
There was a problem hiding this comment.
Why is this change made?
There was a problem hiding this comment.
Leftover from a removed test case. Reverting to warn.
Fixes #13943
Lint names in
[lints]accepted both-and_as separators. This meantunexpected_cfgsandunexpected-cfgswere treated as distinct keys by the TOML parser, causing ambiguous behavior when both appeared in the same block.Changes:
-instead of_, will not work in a future edition_before passing them to rustc