Skip to content

feat(diag): Stabilize cargo-lints - #17298

Merged
weihanglo merged 5 commits into
rust-lang:masterfrom
epage:stable-lints
Aug 25, 2026
Merged

feat(diag): Stabilize cargo-lints #17298
weihanglo merged 5 commits into
rust-lang:masterfrom
epage:stable-lints

Conversation

@epage

@epage epage commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

View all comments

What does this PR try to resolve?

Fixes #12235

Unstable feature docs: https://doc.rust-lang.org/stable/cargo/reference/unstable.html#lintscargo

We are adding a linting system to workspaces and packages controlled by [lints.cargo].

As the presence of [lints.cargo] was a hard error before 1.79, by-default warn/deny lints are ignored when package.rust-version is set below that.

Workspace lints are controlled by [workspace.lints] if present, otherwise [lints]. This was inspired by workspace.resolver.
The rust-version used for the workspace is the lowest among the workspace members.

In vetting the design, we have a fully general parse-pass that runs during build operations as well as cargo fetxh (matching deferred warnings and errors from manifest parsing). We also have a one-off lint that runs against the completed build units.

The initial batch of lints being stabilized is documented at https://doc.rust-lang.org/nightly/cargo/reference/lints.html

For more on the behavior of these lints, see https://github.com/rust-lang/cargo/tree/master/tests/testsuite/lints

Relevant docs:

How to test and review this PR?

At #t-cargo > Last items for linting system: `unused_dependencies`, I raised concern over unused_dependencies name in case we want to add other kinds of unused dependencies (like artifacts) as separate lints. No one expressed interest in that, so I kept it as a general lint name. I didn't add package to the name since our existing dept tables don't have that and the intent is likely clear.

@rustbot rustbot added A-build-execution Area: anything dealing with executing the compiler A-documenting-cargo-itself Area: Cargo's documentation A-manifest Area: Cargo.toml issues A-unstable Area: nightly unstable support S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 1, 2026
@rustbot

rustbot commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

r? @weihanglo

rustbot has assigned @weihanglo.
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: @epage, @weihanglo
  • @epage, @weihanglo expanded to epage, weihanglo

@weihanglo weihanglo Aug 2, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just thought about this: Do we dogfood this yet? Maybe before stabilization we can do it in rust-lang/cargo and rust-lang/rust and get an sense of how it looks like in real world.

Not a blocker btw

View changes since the review

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.

I have tried it out a couple times on Cargo. I have not on rust-lang/rust.

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.

I just tried in rustc

  • several cargo::manual_readme
  • several cargo::non_kebab_case_bins
  • A warning about #![expect(unused_crate_dependencies)] being unfulfilled.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the info!

Should we configure our CI to adopt that?

@epage
epage force-pushed the stable-lints branch 2 times, most recently from e7f3786 to 424ad37 Compare August 4, 2026 15:17
@rustbot

This comment has been minimized.

@epage
epage force-pushed the stable-lints branch 2 times, most recently from 5d91e48 to 426df5f Compare August 4, 2026 20:26
@rustbot

This comment has been minimized.

Comment thread tests/testsuite/script/cargo.rs
Comment thread crates/xtask-lint-docs/src/main.rs

@weihanglo weihanglo Aug 4, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you share why we need to allow cargo::default here for many tests? Were they got lint warnings for the same reason, or case by case?

View changes since the review

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.

Most test have unused dependencies. There were a smattering of others. I figured it would be easier to do this globally than resolving lints, allowing on a case-by-case basis, etc.

@weihanglo weihanglo added the T-cargo Team: Cargo label Aug 4, 2026
@weihanglo

This comment was marked as duplicate.

1 similar comment
@weihanglo

Copy link
Copy Markdown
Member

@rfcbot fcp merge T-cargo

We have discussed this during the sync weekly meeting. Ed has written a good review guide. Would be appreciated if people find a time reviewing them.

@rust-rfcbot

rust-rfcbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

@weihanglo has proposed to merge this. The next step is review by the rest of the tagged team members:

Concerns:

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period An FCP proposal has started, but not yet signed off. disposition-merge FCP with intent to merge labels Aug 4, 2026
@weihanglo

Copy link
Copy Markdown
Member

@rfcbot concern blanket_hint_mostly_unused

Should this be behind -Zprofile-hint-mostly-unused?

@epage

epage commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

I believe so.

@epage

epage commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Since I won the race for blanket_hint_mostly_unused, I posted #17313 to update the feature gate

@weihanglo

Copy link
Copy Markdown
Member

@rfcbot resolve blanket_hint_mostly_unused

#17313

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-rfcbot rust-rfcbot added finished-final-comment-period FCP complete and removed final-comment-period FCP — a period for last comments before action is taken labels Aug 22, 2026
@rust-rfcbot

Copy link
Copy Markdown
Collaborator

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

@weihanglo weihanglo added the relnotes Release-note worthy label Aug 22, 2026
@weihanglo
weihanglo enabled auto-merge August 22, 2026 21:30
@rustbot

rustbot commented Aug 24, 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.

@weihanglo
weihanglo disabled auto-merge August 24, 2026 19:45
Comment thread tests/testsuite/cache_messages.rs
Comment thread tests/testsuite/cache_messages.rs
Comment thread doc/book/src/reference/unstable.md Outdated
Comment thread doc/book/src/reference/unstable.md Outdated
Comment thread tests/testsuite/rustdocflags.rs Outdated
Comment thread tests/testsuite/rustc.rs
Comment thread tests/testsuite/profile_settings.rs Outdated
Comment thread tests/testsuite/build_dir.rs

@weihanglo weihanglo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@weihanglo
weihanglo added this pull request to the merge queue Aug 25, 2026
Merged via the queue into rust-lang:master with commit 94ba974 Aug 25, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 25, 2026
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Aug 26, 2026
Update cargo submodule

7 commits in e8cb624d5701824f46a2ec5873cfd59ee3d2f66c..94ba974179df2adb3c911fadf361f03b84aa8f14
2026-08-22 00:23:45 +0000 to 2026-08-25 18:16:11 +0000
- feat(diag): Stabilize cargo-lints  (rust-lang/cargo#17298)
- chore(deps): Update partial_ref to v0.3.4 (rust-lang/cargo#17392)
- refactor: remove ad-hoc `subslice_range` (rust-lang/cargo#17390)
- docs(changelog): move build-dir new layout to Changed (rust-lang/cargo#17387)
- chore(deps): update msrv (1 version) to v1.98 (rust-lang/cargo#17386)
- docs: Use mdbook admonitions (rust-lang/cargo#17384)
- chore(ci): exclude resolver-tests from intra doc link checks (rust-lang/cargo#17385)
@epage
epage deleted the stable-lints branch August 27, 2026 01:38
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Sep 2, 2026
Update cargo submodule



26 commits in e8cb624d5701824f46a2ec5873cfd59ee3d2f66c..b2e9d5f9db3fb1c454ab84f10c16508984a266e2
2026-08-22 00:23:45 +0000 to 2026-09-02 14:49:16 +0000
- fix(parser): Resolve theoretical use-after-free (rust-lang/cargo#17428)
- fix(trim-paths)!: remove default scope from release profile (rust-lang/cargo#17424)
- fix(git): Use git's 429 retry, when available (rust-lang/cargo#17422)
- Avoid passing search path (-L) args when they are passed as --extern (rust-lang/cargo#17410)
- chore(deps): update crate-ci/typos action to v1.50.0 (rust-lang/cargo#17417)
- test: Move -Z onto its own line (rust-lang/cargo#17416)
- chore(triagebot): enable `@rustbot merge/delegate` (rust-lang/cargo#17415)
- Micro-optimize two package dir functions (rust-lang/cargo#17413)
- perf: Do not build SBOM if user has not set build.sbom (rust-lang/cargo#17412)
- feat(manifest)!: implement feature-metadata RFC3416 (rust-lang/cargo#15056)
- Cargo profiling improvements (rust-lang/cargo#17411)
- test(git): Remove gix override run in CI and the mode in code (rust-lang/cargo#17405)
- perf(git): Reduce extra work when using git-cli (rust-lang/cargo#17406)
- feat(resolver): Stabilize min-publish-age (rust-lang/cargo#17335)
- fix(git): Remove ref status update when showing progress  (rust-lang/cargo#17400)
- revert: refactor: move sysroot lookup to GlobalContext (rust-lang/cargo#17401)
- fix(run): Printing a new line to avoid overwriting error code after \r (rust-lang/cargo#17373)
- fix(trim-paths): custom workspace-relative member paths remap (rust-lang/cargo#17366)
- fix(home): rustdoc lint (rust-lang/cargo#17394)
- feat(diag): Stabilize cargo-lints  (rust-lang/cargo#17298)
- chore(deps): Update partial_ref to v0.3.4 (rust-lang/cargo#17392)
- refactor: remove ad-hoc `subslice_range` (rust-lang/cargo#17390)
- docs(changelog): move build-dir new layout to Changed (rust-lang/cargo#17387)
- chore(deps): update msrv (1 version) to v1.98 (rust-lang/cargo#17386)
- docs: Use mdbook admonitions (rust-lang/cargo#17384)
- chore(ci): exclude resolver-tests from intra doc link checks (rust-lang/cargo#17385)
@rustbot rustbot added this to the 1.100.0 milestone Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-execution Area: anything dealing with executing the compiler A-documenting-cargo-itself Area: Cargo's documentation A-manifest Area: Cargo.toml issues A-unstable Area: nightly unstable support disposition-merge FCP with intent to merge finished-final-comment-period FCP complete relnotes Release-note worthy T-cargo Team: Cargo to-announce

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

User control over cargo warnings

5 participants