Skip to content

Use caret (^) as the default required_version comparator - #7048

Merged
ytmimi merged 2 commits into
rust-lang:mainfrom
wesleymatosdev:fix/6729-caret-default
Oct 10, 2026
Merged

ytmimi merged 2 commits into
rust-lang:mainfrom
wesleymatosdev:fix/6729-caret-default

Conversation

@wesleymatosdev

Copy link
Copy Markdown
Contributor

Closes #6729

Summary

required_version currently treats a bare version (no comparator prefix) as
an exact match, overriding the semver crate's own default of a caret
requirement. As discussed in #6729, this diverges from how Cargo treats
dependency version requirements with no operator, where a bare version like
"1.2.3" is equivalent to "^1.2.3".

This removes the override in check_semver_version so a bare version behaves
like ^version, matching Cargo's convention. The old exact-match behavior is
still available by opting in explicitly with =, e.g.
required_version = "=1.2.3".

  • src/config/mod.rs: remove the per-comparator override that forced a bare
    (no-prefix) comparator from semver's own default (Op::Caret) back to
    Op::Exact.
  • Configurations.md: documents the new default, adds an explicit "Match on
    exact version" example using =, and notes the caret-default in the
    Possible values bullet.
  • CHANGELOG.md: adds a Changed entry under [Unreleased] referencing
    Use caret (^) comparison instead of == for required_version #6729.

Test plan

  • cargo test --lib required_version — all 19 existing tests pass unchanged;
    none of them depended on the old exact-only default (they all either use
    the current version as its own requirement, an explicit operator, or a
    requirement whose major/minor already differs enough that caret vs. exact
    makes no difference).
  • cargo test --lib check_semver_version — 27 tests pass, including two new
    ones: test_default_caret_match (renamed from test_exact_version_match,
    with the two assertions that change under the new default flipped) and
    test_explicit_exact_match (covers the opt-in = exact-match path).
  • cargo test --lib (full suite, binary built first): 235 passed; 0 failed.

Copilot AI lite review requested due to automatic review settings August 22, 2026 20:06
@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Aug 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@matthewhughes934 matthewhughes934 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.

functionally looks good, I had some thoughts on some of the comments.

View changes since this review

Comment thread src/config/mod.rs Outdated
Comment thread src/config/mod.rs Outdated
Comment thread Configurations.md Outdated
@wesleymatosdev

Copy link
Copy Markdown
Contributor Author

suggestions applied. Thank you for reviewing it @matthewhughes934

@ytmimi

ytmimi commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@wesleymatosdev Please rebase these changes on the latest main when you get a chance.

required_version currently treats a bare version (no comparator prefix)
as an exact match, overriding the semver crate's own default of a caret
requirement. This diverges from how Cargo treats dependency version
requirements with no operator.

Remove the override so a bare version behaves like `^version`, matching
Cargo's convention. The old exact-match behavior is still available by
opting in explicitly with `=`.
Drop the now-unnecessary old-behavior explanations from the
check_semver_version comment and the test_explicit_exact_match
test, and combine the Configurations.md caret-default note with
an equivalent bare-version example.
@wesleymatosdev
wesleymatosdev force-pushed the fix/6729-caret-default branch from 68d1b90 to 9a8d9ca Compare October 7, 2026 17:16
@rustbot

rustbot commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main 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.

@rustbot

This comment has been minimized.

@ytmimi

ytmimi commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

@wesleymatosdev Please remove Closes #6729 from 08fe6dc's commit message.

@ytmimi ytmimi added S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: awaiting review from the assignee but also interested parties. labels Oct 7, 2026
@wesleymatosdev
wesleymatosdev force-pushed the fix/6729-caret-default branch from 9a8d9ca to 29fe674 Compare October 7, 2026 23:50
@wesleymatosdev

Copy link
Copy Markdown
Contributor Author

@ytmimi removed!

@ytmimi

ytmimi commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Thank you!

@ytmimi
ytmimi added this pull request to the merge queue Oct 10, 2026
Merged via the queue into rust-lang:main with commit ed040bb Oct 10, 2026
33 checks passed
@rustbot rustbot added release-notes Needs an associated changelog entry and removed S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. labels Oct 10, 2026
@rustbot rustbot mentioned this pull request Oct 10, 2026
1 of 2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes Needs an associated changelog entry UO-required_version Unstable option: required_version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use caret (^) comparison instead of == for required_version

5 participants