Skip to content

Commit 48b75c5

Browse files
committed
Suggest MSRV policy
I don't think there's a strong consensus here yet. However, there seems to be a weak consensus, and also de-facto practice for many popular crates (`cfg-if`, `lazy-static`). Additionally, there's a lot of continuous discussion and re-litigation across various forums and issue trackers. So it seems like tentatively documenting current practice might make sense?
1 parent 91939a7 commit 48b75c5

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/checklist.md

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
- **Necessities** *(to whom they matter, they really matter)*
7373
- [ ] Public dependencies of a stable crate are stable ([C-STABLE])
7474
- [ ] Crate and its dependencies have a permissive license ([C-PERMISSIVE])
75+
- [ ] Crate has MSRV policy ([C-MSRV])
7576

7677

7778
[C-CASE]: naming.html#c-case
@@ -139,3 +140,4 @@
139140

140141
[C-STABLE]: necessities.html#c-stable
141142
[C-PERMISSIVE]: necessities.html#c-permissive
143+
[C-MSRV]: necessities.html#c-msrv

src/necessities.md

+35
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,38 @@ cannot be used in some situations where most of the Rust runtime stack can.
109109
The license of a crate's dependencies can affect the restrictions on
110110
distribution of the crate itself, so a permissively-licensed crate should
111111
generally only depend on permissively-licensed crates.
112+
113+
<a id="c-msrv"></a>
114+
## Crate has a MSRV policy (C-MSRV)
115+
116+
A crate should clearly document its Minimal Supported Rust Version:
117+
118+
* Which versions versions of Rust are supported now?
119+
* Under what conditions is MSRV increased?
120+
* How MSRV increases are reflected in the semver version of the crate?
121+
122+
MSRV should be tested in CI.
123+
124+
The API guidelines tentatively suggest that, for libraries, MSRV increase should
125+
*not* be considered a semver-breaking change. Specifically, when increasing
126+
MSRV:
127+
128+
* for crates past `1.0.0` increment minor version (`1.1.3` -> `1.2.0`),
129+
* for crates before `1.0.0`, increment patch version (`0.1.3` -> `0.1.4`).
130+
131+
This reduces the amount of ecosystem-wide work for MSRV upgrades and prevents
132+
incompatibilities. It also is a de-facto practice for many cornerstone crates.
133+
This policy gives more power to library consumers to manually select working
134+
combinations of library and compiler versions, at the cost of breaking `cargo
135+
update` workflow for older compilers.
136+
137+
However, do not increase MSRV without a good reason, and, if possible, batch
138+
MSRV increases with sevmer-breaking changes.
139+
140+
To reliably test MSRV on CI, use a dedicated Cargo.lock file with dependencies
141+
pinned to minimal versions:
142+
143+
```bash
144+
$ cp ci/Cargo.lock.min ./Cargo.lock
145+
$ cargo +$MSRV test
146+
```

0 commit comments

Comments
 (0)