Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add matches_prerelease semantic #14305

Merged
merged 4 commits into from
Aug 23, 2024

Conversation

linyihai
Copy link
Contributor

@linyihai linyihai commented Jul 26, 2024

What does this PR try to resolve?

One implementaion for #13290

Thanks to @Eh2406 feedback, a working version came out, and I think it should be able to test under the nightly feature.

This PR proposes a matches_prerelease semantic.

req matches matches_prerelease matches_prerelease_mirror_node 2
Op::Exact
=I.J.K =I.J.K >=I.J.K, <I.J.(K+1)-0 >=I.J.K, <I.J.(K+1)-0
=I.J >=I.J.0, <I.(J+1).0 >=I.J.0, <I.(J+1).0-0 >=I.J.0-0, <I.(J+1).0-0
=I >=I.0.0, <(I+1).0.0 >=I.0.0, <(I+1).0.0-0 >=I.0.0-0, <(I+1).0.0-0
Op::Greater
>I.J.K >I.J.K >I.J.K >I.J.K
>I.J >=I.(J+1).0 >=I.(J+1).0-0 >=I.(J+1).0-0
>I >=(I+1).0.0 >=(I+1).0.0-0 >=(I+1).0.0-0
Op::GreaterEq
>=I.J.K >=I.J.K >=I.J.K >=I.J.K
>=I.J >=I.J.0 >=I.J.0 >=I.J.0-0
>=I >=I.0.0 >=I.0.0 >=I.0.0-0
Op::Less
<I.J.K <I.J.K <I.J.K or I.J.K-0 depends 1 <I.J.K
<I.J <I.J.0 <I.J.0-0 <I.J.0-0
<I <I.0.0 <I.0.0-0 <I.0.0-0
Op::LessEq
<=I.J.K <=I.J.K <=I.J.K <=I.J.K
<=I.J <I.(J+1).0 <I.(J+1).0-0 <I.(J+1).0-0
<=I <(I+1).0.0 <(I+1).0.0-0 <(I+1).0.0-0
Op::Tilde
~I.J.K >=I.J.K, <I.(J+1).0 >=I.J.K, <I.(J+1).0-0 >=I.J.K, <I.(J+1).0-0
~I.J =I.J >=I.J.0, <I.(J+1).0-0 >=I.J.0, <I.(J+1).0-0
~I =I >=I.0.0, <(I+1).0.0-0 >=I.0.0, <(I+1).0.0-0
Op::Caret
^I.J.K (for I>0) >=I.J.K, <(I+1).0.0 >=I.J.K, <(I+1).0.0-0 >=I.J.K, <(I+1).0.0-0
^0.J.K (for J>0) >=0.J.K, <0.(J+1).0 >=0.J.K, <0.(J+1).0-0 >=0.J.K-0, <0.(J+1).0-0
^0.0.K =0.0.K >=0.0.K, <0.0.(K+1)-0 >=0.J.K-0, <0.(J+1).0-0
^I.J ^I.J.0 >=I.J.0, <(I+1).0.0-0 >=I.J.0-0, <(I+1).0.0-0
^0.0 =0.0 >=0.0.0, <0.1.0-0 >=0.0.0-0, <0.1.0-0
^I =I >=I.0.0, <(I+1).0.0-0 >=I.0.0-0, <(I+1).0.0-0
Op::Wildcard
I.J.* =I.J >=I.J.0, <I.(J+1).0-0 >=I.J.0-0, <I.(J+1).0-0
I.* or I.*.* =I >=I.0.0, <(I+1).0.0-0 >=I.0.0-0, <(I+1).0.0-0

Notes:

  • <I.J.K: This is equivalent to <I.J.K-0 if no lower bound or the lower bound isn't pre-release, otherwise this is equivalent to <I.J.K.

Besides, the proposed semtantic left a unsolved issuse , I don't have clear idea to handle it.

How should we test and review this PR?

