RFC 2495 specifies how crates can describe in their
Cargo.toml what the minimal supported Rust version is.
While this will not be used during dependency resolution (that was scoped out of the RFC as future work), it can help give better error messages if you're trying to compile a crate with a compiler that is too old: instead of specific errors about APIs that are not available, you'll get an explicit error saying the compiler is not supported. There are also some nice potential wins for Clippy (which could figure out from the stated
rust-version which lints should be applied) or for CI systems, that could automatically figure out which Rust version to run against to test MSRV support.
In order to test it, you will need nightly Cargo, and add the following to your
cargo-features = ["rust-version"] [package] rust-version = "1.54"
cargo +nightly c, and an error should appear:
error: package `foo v0.1.0 (/Users/djc/src/foo)` cannot be built because it requires rustc 1.54 or newer, while the currently active rustc version is 1.53.0-nightly
I'm very interested to hear if the feature makes sense, if more documentation is needed, and if you see unexpected edge cases when for example testing with patched dependencies, path dependencies, git dependencies, in workspaces, with alternate registries, or anything else you can think of.