Conversation
|
r? @epage rustbot has assigned @epage. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| // have a match whatsoever. Otherwise we need to check | ||
| // `[patch]`... | ||
| if !dep.matches_ignoring_source(id, mode) { | ||
| if !dep.matches_ignoring_source(id, VersionReqMatchMode::Default) { |
There was a problem hiding this comment.
This needs to stick to the default mode because we don't currently support matching prerelease from a [patch] entry
| assert!(!self.patches_locked); | ||
|
|
||
| let mode = VersionReqMatchMode::Default; | ||
| let mode = if self.gctx.cli_unstable().prerelease { |
There was a problem hiding this comment.
This is asking whether a previously locked matches dependency requirement from a [patch] entry, not the version of [patch] itself.
|
cc @celinval |
|
Is this the right direction to go?
I would have assumed the fix would be to do this. |
|
Yeah, that is what this PR is doing. Both consumption and generation side require Were you thinking of a different implementation or anything I am missing? |
97382f3 to
dd76ab8
Compare
This comment has been minimized.
This comment has been minimized.
| @@ -1,4 +1,4 @@ | |||
| # Unstable Features | |||
| # Unstable Featuresunstable.md | |||
There was a problem hiding this comment.
typo?
| # Unstable Featuresunstable.md | |
| # Unstable Features |
There was a problem hiding this comment.
My neovim love pasting nonsense.
| ``` | ||
|
|
||
| It's possible to update `my-dependency` to a pre-release with `update -Zunstable-options my-dependency --precise 0.1.2-pre.0`. | ||
| It's possible to update `my-dependency` to a pre-release with `update -Zprerelease my-dependency --precise 0.1.2-pre.0`. |
There was a problem hiding this comment.
Can we document that the same feature has to be enabled for subsequent cargo commands?
dd76ab8 to
dcd3c7a
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
`-Zunstable-options` only gates `cargo update` for generation side. This prepare use it in consumption side, for example, `cargo build -Zprerelease`.
The second resolution either replaces the locked prerelease, or fails when another dep requires a non-prerelease requirement.
Use prerelease if they are in `Cargo.lock` already, so locked prerelease survive subsequent resolution.
We use prelease match mode for `--precies` when either "update to" or locked version is pre-release. Otherwise the entire `--precise` will be ignored because default mode doesn't match the locked prerelease version.
dcd3c7a to
c84bd1c
Compare
|
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. |
What does this PR try to resolve?
This implements the consumption side of for prerelease version pinning, addressing the issue mentioned in #13290 (comment) (and all the above bug reports)
The initial implementation only dealt with the the resolution creation side (
cargo update --precise <prerelease>), but we never touched how the pinned prerelease versions in lockfile are consumed for subsequent cargo commands.In order to use the pinned prerelease for subsequent cargo commands beyond
cargo update, this adds a new standalone flag-Zprerelease. Previously it was under the umbrella flag-Zunstable-optionsincargo update.How to test and review this PR?
The concept of the implementation is simple: Introduce a new enum modeling version request match mode.
Defaultfor the default semver matching semanticsPrereleasefor additional pre-release matchingHowever, the area this PR touching is messy, and the lockfile consumption site is hard to identify. This is my best-effort work, though I am not sure if it is done 100% correct.
Here is how I checked whether it needs the default semantic or extra prerelease semantic:
OptVersionReqisLockedorPrecise, just use theDefaultmode. Mode makes no difference if it is already exact. For example, code block underreq.is_locked()condition doesn't need prerelease mode.Prereleasemode can only come from lockfile or--precise. Otherwise we may accidentally select more candidates.Future extensions
While We mostly only want to apply prerelease mode on lockfile consumption side + pre-existing
cargo update --preciselocations at this moment, in the future we can probably make this configurable viaresolver.prereleaseacceptingdeny|locked-only|fallback|preferredor else.There are some other "extensions" like supporting
[patch]/[replace]. I meant like whether a[patch]entry of a prerelease version is applicable. I deferred them to future PRs as it is not purely lockfile consumption fix and the RFC didn't mention that, so not going do it right now.🤖 LLM disclosure: LLM helped me find some more edge cases in
[patch]. Code are hand written though.