The tests in src/cargo/util/semver_eval_ext.rs are designed to reflect current semantic.

Additional information

Migrated from dtolnay/semver#321

TBO, this feature was not conceived in advance plus the semantic is unclear at first. I need to experiment step by step and find out what I think makes sense. My experiment can be seen this comment.

@rustbot
Copy link
Collaborator

rustbot commented Jul 26, 2024

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

@rustbot rustbot added A-semver Area: semver specifications, version matching, etc. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 26, 2024
src/cargo/util/semver_ext.rs Outdated Show resolved Hide resolved
src/cargo/util/semver_ext.rs Outdated Show resolved Hide resolved
src/cargo/util/semver_ext.rs Outdated Show resolved Hide resolved
@epage
Copy link
Contributor

epage commented Jul 27, 2024

I've not gone into a lot of the details yet, more focusing on the high level

Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

Really appreciate your efforts on prerelease!

src/cargo/util/semver_ext.rs Outdated Show resolved Hide resolved
@@ -0,0 +1,520 @@
use semver::{Comparator, Op, Prerelease, Version, VersionReq};
Copy link
Member

Choose a reason for hiding this comment

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

Should we have some mod-level comments explaining what have been copied over from semver and why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problems.

@linyihai linyihai force-pushed the matches-prerelease-semantic branch 2 times, most recently from 1586c33 to 3e47ef8 Compare July 29, 2024 02:46
@linyihai

This comment was marked as outdated.

@Eh2406
Copy link
Contributor

Eh2406 commented Aug 1, 2024

Thank you all for doing work on this. I am going on vacation and will not be able to look at or think about this for 2 weeks.

One open design question is whether "matches implies matches_prerelease" is an axiom of our design. If it is then there are all kinds of (obscure) corner cases we need to track down and decide how to deal with. In general we should modify the new thing to meet our axioms. But given how obscure the cases are we should also consider modifying the existing behavior. Breakage will probably be only theoretical.

Please do not let my absence slow down this effort. When people feel it's ready, let's merge this PR. Unstable features are cheap to change if we change our mind.

@linyihai
Copy link
Contributor Author

The forced update commits just updated the comments of the code .

And I had updated the semantic in the PR description, exspecially for <I.J.K.

src/cargo/util/semver_ext.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Aug 20, 2024

☔ The latest upstream changes (presumably #14412) made this pull request unmergeable. Please resolve the merge conflicts.

@linyihai linyihai force-pushed the matches-prerelease-semantic branch from dbe0ace to de78ea3 Compare August 22, 2024 06:45
@rustbot rustbot added the A-manifest Area: Cargo.toml issues label Aug 22, 2024
@@ -75,7 +75,7 @@ fn matches_exact(cmp: &Comparator, ver: &Version) -> bool {
}

// See https://github.com/dtolnay/semver/blob/69efd3cc770ead273a06ad1788477b3092996d29/src/eval.rs#L64-L88
fn matches_greater(cmp: &Comparator, ver: &Version) -> bool {
pub(crate) fn matches_greater(cmp: &Comparator, ver: &Version) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unsure if this commit is worth it. In theory, semver_eval_ext will be going away and we'll have to undo this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, this commit is not very important for this PR. We can decide what to do with it later.

@linyihai linyihai force-pushed the matches-prerelease-semantic branch from de78ea3 to bdf19e0 Compare August 23, 2024 03:16
@epage
Copy link
Contributor

epage commented Aug 23, 2024

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Aug 23, 2024

📌 Commit bdf19e0 has been approved by epage

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 23, 2024
@bors
Copy link
Contributor

bors commented Aug 23, 2024

⌛ Testing commit bdf19e0 with merge a0acc29...

@bors
Copy link
Contributor

bors commented Aug 23, 2024

☀️ Test successful - checks-actions
Approved by: epage
Pushing a0acc29 to master...

@bors bors merged commit a0acc29 into rust-lang:master Aug 23, 2024
22 checks passed
@linyihai linyihai deleted the matches-prerelease-semantic branch August 24, 2024 14:33
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 1, 2024
Update cargo

9 commits in 8f40fc59fb0c8df91c97405785197f3c630304ea..c1fa840a85eca53818895901a53fae34247448b2
2024-08-21 22:37:06 +0000 to 2024-08-29 21:03:53 +0000
- fix(resolve): With `latest` message, differentiate actionable updates (rust-lang/cargo#14461)
- fix(pkgid): Allow open namespaces in PackageIdSpec's (rust-lang/cargo#14467)
- feat(resolve): Report incompatible-with-rustc when MSRV-resolver is disabled (rust-lang/cargo#14459)
- fix(resolve): Report incompatible packages with precise Rust version (rust-lang/cargo#14457)
- fix(resolve): Dont show locking workspace members (rust-lang/cargo#14445)
- Log details of failure if no errors were seen (rust-lang/cargo#14453)
- More helpful missing feature error message (rust-lang/cargo#14436)
- feat: Add matches_prerelease semantic (rust-lang/cargo#14305)
- refactor(update): Prepare for smarter update messages (rust-lang/cargo#14440)

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 1, 2024
Update cargo

9 commits in 8f40fc59fb0c8df91c97405785197f3c630304ea..c1fa840a85eca53818895901a53fae34247448b2
2024-08-21 22:37:06 +0000 to 2024-08-29 21:03:53 +0000
- fix(resolve): With `latest` message, differentiate actionable updates (rust-lang/cargo#14461)
- fix(pkgid): Allow open namespaces in PackageIdSpec's (rust-lang/cargo#14467)
- feat(resolve): Report incompatible-with-rustc when MSRV-resolver is disabled (rust-lang/cargo#14459)
- fix(resolve): Report incompatible packages with precise Rust version (rust-lang/cargo#14457)
- fix(resolve): Dont show locking workspace members (rust-lang/cargo#14445)
- Log details of failure if no errors were seen (rust-lang/cargo#14453)
- More helpful missing feature error message (rust-lang/cargo#14436)
- feat: Add matches_prerelease semantic (rust-lang/cargo#14305)
- refactor(update): Prepare for smarter update messages (rust-lang/cargo#14440)

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 1, 2024
Update cargo

9 commits in 8f40fc59fb0c8df91c97405785197f3c630304ea..c1fa840a85eca53818895901a53fae34247448b2
2024-08-21 22:37:06 +0000 to 2024-08-29 21:03:53 +0000
- fix(resolve): With `latest` message, differentiate actionable updates (rust-lang/cargo#14461)
- fix(pkgid): Allow open namespaces in PackageIdSpec's (rust-lang/cargo#14467)
- feat(resolve): Report incompatible-with-rustc when MSRV-resolver is disabled (rust-lang/cargo#14459)
- fix(resolve): Report incompatible packages with precise Rust version (rust-lang/cargo#14457)
- fix(resolve): Dont show locking workspace members (rust-lang/cargo#14445)
- Log details of failure if no errors were seen (rust-lang/cargo#14453)
- More helpful missing feature error message (rust-lang/cargo#14436)
- feat: Add matches_prerelease semantic (rust-lang/cargo#14305)
- refactor(update): Prepare for smarter update messages (rust-lang/cargo#14440)

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 1, 2024
Update cargo

9 commits in 8f40fc59fb0c8df91c97405785197f3c630304ea..c1fa840a85eca53818895901a53fae34247448b2
2024-08-21 22:37:06 +0000 to 2024-08-29 21:03:53 +0000
- fix(resolve): With `latest` message, differentiate actionable updates (rust-lang/cargo#14461)
- fix(pkgid): Allow open namespaces in PackageIdSpec's (rust-lang/cargo#14467)
- feat(resolve): Report incompatible-with-rustc when MSRV-resolver is disabled (rust-lang/cargo#14459)
- fix(resolve): Report incompatible packages with precise Rust version (rust-lang/cargo#14457)
- fix(resolve): Dont show locking workspace members (rust-lang/cargo#14445)
- Log details of failure if no errors were seen (rust-lang/cargo#14453)
- More helpful missing feature error message (rust-lang/cargo#14436)
- feat: Add matches_prerelease semantic (rust-lang/cargo#14305)
- refactor(update): Prepare for smarter update messages (rust-lang/cargo#14440)

r? ghost
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 2, 2024
Update cargo

9 commits in 8f40fc59fb0c8df91c97405785197f3c630304ea..c1fa840a85eca53818895901a53fae34247448b2
2024-08-21 22:37:06 +0000 to 2024-08-29 21:03:53 +0000
- fix(resolve): With `latest` message, differentiate actionable updates (rust-lang/cargo#14461)
- fix(pkgid): Allow open namespaces in PackageIdSpec's (rust-lang/cargo#14467)
- feat(resolve): Report incompatible-with-rustc when MSRV-resolver is disabled (rust-lang/cargo#14459)
- fix(resolve): Report incompatible packages with precise Rust version (rust-lang/cargo#14457)
- fix(resolve): Dont show locking workspace members (rust-lang/cargo#14445)
- Log details of failure if no errors were seen (rust-lang/cargo#14453)
- More helpful missing feature error message (rust-lang/cargo#14436)
- feat: Add matches_prerelease semantic (rust-lang/cargo#14305)
- refactor(update): Prepare for smarter update messages (rust-lang/cargo#14440)

r? ghost
@rustbot rustbot added this to the 1.83.0 milestone Sep 2, 2024
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Sep 6, 2024
Update cargo

9 commits in 8f40fc59fb0c8df91c97405785197f3c630304ea..c1fa840a85eca53818895901a53fae34247448b2
2024-08-21 22:37:06 +0000 to 2024-08-29 21:03:53 +0000
- fix(resolve): With `latest` message, differentiate actionable updates (rust-lang/cargo#14461)
- fix(pkgid): Allow open namespaces in PackageIdSpec's (rust-lang/cargo#14467)
- feat(resolve): Report incompatible-with-rustc when MSRV-resolver is disabled (rust-lang/cargo#14459)
- fix(resolve): Report incompatible packages with precise Rust version (rust-lang/cargo#14457)
- fix(resolve): Dont show locking workspace members (rust-lang/cargo#14445)
- Log details of failure if no errors were seen (rust-lang/cargo#14453)
- More helpful missing feature error message (rust-lang/cargo#14436)
- feat: Add matches_prerelease semantic (rust-lang/cargo#14305)
- refactor(update): Prepare for smarter update messages (rust-lang/cargo#14440)

r? ghost
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Sep 25, 2024
Update cargo

9 commits in 8f40fc59fb0c8df91c97405785197f3c630304ea..c1fa840a85eca53818895901a53fae34247448b2
2024-08-21 22:37:06 +0000 to 2024-08-29 21:03:53 +0000
- fix(resolve): With `latest` message, differentiate actionable updates (rust-lang/cargo#14461)
- fix(pkgid): Allow open namespaces in PackageIdSpec's (rust-lang/cargo#14467)
- feat(resolve): Report incompatible-with-rustc when MSRV-resolver is disabled (rust-lang/cargo#14459)
- fix(resolve): Report incompatible packages with precise Rust version (rust-lang/cargo#14457)
- fix(resolve): Dont show locking workspace members (rust-lang/cargo#14445)
- Log details of failure if no errors were seen (rust-lang/cargo#14453)
- More helpful missing feature error message (rust-lang/cargo#14436)
- feat: Add matches_prerelease semantic (rust-lang/cargo#14305)
- refactor(update): Prepare for smarter update messages (rust-lang/cargo#14440)

r? ghost
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 A-semver Area: semver specifications, version matching, etc. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants