Skip to content

Commit d34db12

Browse files
committed
Add more about versions that aren't caret
1 parent 8abe7c0 commit d34db12

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

text/3493-precise-pre-release-cargo-update.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ Consider this table where `a.b.c` is compatible with `x.y.z` and `x.y.z > a.b.c`
6666

6767
| Cargo.toml spec | Cargo.lock version | Target version | Selected by cargo update | Selected by cargo update --precise |
6868
| --------------- | ------------------ | -------------- | ------------------------- | ----------------------------------- |
69-
| `a.b.c` | `a.b.c` | `x.y.z` |||
70-
| `a.b.c` | `a.b.c` | `x.y.z-pre.0` |||
71-
| `a.b.c` | `x.y.z-pre.0` | `x.y.z-pre.1` |||
72-
| `a.b.c-pre.0` | `a.b.c-pre.0` | `a.b.c-pre.1` | ✅¹ ||
73-
| `a.b.c-pre.0` | `a.b.c-pre.0` | `x.y.z` | ✅¹ ||
74-
| `a.b.c` | `a.b.c` | `a.b.c-pre.0` |||
69+
| `^a.b.c` | `a.b.c` | `x.y.z` |||
70+
| `^a.b.c` | `a.b.c` | `x.y.z-pre.0` |||
71+
| `^a.b.c` | `x.y.z-pre.0` | `x.y.z-pre.1` |||
72+
| `^a.b.c-pre.0` | `a.b.c-pre.0` | `a.b.c-pre.1` | ✅¹ ||
73+
| `^a.b.c-pre.0` | `a.b.c-pre.0` | `x.y.z` | ✅¹ ||
74+
| `^a.b.c` | `a.b.c` | `a.b.c-pre.0` |||
7575

7676
✅: Will upgrade
7777

@@ -81,6 +81,21 @@ Consider this table where `a.b.c` is compatible with `x.y.z` and `x.y.z > a.b.c`
8181
This RFC preserves this behaviour to remain backwards compatible.
8282
Since this RFC is concerned with the behaviour of `cargo update --precise` changes to bare `cargo update` made in future RFCs should have no impact on this proposal.
8383

84+
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.
85+
86+
For example consider the version `~1.2.3`.
87+
The range for `~1.2.3` is [stated in the cargo book](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#tilde-requirements).
88+
89+
```
90+
~1.2.3 := >=1.2.3, <1.3.0
91+
```
92+
93+
Intuitively `1.2.4-pre.0` satisfies this inequality, therefore it can be selected with `cargo update --precise`.
94+
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`.
95+
`1.3.0-pre.0` also satisfies the inequality but `1.2.3-pre.0` and `1.3.1-pre.0` do not.
96+
97+
Put in simple terms the relationship between a pre-release and its stable release is always `a.b.c-pre.0 < a.b.c`.
98+
8499
# Drawbacks
85100
[drawbacks]: #drawbacks
86101

0 commit comments

Comments
 (0)