skip to content

As maintainer of a widely used Rust library, how would you set its minimum supported Rust version policy, and what keeps eroding it?

level: principalimportance: should knowfreq 30%

answer

  1. users lag the release train
  2. latest, N-2 or calendar window
  3. dependencies move first
  4. verify on the old toolchain

basics

~20 s

Pick a written rule, such as latest stable or a rolling window like N-2, record it in rust-version, verify it with a CI job on that toolchain, and raise it only in minor releases. Dependencies, new std APIs and editions erode it.

solid answer

~40 s

An MSRV is the oldest Rust release on which the crate builds with every feature, and the project itself patches only the latest stable. The policy weighs maintainer cost against users who lag behind: distribution compilers, fixed re-verification schedules. Common rules are latest stable, a rolling window such as N-2, or every release from this calendar year with a grace period. Write the rule down, record it in Cargo's `rust-version`, and verify it with a CI job that runs `cargo check` on that exact toolchain. Raise it only in a minor release, as Cargo's SemVer guide recommends. Erosion comes from dependencies raising their own MSRV, new std APIs used unnoticed, and manifest choices such as edition 2024, which needs Rust 1.85.

go deeper

for a junior

Know what MSRV stands for and that a library states the oldest Rust release it builds on.

for a middle

Explain how the MSRV is recorded and checked, and why a job on the latest stable cannot prove it.

for a senior

Show how MSRV erodes through dependencies, new std APIs and optional features, and how CI catches each of them.

for a principal

Weigh maintainer cost against lagging users, choose a window that fits the crate's place in the ecosystem, and commit to a bump rule users can rely on.

## What an MSRV promises A library's **minimum supported Rust version** (MSRV) is the oldest compiler release on which it builds and works. Cargo's documentation spells out what users reasonably expect from that promise: - **Complete**: every feature combination and every binary works on the supported versions, not just the default build. - **Verified**: the claim is tested automatically, not inferred from memory. - **Dependency support**: each dependency's version requirement allows at least one version that works on the MSRV. The Rust project itself offers bug fixes and security updates **only for the latest stable**, and a new stable ships every six weeks. Yet many users cannot follow that train: some build with the compiler their Linux distribution packages, some re-verify on a fixed schedule such as the first release of the year, and all of them need time to notice a release and test it. The MSRV is where a library decides how far behind the train it will wait for them. ## The policies on the table | Policy | What it means | Who it suits | |---|---|---| | **Latest stable** | build only on the newest release | applications, fast-moving crates with few downstream libraries | | **Rolling window**, e.g. "N-2" | latest release plus a grace window of two releases | most libraries: a few months of lag, predictable | | **Calendar window** | every release from this calendar year, plus a year's grace | foundational crates used by slow-moving users | | **When needed** | raise it whenever a change wants a newer feature | nobody, in the long run: users cannot predict it | There is no right answer, only a trade between three costs Cargo's guide names: the maintainer's cost of not using newer toolchain features or newer dependencies, the users' cost of missing improvements the crate could have had, and the availability of the crate to users on older compilers. A crate at the bottom of the ecosystem, which hundreds of other libraries depend on, sets its MSRV for its slowest important user; a leaf library can be much more aggressive. Cargo's guide also warns against **silent drift**: an MSRV that lags the stated policy invites users to infer a promise you never made. ## What erodes it An MSRV rarely breaks because of one deliberate decision. It erodes: - **Dependencies move first.** A dependency can raise its own MSRV in a minor release, and Cargo's SemVer guide recommends exactly that. Your crate's real minimum becomes the highest MSRV in its graph. With resolver 3, the default on the 2024 edition, Cargo prefers dependency versions compatible with your `rust-version`; the mechanics belong with Cargo's resolver. - **New std APIs slip in.** A contributor developing on the latest stable calls a method stabilised last month; nothing fails locally. Clippy's `incompatible_msrv` lint, which reads `rust-version`, catches many of these, though by default it skips test code. - **Language and manifest choices.** Moving to the 2024 edition requires Rust 1.85; let chains require 1.88 on that edition; newer manifest features require newer Cargo. - **Optional features.** A rarely enabled feature pulls in code or a dependency the default build never compiles, so only a check across feature combinations finds the breakage. ## Enforcing it 1. **Write the policy down** in the README, with how much notice a bump gets. 2. **Record the minimum** in the `rust-version` key, covered with Cargo's manifest. Cargo then refuses to build the package on an older toolchain with a clear error, instead of an obscure syntax failure. 3. **Verify it in CI**: one job installs the MSRV toolchain and runs `cargo check` across targets and features. Cargo's CI guide shows one way to do this with a third-party subcommand that checks every published workspace member against its own `rust-version`, using `cargo check` because most breakage is a missing API, not changed behaviour. Keep the repository's own `rust-toolchain.toml` on recent stable; the MSRV job names its toolchain explicitly. 4. **Raise it only in a minor release**, never a patch, and say so in the changelog. Cargo's SemVer guide treats a higher MSRV as possibly breaking and generally recommends a minor bump, not a major one. 5. **Decide about old lines.** If the policy promises support for older compilers, the last minor version that supports them may need backported fixes; say whether those come from you or from the community. ## When a contributor needs nightly A contributor who wants an unstable feature does not change the MSRV, because no stable release can build it. Keep such code behind an opt-in Cargo feature that is off by default, test it in an advisory nightly job, and leave the shared toolchain pin on stable. Unstable `cfg(version(..))` and `cfg(accessible(..))` would let code detect newer compilers, but both are nightly-only today, so a crate that wants a newer API must either raise its MSRV or carry a small copy of the code until it does.

  • Why does a CI job on the latest stable not prove a Rust library's MSRV?
    Newer compilers accept everything older ones do and more, so a green build on the latest stable says nothing about whether an API, syntax or dependency needs a newer release. Only building on the MSRV toolchain itself shows it still works there, which is why the job installs that exact version and runs `cargo check`.
  • A Rust library's dependency raises its MSRV in a minor release; what can the library do?
    Either follow it and raise its own MSRV in its next minor release, or keep the old minimum: leave the version requirement wide enough to include an older compatible release, which Cargo's MSRV-aware resolution prefers, and keep the MSRV CI job green on it. Whichever it chooses should match the written policy, so users are not surprised.

  • An MSRV is guaranteed by setting rust-version; no CI job is needed.
  • Raising the MSRV must always be a new major version of the library.
  • Testing on the latest stable proves the library still builds on older releases.
  • rust-toolchain.toml in the repository tells users which Rust they need.
  • Dependencies never affect the MSRV because each crate builds separately.

Assumes Rust 1.99.1; the 2024 edition needs Rust 1.85, let chains 1.88, and resolver 3 is the 2024-edition default.