Minimum Supported Rust Version (MSRV) Policies #231
Replies: 6 comments 18 replies
-
+ a practical advice To reliably test MSRV on CI, use a dedicated `Cargo.lock` file with dependencies pinned to minimal versions: $ cp ci/Cargo.lock.min ./Cargo.lock
$ cargo +$MSRV build |
Beta Was this translation helpful? Give feedback.
-
Hashed out arguments for why MSRV should not be breaking here:
At least one thread of that discussion keeps circling around MSRV SemVer. I think t-libs taking a clear stance here would help. |
Beta Was this translation helpful? Give feedback.
-
Another thought: a common objection to "MSRV is not breaking" policy is a somewhat literal interpretation of sevmer: this change breaks my build, hence its a breaking change, hence it's a major change. There's a similarly literal counter-argument (I don't think it's a good argument, but it might be persuasive because it uses the same reasoning machinery (literal interpretation)): When Rust releases a new version, this is a new minor version: 1.60 -> 1.61 -> 1.62. And a library depends on Rust. Upgrading a minor version of dependency is not considered a breaking change. Indeed, when library A upgrades it dependency on library B from 1.x to 1.x+1, library A can no longer be build with B 1.x.. Its on the consumer of A to ensure they use at least B 1.x+1. This is exactly the same situation if it is |
Beta Was this translation helpful? Give feedback.
-
To me, "Cargo doesn't automatically download the new version of Rust." is precisely why it is a breaking change -- whether we would like it to be or not. |
Beta Was this translation helpful? Give feedback.
-
I think this needs much stronger wording. Doing this creates horrible incompatibilities similar to Python 2 vs 3 fiasco. Example:
Whenever B or C decides to upgrade A it has to also issue breaking release. Further D can't upgrade just B or C alone because the traits don't match and the programmer gets super-confusing type error which he then has to solve by making a wrapper type and a bunch of boilerplate. And literally the only thing this solves is not having to track the version in Cargo toml. 🤦♂️ The only case where this could work is in crates that contain functions only - no type or trait definitions. These are quite uncommon. |
Beta Was this translation helpful? Give feedback.
-
I see an issue with MSRV bumps in patch releases. IMHO it voids the concept of having a well-defined MSRV for library crates at all, as soon as there are dependency chains: Imagine you have 3 library crates in a chain: A depends on B, B depends on C. In effect, that would mean that a library that wants to have a well-defined MSRV would need to add direct, exact dependencies on every single transitive dependency in its dependency tree. That's surely not a scalable solution. |
Beta Was this translation helpful? Give feedback.
-
cc @matklad
#227 suggested the following policy with respect to MSRVs:
A crate should clearly document its Minimal Supported Rust Version:
Compliance with a crate’s stated MSRV should be tested in CI.
The API guidelines tentatively suggest that, for libraries, an MSRV increase should
not be considered a semver-breaking change. Specifically, when increasing
MSRV:
1.0.0
, increment minor version (1.1.3
->1.2.0
),1.0.0
, increment patch version (0.1.3
->0.1.4
).This reduces the amount of ecosystem-wide work for MSRV upgrades and prevents incompatibilities. It also is a de-facto practice for many cornerstone crates. This policy gives more power to library consumers to manually select working combinations of library and compiler versions, at the cost of breaking
cargo update
workflow for older compilers.However, do not increase MSRV without a good reason, and, if possible, batch MSRV increases with semver-breaking changes.
Nonetheless, some crates intentionally choose to treat MSRV increases as a semver breaking change. This is also a valid strategy, but it is not recommended as the default choice.
We aren't quite ready to adopt a guideline around MSRVs so this discussion is here to continue what was started in the original PR.
Beta Was this translation helpful? Give feedback.
All reactions