fix(toml): warn on hyphenated lint names and duplicates#17051
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?
There was a problem hiding this comment.
Since Edition2027 isn't defined yet, I've downgraded the check to just emit a warning for now. Because it's only a warning, a cargo fix migration isn't needed at this moment. We can introduce the hard error and the migration later when the next edition is officially added.
There was a problem hiding this comment.
We do have EditionFuture. Might be fine for us to move forward with this without handling EditionFuture.
There was a problem hiding this comment.
To add, this isn't marked as closing the Issue so we will still track that remaining work.
| 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.
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?
To follow up on this: I ended up keeping it as a warning instead of a hard error because Edition2027 isn't defined in the codebase yet.
fae8f97 to
5cf81cd
Compare
5cf81cd to
0f44606
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
0f44606 to
8fd7c7b
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. |
| [WARNING] Cargo.toml: `lints.rust.unexpected-cfgs` is deprecated in favor of `lints.rust.unexpected_cfgs` and will not work in a future edition | ||
| [WARNING] Cargo.toml: duplicate lint `unexpected-cfgs` in `[lints.rust]`, conflicts with `unexpected_cfgs` and will not work in a future edition |
There was a problem hiding this comment.
The first one fires simply for using a hyphen in the lint name, and the second one fires because it creates a duplicate conflict after normalization.
Update cargo submodule 17 commits in 3efb1f477e99b42974b982d939fd100303cdf7db..54b61f13a4eea47ec3ee95237d4107976d7909ed 2026-07-17 23:53:19 +0000 to 2026-07-24 13:23:18 +0000 - chore: bump to `libgit2-sys@0.18.7+1.9.6` (rust-lang/cargo#17259) - Enable build-dir layout v2 on nightly by default (rust-lang/cargo#17258) - fix(path): clarify error message when path dependency has wrong package (rust-lang/cargo#16927) - fix(toml): warn on hyphenated lint names and duplicates (rust-lang/cargo#17051) - fix(test): gate trim-paths tests on split debuginfo support (rust-lang/cargo#17256) - test(git): Explicitly test for git injection attacks (rust-lang/cargo#17253) - fix(git): Suggest libgit2 if git-cli fails (rust-lang/cargo#17252) - fix(diag): bound transitive unused dependency traversal (rust-lang/cargo#17251) - fix(git): Hide git fetch output without progress (rust-lang/cargo#17243) - revert(lint): Remove `new_implicit_minimum_version_req` (rust-lang/cargo#16321) (rust-lang/cargo#17249) - fix: Add haiku's dylib path (rust-lang/cargo#17248) - Zsh completion: Add `-p` and `--package` flags for `cargo add` (rust-lang/cargo#17247) - refactor(source): Clarify the name of the remote git registry (rust-lang/cargo#17240) - fix(timings): only report units the job queue actually ran (rust-lang/cargo#17238) - Do not include proc-macro deps in rustc search path args (rust-lang/cargo#17236) - chore(deps): update cargo-semver-checks to v0.49.0 (rust-lang/cargo#17237) - rustdoc: rename the doc parts metadata params (rust-lang/cargo#17234) r? ghost
Update cargo submodule 17 commits in 3efb1f477e99b42974b982d939fd100303cdf7db..54b61f13a4eea47ec3ee95237d4107976d7909ed 2026-07-17 23:53:19 +0000 to 2026-07-24 13:23:18 +0000 - chore: bump to `libgit2-sys@0.18.7+1.9.6` (rust-lang/cargo#17259) - Enable build-dir layout v2 on nightly by default (rust-lang/cargo#17258) - fix(path): clarify error message when path dependency has wrong package (rust-lang/cargo#16927) - fix(toml): warn on hyphenated lint names and duplicates (rust-lang/cargo#17051) - fix(test): gate trim-paths tests on split debuginfo support (rust-lang/cargo#17256) - test(git): Explicitly test for git injection attacks (rust-lang/cargo#17253) - fix(git): Suggest libgit2 if git-cli fails (rust-lang/cargo#17252) - fix(diag): bound transitive unused dependency traversal (rust-lang/cargo#17251) - fix(git): Hide git fetch output without progress (rust-lang/cargo#17243) - revert(lint): Remove `new_implicit_minimum_version_req` (rust-lang/cargo#16321) (rust-lang/cargo#17249) - fix: Add haiku's dylib path (rust-lang/cargo#17248) - Zsh completion: Add `-p` and `--package` flags for `cargo add` (rust-lang/cargo#17247) - refactor(source): Clarify the name of the remote git registry (rust-lang/cargo#17240) - fix(timings): only report units the job queue actually ran (rust-lang/cargo#17238) - Do not include proc-macro deps in rustc search path args (rust-lang/cargo#17236) - chore(deps): update cargo-semver-checks to v0.49.0 (rust-lang/cargo#17237) - rustdoc: rename the doc parts metadata params (rust-lang/cargo#17234) r? ghost
View all comments
Relates #13943
Changes:
_instead of-.-instead of_Note: Kept both as warnings for now since
Edition2027isn't defined yet and 2024 has already shipped.