Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Rust Edition and MSRV

Rule

Use Rust 2024 for new code and declare rust-version; default new Rust 2024 crates to 1.85 unless project constraints require otherwise.

Why

The edition controls language compatibility, while rust-version makes the supported compiler floor visible to Cargo, CI, and downstream users.

Do

  • Set edition = "2024" and rust-version = "1.85" for new crates.
  • Keep workspace members aligned unless a crate documents a different constraint.
  • Use stable language features by default.
  • Check reusable libraries, including feature-gated code, with the declared MSRV.
  • Treat a published library MSRV bump as a deliberate compatibility change.
  • Check dependency changes against the MSRV policy on Cargo and dependencies.

Avoid

  • Do not omit rust-version or set it below the selected edition’s minimum.
  • Do not use APIs stabilized after the declared MSRV without updating the declaration.
  • Do not let a dependency silently raise a library’s practical MSRV.
  • Do not use nightly language features as house style.

Example

[package]
name = "example-crate"
version = "0.1.0"
edition = "2024"
rust-version = "1.85"

Verify reusable code with the declared toolchain:

cargo +1.85.0 check --workspace --all-targets --all-features

Exceptions

  • Use Rust 2021 when downstream users, targets, dependencies, or tooling require it.
  • Use a higher MSRV when the project deliberately depends on newer stable features.
  • Migrate existing crates as a focused mechanical change when practical.