Skip to content

fix(toml): deprecate hyphen lint names and error on duplicates#17051

Open
raushan728 wants to merge 4 commits into
rust-lang:masterfrom
raushan728:fix/lint-hyphen-deprecation-and-duplicate-detection
Open

fix(toml): deprecate hyphen lint names and error on duplicates#17051
raushan728 wants to merge 4 commits into
rust-lang:masterfrom
raushan728:fix/lint-hyphen-deprecation-and-duplicate-detection

Conversation

@raushan728
Copy link
Copy Markdown
Contributor

@raushan728 raushan728 commented May 30, 2026

Fixes #13943

Lint names in [lints] accepted both - and _ as separators. This meant unexpected_cfgs and unexpected-cfgs were treated as distinct keys by the TOML parser, causing ambiguous behavior when both appeared in the same block.

Changes:

  • Deprecation warning when a lint name uses - instead of _, will not work in a future edition
  • Error when two lint names conflict after normalization
  • Normalize lint names to _ before passing them to rustc

@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
Copy link
Copy Markdown
Collaborator

rustbot commented May 30, 2026

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

));
}
if let Some(existing) = seen_normalized.get(&normalized) {
anyhow::bail!(
Copy link
Copy Markdown
Contributor

@epage epage May 30, 2026

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

Copy link
Copy Markdown
Contributor Author

@raushan728 raushan728 May 31, 2026

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?

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

@epage epage May 30, 2026

Choose a reason for hiding this comment

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

Should we generate an error or push an error?

View changes since the review

@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
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 1, 2026

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.

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 S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lints table allows both - and _ separators, including allowing redundant entries.

3 participants