Skip to content

fix(toml): warn on hyphenated lint names and duplicates#17051

Merged
epage merged 4 commits into
rust-lang:masterfrom
raushan728:fix/lint-hyphen-deprecation-and-duplicate-detection
Jul 22, 2026
Merged

fix(toml): warn on hyphenated lint names and duplicates#17051
epage merged 4 commits into
rust-lang:masterfrom
raushan728:fix/lint-hyphen-deprecation-and-duplicate-detection

Conversation

@raushan728

@raushan728 raushan728 commented May 30, 2026

Copy link
Copy Markdown
Contributor

View all comments

Relates #13943

Changes:

  • Refactor: Updated unrelated existing tests to use _ instead of -.
  • Warn on Hyphens: Emits a deprecation warning if a lint name uses - instead of _
  • Warn on Duplicates: Emits a warning if two lint names conflict after normalization

Note: Kept both as warnings for now since Edition2027 isn't defined yet and 2024 has already shipped.

@rustbot rustbot added A-manifest Area: Cargo.toml issues S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 30, 2026
@rustbot

rustbot commented May 30, 2026

Copy link
Copy Markdown
Collaborator

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

Comment thread src/cargo/util/toml/mod.rs Outdated
));
}
if let Some(existing) = seen_normalized.get(&normalized) {
anyhow::bail!(

@epage epage May 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

View changes since the review

@raushan728 raushan728 May 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@raushan728 raushan728 Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, gating against 2024 was the bug since that's already shipped.
Which edition should the error land on, since 2024 is taken?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have EditionFuture. Might be fine for us to move forward with this without handling EditionFuture.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!(

@epage epage May 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue said we were suppose to error in the next edition.

View changes since the review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this resolved when that error is not present and no reason is given for why it was resolved?

@raushan728 raushan728 Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was resolved too early without addressing your point. Will restore the edition-gated error once we settle on the edition.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/testsuite/lints/mod.rs Outdated
Comment thread src/cargo/util/toml/mod.rs Outdated
@raushan728
raushan728 force-pushed the fix/lint-hyphen-deprecation-and-duplicate-detection branch 2 times, most recently from fae8f97 to 5cf81cd Compare May 31, 2026 06:56
@raushan728
raushan728 requested a review from epage May 31, 2026 07:21
Comment thread tests/testsuite/lints_table.rs Outdated
@raushan728
raushan728 force-pushed the fix/lint-hyphen-deprecation-and-duplicate-detection branch from 5cf81cd to 0f44606 Compare June 1, 2026 05:44
@rustbot

This comment has been minimized.

Comment thread src/cargo/util/toml/mod.rs Outdated
Comment thread tests/testsuite/lints/mod.rs Outdated
Comment thread tests/testsuite/lints/unknown_lints.rs Outdated
Comment thread tests/testsuite/lints_table.rs Outdated
Comment thread tests/testsuite/lints_table.rs Outdated
@rustbot

This comment has been minimized.

@raushan728
raushan728 force-pushed the fix/lint-hyphen-deprecation-and-duplicate-detection branch from 0f44606 to 8fd7c7b Compare July 19, 2026 11:33
@rustbot

rustbot commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

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.

@raushan728 raushan728 changed the title fix(toml): deprecate hyphen lint names and error on duplicates fix(toml): warn on hyphenated lint names and duplicates Jul 19, 2026
Comment on lines +897 to +898
[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

@raushan728 raushan728 Jul 19, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

View changes since the review

@raushan728
raushan728 requested a review from epage July 19, 2026 11:59

@epage epage left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@epage
epage added this pull request to the merge queue Jul 22, 2026
Merged via the queue into rust-lang:master with commit f0001ff Jul 22, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 22, 2026
@raushan728
raushan728 deleted the fix/lint-hyphen-deprecation-and-duplicate-detection branch July 23, 2026 05:57
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jul 25, 2026
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
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jul 25, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-manifest Area: Cargo.toml issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants