Skip to content

feat(lints): Add non_kebab_case_bin lint #16524

Merged
Muscraft merged 4 commits intorust-lang:masterfrom
epage:lint
Jan 20, 2026
Merged

feat(lints): Add non_kebab_case_bin lint #16524
Muscraft merged 4 commits intorust-lang:masterfrom
epage:lint

Conversation

@epage
Copy link
Contributor

@epage epage commented Jan 16, 2026

What does this PR try to resolve?

Fixes #15586

How to test and review this PR?

Regarding lint naming:

  • I didn't go with non_kebab_case because we had received
    encouragement to be more specific than non_camel_case when
    discussing this at the All Hands
  • I went with bin rather than bin_name because the thing we are
    ultimately linting is the binary file stem, not any specific field, and if
    other fields end up contributing to the binary name, we should include
    those, like
    bin.namefilename
    or any potential prefixes or suffixes

Regarding the lint's look: I tried to make this look as much like rustc
as possible:

    Checking cargo v0.95.0 (/home/epage/src/personal/cargo)
warning: function `Is_default_main` should have a snake case name
   --> src/cargo/lints/rules/non_kebab_case_bin.rs:188:4
    |
188 | fn Is_default_main(path: Option<&cargo_util_schemas::manifest::PathValue>) -> bool {
    |    ^^^^^^^^^^^^^^^ help: convert the identifier to snake case (notice the capitalization): `is_default_main`
    |
    = note: `#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default

@rustbot rustbot added A-manifest Area: Cargo.toml issues A-workspaces Area: workspaces S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 16, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 16, 2026

r? @ehuss

rustbot has assigned @ehuss.
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

{
desc = desc.element(Snippet::source(contents).path(manifest_path).annotation(
AnnotationKind::Primary.span(span.value).label(format!(
"help: convert the bin name to kebab case: `{kebab_case}`"
Copy link
Member

Choose a reason for hiding this comment

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

I believe it is preferred to have help be its own Group

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was copying the existing rustc message style. Admittedly, rustc tends to not update every message as they evolve their style.

So which do we conform to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was copying the existing rustc message style. Admittedly, rustc tends to not update every message as they evolve their style.

So which do we conform to?

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer, for the time being, to have help be its own group. I think it makes it easier to differentiate the problem and the fix, at the expense of longer output. We can adjust things as we get feedback.

@rustbot

This comment has been minimized.

@epage epage force-pushed the lint branch 2 times, most recently from 956a9a3 to 68e6f88 Compare January 20, 2026 20:45
@rustbot
Copy link
Collaborator

rustbot commented Jan 20, 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.

epage added 2 commits January 20, 2026 14:53
Regarding lint naming:
- I didn't go with `non_kebab_case` because we had received
  encouragement to be more specific than `non_camel_case` when
  discussing this at the All Hands
- I went with `bin` rather than `bin_name` because the thing we are
  ultimately linting is the binary file stem, not any specific field, and if
  other fields end up contributing to the binary name, we should include
  those, like
  [bin.namefilename](https://doc.rust-lang.org/cargo/reference/unstable.html#different-binary-name)
  or any potential [prefixes or suffixes](rust-lang#1970)

Regarding the lint's look: I tried to make this look as much like rustc
as possible:
```
    Checking cargo v0.95.0 (/home/epage/src/personal/cargo)
warning: function `Is_default_main` should have a snake case name
   --> src/cargo/lints/rules/non_kebab_case_bin.rs:188:4
    |
188 | fn Is_default_main(path: Option<&cargo_util_schemas::manifest::PathValue>) -> bool {
    |    ^^^^^^^^^^^^^^^ help: convert the identifier to snake case (notice the capitalization): `is_default_main`
    |
    = note: `#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default
```

Fixes rust-lang#15586
@rustbot rustbot added the A-documenting-cargo-itself Area: Cargo's documentation label Jan 20, 2026
@epage epage force-pushed the lint branch 4 times, most recently from caa3f93 to 6a5bef2 Compare January 20, 2026 22:33
@Muscraft Muscraft enabled auto-merge January 20, 2026 22:49
@Muscraft Muscraft added this pull request to the merge queue Jan 20, 2026
Merged via the queue into rust-lang:master with commit 441c07d Jan 20, 2026
31 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 20, 2026
@epage epage deleted the lint branch January 22, 2026 02:00
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Jan 23, 2026
Update cargo submodule

14 commits in 85eff7c80277b57f78b11e28d14154ab12fcf643..efcd9f58636c1990393d495159045d9c35e43b8f
2026-01-15 16:18:08 +0000 to 2026-01-23 13:50:59 +0000
- chore(deps): update cargo-semver-checks to v0.46.0 (rust-lang/cargo#16548)
- Increase cache_lock test timeout (rust-lang/cargo#16545)
- iTerm now supports OSC 9;4 (terminal window progress bar) (rust-lang/cargo#16506)
- chore: Updated compiler errors for Rust 1.93 (rust-lang/cargo#16543)
- test(build-std): adjust snapshot (rust-lang/cargo#16539)
- chore: bump to 0.96.0 (rust-lang/cargo#16538)
- fix: update `resolve_all_features()` to filter pkg deps (rust-lang/cargo#16221)
- fix: show implicit_minimum_version_req emitted source once per package (rust-lang/cargo#16535)
- fix: `--remap-path-scope` stabilized in 1.95-nightly (rust-lang/cargo#16536)
- feat(lints): Add non_kebab_case_bin lint  (rust-lang/cargo#16524)
- fix(rm): Suggest table flags when none are specified (rust-lang/cargo#16533)
- fix(patch): clean up patch-related error messages (rust-lang/cargo#16498)
- Store artifact deps in build unit dir (rust-lang/cargo#16519)
- refactor(timings): reuse timing metric collection logic between `--timings` and `-Zbuild-analysis` (rust-lang/cargo#16497)
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Jan 23, 2026
Update cargo submodule

14 commits in 85eff7c80277b57f78b11e28d14154ab12fcf643..efcd9f58636c1990393d495159045d9c35e43b8f
2026-01-15 16:18:08 +0000 to 2026-01-23 13:50:59 +0000
- chore(deps): update cargo-semver-checks to v0.46.0 (rust-lang/cargo#16548)
- Increase cache_lock test timeout (rust-lang/cargo#16545)
- iTerm now supports OSC 9;4 (terminal window progress bar) (rust-lang/cargo#16506)
- chore: Updated compiler errors for Rust 1.93 (rust-lang/cargo#16543)
- test(build-std): adjust snapshot (rust-lang/cargo#16539)
- chore: bump to 0.96.0 (rust-lang/cargo#16538)
- fix: update `resolve_all_features()` to filter pkg deps (rust-lang/cargo#16221)
- fix: show implicit_minimum_version_req emitted source once per package (rust-lang/cargo#16535)
- fix: `--remap-path-scope` stabilized in 1.95-nightly (rust-lang/cargo#16536)
- feat(lints): Add non_kebab_case_bin lint  (rust-lang/cargo#16524)
- fix(rm): Suggest table flags when none are specified (rust-lang/cargo#16533)
- fix(patch): clean up patch-related error messages (rust-lang/cargo#16498)
- Store artifact deps in build unit dir (rust-lang/cargo#16519)
- refactor(timings): reuse timing metric collection logic between `--timings` and `-Zbuild-analysis` (rust-lang/cargo#16497)
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Jan 24, 2026
Update cargo submodule

14 commits in 85eff7c80277b57f78b11e28d14154ab12fcf643..efcd9f58636c1990393d495159045d9c35e43b8f
2026-01-15 16:18:08 +0000 to 2026-01-23 13:50:59 +0000
- chore(deps): update cargo-semver-checks to v0.46.0 (rust-lang/cargo#16548)
- Increase cache_lock test timeout (rust-lang/cargo#16545)
- iTerm now supports OSC 9;4 (terminal window progress bar) (rust-lang/cargo#16506)
- chore: Updated compiler errors for Rust 1.93 (rust-lang/cargo#16543)
- test(build-std): adjust snapshot (rust-lang/cargo#16539)
- chore: bump to 0.96.0 (rust-lang/cargo#16538)
- fix: update `resolve_all_features()` to filter pkg deps (rust-lang/cargo#16221)
- fix: show implicit_minimum_version_req emitted source once per package (rust-lang/cargo#16535)
- fix: `--remap-path-scope` stabilized in 1.95-nightly (rust-lang/cargo#16536)
- feat(lints): Add non_kebab_case_bin lint  (rust-lang/cargo#16524)
- fix(rm): Suggest table flags when none are specified (rust-lang/cargo#16533)
- fix(patch): clean up patch-related error messages (rust-lang/cargo#16498)
- Store artifact deps in build unit dir (rust-lang/cargo#16519)
- refactor(timings): reuse timing metric collection logic between `--timings` and `-Zbuild-analysis` (rust-lang/cargo#16497)
@rustbot rustbot added this to the 1.95.0 milestone Jan 24, 2026
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 25, 2026
Update cargo submodule

14 commits in 85eff7c80277b57f78b11e28d14154ab12fcf643..efcd9f58636c1990393d495159045d9c35e43b8f
2026-01-15 16:18:08 +0000 to 2026-01-23 13:50:59 +0000
- chore(deps): update cargo-semver-checks to v0.46.0 (rust-lang/cargo#16548)
- Increase cache_lock test timeout (rust-lang/cargo#16545)
- iTerm now supports OSC 9;4 (terminal window progress bar) (rust-lang/cargo#16506)
- chore: Updated compiler errors for Rust 1.93 (rust-lang/cargo#16543)
- test(build-std): adjust snapshot (rust-lang/cargo#16539)
- chore: bump to 0.96.0 (rust-lang/cargo#16538)
- fix: update `resolve_all_features()` to filter pkg deps (rust-lang/cargo#16221)
- fix: show implicit_minimum_version_req emitted source once per package (rust-lang/cargo#16535)
- fix: `--remap-path-scope` stabilized in 1.95-nightly (rust-lang/cargo#16536)
- feat(lints): Add non_kebab_case_bin lint  (rust-lang/cargo#16524)
- fix(rm): Suggest table flags when none are specified (rust-lang/cargo#16533)
- fix(patch): clean up patch-related error messages (rust-lang/cargo#16498)
- Store artifact deps in build unit dir (rust-lang/cargo#16519)
- refactor(timings): reuse timing metric collection logic between `--timings` and `-Zbuild-analysis` (rust-lang/cargo#16497)
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jan 26, 2026
Update cargo submodule

14 commits in 85eff7c80277b57f78b11e28d14154ab12fcf643..efcd9f58636c1990393d495159045d9c35e43b8f
2026-01-15 16:18:08 +0000 to 2026-01-23 13:50:59 +0000
- chore(deps): update cargo-semver-checks to v0.46.0 (rust-lang/cargo#16548)
- Increase cache_lock test timeout (rust-lang/cargo#16545)
- iTerm now supports OSC 9;4 (terminal window progress bar) (rust-lang/cargo#16506)
- chore: Updated compiler errors for Rust 1.93 (rust-lang/cargo#16543)
- test(build-std): adjust snapshot (rust-lang/cargo#16539)
- chore: bump to 0.96.0 (rust-lang/cargo#16538)
- fix: update `resolve_all_features()` to filter pkg deps (rust-lang/cargo#16221)
- fix: show implicit_minimum_version_req emitted source once per package (rust-lang/cargo#16535)
- fix: `--remap-path-scope` stabilized in 1.95-nightly (rust-lang/cargo#16536)
- feat(lints): Add non_kebab_case_bin lint  (rust-lang/cargo#16524)
- fix(rm): Suggest table flags when none are specified (rust-lang/cargo#16533)
- fix(patch): clean up patch-related error messages (rust-lang/cargo#16498)
- Store artifact deps in build unit dir (rust-lang/cargo#16519)
- refactor(timings): reuse timing metric collection logic between `--timings` and `-Zbuild-analysis` (rust-lang/cargo#16497)
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Jan 27, 2026
Update cargo submodule

14 commits in 85eff7c80277b57f78b11e28d14154ab12fcf643..efcd9f58636c1990393d495159045d9c35e43b8f
2026-01-15 16:18:08 +0000 to 2026-01-23 13:50:59 +0000
- chore(deps): update cargo-semver-checks to v0.46.0 (rust-lang/cargo#16548)
- Increase cache_lock test timeout (rust-lang/cargo#16545)
- iTerm now supports OSC 9;4 (terminal window progress bar) (rust-lang/cargo#16506)
- chore: Updated compiler errors for Rust 1.93 (rust-lang/cargo#16543)
- test(build-std): adjust snapshot (rust-lang/cargo#16539)
- chore: bump to 0.96.0 (rust-lang/cargo#16538)
- fix: update `resolve_all_features()` to filter pkg deps (rust-lang/cargo#16221)
- fix: show implicit_minimum_version_req emitted source once per package (rust-lang/cargo#16535)
- fix: `--remap-path-scope` stabilized in 1.95-nightly (rust-lang/cargo#16536)
- feat(lints): Add non_kebab_case_bin lint  (rust-lang/cargo#16524)
- fix(rm): Suggest table flags when none are specified (rust-lang/cargo#16533)
- fix(patch): clean up patch-related error messages (rust-lang/cargo#16498)
- Store artifact deps in build unit dir (rust-lang/cargo#16519)
- refactor(timings): reuse timing metric collection logic between `--timings` and `-Zbuild-analysis` (rust-lang/cargo#16497)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-documenting-cargo-itself Area: Cargo's documentation A-manifest Area: Cargo.toml issues A-workspaces Area: workspaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lint that binary names should be kebab case

4 participants