You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To determine if a version can be selected with `--precise` for a specification that isn't listed above cosider where pre-releases exist within version ranges.
94
+
## Version requirements
95
95
96
-
For example consider the version `~1.2.3`.
97
-
The range for `~1.2.3` is [stated in the cargo book](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#tilde-requirements).
96
+
Version requirement operator semantics will change to encompass pre-release versions, compared to before where the presence of pre-release would change matching modes.
97
+
This will also better align with the mathematical properties associated with some of the operators (see the closed [RFC 3266](https://github.com/rust-lang/rfcs/pull/3266)).
Note that the old syntax implicitly excluded `2.0.0-<prelease>` which we have have to explicitly exclude by referencing the smallest possible pre-release version of `-0`.
108
+
109
+
This change applies to all operators.
110
+
111
+
## Dependency Resolution
112
+
113
+
The intent is to mirror the behavior of yanked today.
114
+
115
+
When parsing a `Cargo.lock`, any pre-release version would be tracked in an allow-list.
116
+
When resolving, we would exclude from consideration any pre-release version unless:
117
+
- It is in the allow-list
118
+
- It matches the version requirement under the old pre-release version requirement semantics.
119
+
120
+
## `cargo update`
121
+
122
+
The version passed in via `--precise` would be added to the allow-list.
123
+
124
+
**Note:** overriding of yanked via this mechanism is not meant to be assumed to be a part of this proposal.
125
+
Support for selecting yanked with `--precise` should be decided separately from this RFC, instead see [rust-lang/cargo#4225](https://github.com/rust-lang/cargo/issues/4225)
102
126
103
-
Intuitively `1.2.4-pre.0` satisfies this inequality, therefore it can be selected with `cargo update --precise`.
104
-
Since it is a pre-release and the specification is not, `1.2.4-pre.0` would not be selected by a bare `cargo update`.
105
-
`1.3.0-pre.0` also satisfies the inequality but `1.2.3-pre.0` and `1.3.1-pre.0` do not.
127
+
## [`semver`](https://crates.io/crates/semver)
106
128
107
-
Put in simple terms the relationship between a pre-release and its stable release is always `a.b.c-pre.0 < a.b.c`.
129
+
`cargo` will need both the old and new behavior exposed.
130
+
To reduce risk of tools in the ecosystem unintentionally matching pre-releases (despite them still needing an opt-in),
131
+
it might be reasonable for the
132
+
`semver`
133
+
package to offer this new matching behavior under a different name
134
+
(e.g. `VersionReq::matches_prerelease` in contrast to the existing `VersionReq::matches`)
135
+
(also avoiding a breaking change).
136
+
However, we leave the exact API details to the maintainer of the `semver` package.
0 commit comments