Skip to content

Recommend package.rust-version in the Rust version section of reference/semver.md. #15806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kpreid
Copy link
Contributor

@kpreid kpreid commented Aug 5, 2025

Adds a recommendation that, to mitigate “possibly breaking” Rust version requirement increases, they should be declared using package.rust-version.

My main goal in this change is to make it possible to find the Rust version section in this page by searching it, but the most appropriate way to fit it into this section seemed to me to be making this recommendation. Declaring (and maintaining) package.rust-version is additional work, but it is a much lesser burden on maintainers than other items in the same list such as "Provide a large window of support".

Adds a recommendation that, to mitigate “possibly breaking” Rust
version requirement increases, they should be declared using
`package.rust-version`.

My main goal in this change is to make it *possible to find* the Rust
version section in this page by searching it, but the most appropriate
way to fit it into this section seemed to me to be making this
recommendation. Declaring (and maintaining) `package.rust-version` is
additional work, but it is a much lesser burden on maintainers than
other items in the same list such as "Provide a large window of support".
@rustbot
Copy link
Collaborator

rustbot commented Aug 5, 2025

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-documenting-cargo-itself Area: Cargo's documentation S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 5, 2025
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@@ -2028,6 +2028,8 @@ Mitigation strategies:
[`#[cfg(accessible(..))]`][cfg-accessible] features which provide an opt-in
mechanism for new features. These are currently unstable and only available
in the nightly channel.
* Use [`package.rust-version`] to declare your package’s compatibility.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Instead of cargo update, should we say "Cargo's dependency resolution"?
  • MSRV resolver at this moment is best-effort, it will still fall back to incompatible version if nothing found, if we want to be more precise.

Comment on lines +2031 to +2032
* Use [`package.rust-version`] to declare your package’s compatibility.
This allows `cargo update` to avoid introducing an incompatible update.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of:

Suggested change
* Use [`package.rust-version`] to declare your package’s compatibility.
This allows `cargo update` to avoid introducing an incompatible update.
* Specify your minimum-supported Rust version by setting [`package.rust-version`], allowing Cargo to [select older versions of your package] when needed rather than erroring. Be sure to consider the [support expectations] when doing so.
[`package.rust-version`]: https://doc.rust-lang.org/cargo/reference/rust-version.html
[select older versions of your package]: https://doc.rust-lang.org/cargo/reference/resolver.html#rust-version
[support expectations]: https://doc.rust-lang.org/cargo/reference/rust-version.html#support-expectations
  • Re-orders and rewords things so the emphasis is on your package's support, to avoid people setting and forgetting this and it being wrong
  • Explicitly calling out support expectations to avoid people setting and forgetting this and it being wrong
  • Applies feedback from weihanglo

Also, based on what we've written for the package.rust-version page, I think it would be fine to list this first, rather than last.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants