Skip to content

Conversation

@weihanglo
Copy link
Member

@weihanglo weihanglo commented Dec 1, 2025

What does this PR try to resolve?

Add a new cargo::implicit_minimum_version_req lint:
Only check if dependency has a single caret requirement.
All other requirements (multiple, tilde, wildcard)
are not linted by this rule, as they usually have significance
on what version fields get specified.

Fixes #15577

How to test and review this PR?

@rustbot rustbot added A-documenting-cargo-itself Area: Cargo's documentation A-workspaces Area: workspaces S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 1, 2025

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

Comment on lines 493 to 496
--> Cargo.toml:7:[..]
|
7 | bar = { git = '[ROOTURL]/bar', version = "0.1" }
| [..]^^^^^
Copy link
Member Author

Choose a reason for hiding this comment

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

Because the redaction of [ROOTURL], we have no control oveer column number, so redact them.

@weihanglo weihanglo force-pushed the lint-imprecise-version-req branch from 7fac520 to fa31eaf Compare December 7, 2025 19:40
@rustbot
Copy link
Collaborator

rustbot commented Dec 7, 2025

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 changed the title feat(lint): imprecise_version_requirements feat(lint): new implicit_minimum_version_req lint Dec 7, 2025
@weihanglo weihanglo force-pushed the lint-imprecise-version-req branch 4 times, most recently from 7ce7163 to 20be772 Compare December 7, 2025 20:26
@weihanglo weihanglo force-pushed the lint-imprecise-version-req branch from 20be772 to 62036ab Compare December 8, 2025 22:06
return None;
}

// This is a lossy suggestion that
Copy link
Member Author

Choose a reason for hiding this comment

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

Highlight that the suggestion is lossy

Add a new `cargo::implicit_minimum_version_req` lint:
Only check if dependency has a single caret requirement.
All other requirements (multiple, tilde, wildcard)
are not linted by this rule, as they usually have significance
on what version fields get specified.

This currently lints only dependencies with no workspace inheritance.
This has a future performance that version requirments in
`[workspace.dependencies]` shoud avoid reparse
@weihanglo weihanglo force-pushed the lint-imprecise-version-req branch from 62036ab to 864bf96 Compare December 8, 2025 22:40
Copy link
Contributor

@epage epage left a comment

Choose a reason for hiding this comment

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

@epage epage enabled auto-merge December 8, 2025 22:41
@epage epage added this pull request to the merge queue Dec 8, 2025
Merged via the queue into rust-lang:master with commit 14116aa Dec 8, 2025
28 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 8, 2025
@weihanglo weihanglo deleted the lint-imprecise-version-req branch December 9, 2025 00:13
weihanglo added a commit to weihanglo/cargo that referenced this pull request Dec 9, 2025
`unknown_lints` is special that it analyzes only at package level,
and warn if your lint is inherited from workspace.

According to the discussion in
<rust-lang#16321 (comment)>,
we should lint against workspace always plus selected packages.

This additionally handles unstable lint gating.
weihanglo added a commit to weihanglo/cargo that referenced this pull request Dec 9, 2025
`unknown_lints` is special that it analyzes only at package level,
and warn if your lint is inherited from workspace.

According to the discussion in
<rust-lang#16321 (comment)>,
we should lint against workspace always plus selected packages.

This additionally handles unstable lint gating.
github-merge-queue bot pushed a commit that referenced this pull request Dec 9, 2025
### What does this PR try to resolve?

`unknown_lints` is special that it analyzes only at package level,
and warn if your lint is inherited from workspace.

According to the discussion in
<#16321 (comment)>,
we should lint against workspace always plus selected packages.

This additionally handles unstable lint gating.

### How to test and review this PR?

Two new tests are added to reflect that workspace lints were not
analyzed if not inheriting.
bors added a commit to rust-lang/rust that referenced this pull request Dec 13, 2025
Update cargo submodule

27 commits in 2c283a9a5c5968eeb9a8f12313f04feb1ff8dfac..c46423de7351e3c4c734b2faa86088a9f5d1302b
2025-12-04 16:47:28 +0000 to 2025-12-12 23:16:12 +0000
- feat(report): cargo report timings HTML replay (rust-lang/cargo#16377)
- feat: stabilize `-Zconfig-include` (rust-lang/cargo#16284)
- fix(package): Don't verify registry for --list  (rust-lang/cargo#16341)
- Fixed incorrect locking logic when artifact-dir == build-dir (rust-lang/cargo#16385)
- feat(log): make timing messages ready for HTML replay (rust-lang/cargo#16382)
- chore(deps): update msrv (1 version) to v1.92 (rust-lang/cargo#16381)
- Downgrade curl-sys to 0.4.83 (rust-lang/cargo#16379)
- fix(timing): more self-contained timing/log data (rust-lang/cargo#16378)
- test: update to `proc_macro::tracked::path` (rust-lang/cargo#16380)
- refactor(lint): move lints to separate modules (rust-lang/cargo#16364)
- fix(index): Apply feedback from Cargo team (rust-lang/cargo#16369)
- fix(lints): handle lints separately at ws pkg level  (rust-lang/cargo#16367)
- feat(lint): new `implicit_minimum_version_req` lint (rust-lang/cargo#16321)
- fix(info): default to local without explicit reg (rust-lang/cargo#16358)
- Remove `[no-mentions]` handler in our triagebot config (rust-lang/cargo#16361)
- Don't read the config file twice when $CARGO_HOME is a symlink (rust-lang/cargo#16325)
- fix(timings): forgot to negate filter (rust-lang/cargo#16352)
- fix(doctest): Include all search paths with new build layout  (rust-lang/cargo#16348)
- fix(layout): Remove hashes from bins in new layout  (rust-lang/cargo#16351)
- docs(faq): Include an entry on disk space (rust-lang/cargo#16349)
- feat(timings): derive concurrency data from unit data (rust-lang/cargo#16350)
- perf(layout): Use unit_id, not pkg hash, for bin/lib pkg_dirs for new layout (rust-lang/cargo#16345)
- Validate target source paths before compilation with clearer errors (rust-lang/cargo#16338)
- test(doc): Remove unused build script (rust-lang/cargo#16344)
- refactor(timings): store UnitData in RenderContext instead  (rust-lang/cargo#16346)
- perf(clean): Optimize (legacy) clean with multiple -p specifiers (rust-lang/cargo#16264)
- test: Adjust output for out-of-tree build-dir (rust-lang/cargo#16343)
bors added a commit to rust-lang/rust that referenced this pull request Dec 13, 2025
Update cargo submodule

29 commits in 2c283a9a5c5968eeb9a8f12313f04feb1ff8dfac..e91b2baa632c0c7e84216c91ecfe107c37d887c1
2025-12-04 16:47:28 +0000 to 2025-12-13 16:29:21 +0000
- refactor(lints): move from cargo::util::lints to cargo::lints (rust-lang/cargo#16392)
- test(lint): redact more due to line got omitted (rust-lang/cargo#16391)
- feat(report): cargo report timings HTML replay (rust-lang/cargo#16377)
- feat: stabilize `-Zconfig-include` (rust-lang/cargo#16284)
- fix(package): Don't verify registry for --list  (rust-lang/cargo#16341)
- Fixed incorrect locking logic when artifact-dir == build-dir (rust-lang/cargo#16385)
- feat(log): make timing messages ready for HTML replay (rust-lang/cargo#16382)
- chore(deps): update msrv (1 version) to v1.92 (rust-lang/cargo#16381)
- Downgrade curl-sys to 0.4.83 (rust-lang/cargo#16379)
- fix(timing): more self-contained timing/log data (rust-lang/cargo#16378)
- test: update to `proc_macro::tracked::path` (rust-lang/cargo#16380)
- refactor(lint): move lints to separate modules (rust-lang/cargo#16364)
- fix(index): Apply feedback from Cargo team (rust-lang/cargo#16369)
- fix(lints): handle lints separately at ws pkg level  (rust-lang/cargo#16367)
- feat(lint): new `implicit_minimum_version_req` lint (rust-lang/cargo#16321)
- fix(info): default to local without explicit reg (rust-lang/cargo#16358)
- Remove `[no-mentions]` handler in our triagebot config (rust-lang/cargo#16361)
- Don't read the config file twice when $CARGO_HOME is a symlink (rust-lang/cargo#16325)
- fix(timings): forgot to negate filter (rust-lang/cargo#16352)
- fix(doctest): Include all search paths with new build layout  (rust-lang/cargo#16348)
- fix(layout): Remove hashes from bins in new layout  (rust-lang/cargo#16351)
- docs(faq): Include an entry on disk space (rust-lang/cargo#16349)
- feat(timings): derive concurrency data from unit data (rust-lang/cargo#16350)
- perf(layout): Use unit_id, not pkg hash, for bin/lib pkg_dirs for new layout (rust-lang/cargo#16345)
- Validate target source paths before compilation with clearer errors (rust-lang/cargo#16338)
- test(doc): Remove unused build script (rust-lang/cargo#16344)
- refactor(timings): store UnitData in RenderContext instead  (rust-lang/cargo#16346)
- perf(clean): Optimize (legacy) clean with multiple -p specifiers (rust-lang/cargo#16264)
- test: Adjust output for out-of-tree build-dir (rust-lang/cargo#16343)
@rustbot rustbot added this to the 1.94.0 milestone Dec 13, 2025
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Dec 14, 2025
Update cargo submodule

29 commits in 2c283a9a5c5968eeb9a8f12313f04feb1ff8dfac..e91b2baa632c0c7e84216c91ecfe107c37d887c1
2025-12-04 16:47:28 +0000 to 2025-12-13 16:29:21 +0000
- refactor(lints): move from cargo::util::lints to cargo::lints (rust-lang/cargo#16392)
- test(lint): redact more due to line got omitted (rust-lang/cargo#16391)
- feat(report): cargo report timings HTML replay (rust-lang/cargo#16377)
- feat: stabilize `-Zconfig-include` (rust-lang/cargo#16284)
- fix(package): Don't verify registry for --list  (rust-lang/cargo#16341)
- Fixed incorrect locking logic when artifact-dir == build-dir (rust-lang/cargo#16385)
- feat(log): make timing messages ready for HTML replay (rust-lang/cargo#16382)
- chore(deps): update msrv (1 version) to v1.92 (rust-lang/cargo#16381)
- Downgrade curl-sys to 0.4.83 (rust-lang/cargo#16379)
- fix(timing): more self-contained timing/log data (rust-lang/cargo#16378)
- test: update to `proc_macro::tracked::path` (rust-lang/cargo#16380)
- refactor(lint): move lints to separate modules (rust-lang/cargo#16364)
- fix(index): Apply feedback from Cargo team (rust-lang/cargo#16369)
- fix(lints): handle lints separately at ws pkg level  (rust-lang/cargo#16367)
- feat(lint): new `implicit_minimum_version_req` lint (rust-lang/cargo#16321)
- fix(info): default to local without explicit reg (rust-lang/cargo#16358)
- Remove `[no-mentions]` handler in our triagebot config (rust-lang/cargo#16361)
- Don't read the config file twice when $CARGO_HOME is a symlink (rust-lang/cargo#16325)
- fix(timings): forgot to negate filter (rust-lang/cargo#16352)
- fix(doctest): Include all search paths with new build layout  (rust-lang/cargo#16348)
- fix(layout): Remove hashes from bins in new layout  (rust-lang/cargo#16351)
- docs(faq): Include an entry on disk space (rust-lang/cargo#16349)
- feat(timings): derive concurrency data from unit data (rust-lang/cargo#16350)
- perf(layout): Use unit_id, not pkg hash, for bin/lib pkg_dirs for new layout (rust-lang/cargo#16345)
- Validate target source paths before compilation with clearer errors (rust-lang/cargo#16338)
- test(doc): Remove unused build script (rust-lang/cargo#16344)
- refactor(timings): store UnitData in RenderContext instead  (rust-lang/cargo#16346)
- perf(clean): Optimize (legacy) clean with multiple -p specifiers (rust-lang/cargo#16264)
- test: Adjust output for out-of-tree build-dir (rust-lang/cargo#16343)
github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Dec 15, 2025
Update cargo submodule

29 commits in 2c283a9a5c5968eeb9a8f12313f04feb1ff8dfac..e91b2baa632c0c7e84216c91ecfe107c37d887c1
2025-12-04 16:47:28 +0000 to 2025-12-13 16:29:21 +0000
- refactor(lints): move from cargo::util::lints to cargo::lints (rust-lang/cargo#16392)
- test(lint): redact more due to line got omitted (rust-lang/cargo#16391)
- feat(report): cargo report timings HTML replay (rust-lang/cargo#16377)
- feat: stabilize `-Zconfig-include` (rust-lang/cargo#16284)
- fix(package): Don't verify registry for --list  (rust-lang/cargo#16341)
- Fixed incorrect locking logic when artifact-dir == build-dir (rust-lang/cargo#16385)
- feat(log): make timing messages ready for HTML replay (rust-lang/cargo#16382)
- chore(deps): update msrv (1 version) to v1.92 (rust-lang/cargo#16381)
- Downgrade curl-sys to 0.4.83 (rust-lang/cargo#16379)
- fix(timing): more self-contained timing/log data (rust-lang/cargo#16378)
- test: update to `proc_macro::tracked::path` (rust-lang/cargo#16380)
- refactor(lint): move lints to separate modules (rust-lang/cargo#16364)
- fix(index): Apply feedback from Cargo team (rust-lang/cargo#16369)
- fix(lints): handle lints separately at ws pkg level  (rust-lang/cargo#16367)
- feat(lint): new `implicit_minimum_version_req` lint (rust-lang/cargo#16321)
- fix(info): default to local without explicit reg (rust-lang/cargo#16358)
- Remove `[no-mentions]` handler in our triagebot config (rust-lang/cargo#16361)
- Don't read the config file twice when $CARGO_HOME is a symlink (rust-lang/cargo#16325)
- fix(timings): forgot to negate filter (rust-lang/cargo#16352)
- fix(doctest): Include all search paths with new build layout  (rust-lang/cargo#16348)
- fix(layout): Remove hashes from bins in new layout  (rust-lang/cargo#16351)
- docs(faq): Include an entry on disk space (rust-lang/cargo#16349)
- feat(timings): derive concurrency data from unit data (rust-lang/cargo#16350)
- perf(layout): Use unit_id, not pkg hash, for bin/lib pkg_dirs for new layout (rust-lang/cargo#16345)
- Validate target source paths before compilation with clearer errors (rust-lang/cargo#16338)
- test(doc): Remove unused build script (rust-lang/cargo#16344)
- refactor(timings): store UnitData in RenderContext instead  (rust-lang/cargo#16346)
- perf(clean): Optimize (legacy) clean with multiple -p specifiers (rust-lang/cargo#16264)
- test: Adjust output for out-of-tree build-dir (rust-lang/cargo#16343)
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-workspaces Area: workspaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lint on version requirements without a fully specified minimum bound

4 participants