You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/doc/src/reference/rust-version.md
+95-2
Original file line number
Diff line number
Diff line change
@@ -13,8 +13,6 @@ The Rust version must be a bare version number with at least one component; it
13
13
cannot include semver operators or pre-release identifiers. Compiler pre-release
14
14
identifiers such as -nightly will be ignored while checking the Rust version.
15
15
16
-
To find the minimum `rust-version` compatible with your project, you can use third-party tools like [`cargo-msrv`](https://crates.io/crates/cargo-msrv).
17
-
18
16
> **MSRV:** Respected as of 1.56
19
17
20
18
## Uses
@@ -63,3 +61,98 @@ it is expected that each dependency's version-requirement supports at least one
63
61
However,
64
62
it is **not** expected that the dependency specification excludes versions incompatible with your `rust-version`.
65
63
In fact, supporting both allows you to balance the needs of users that support older Rust versions with those that don't.
64
+
65
+
## Setting and Updating Rust Version
66
+
67
+
What Rust versions to support is a trade off between
68
+
- Costs for the maintainer in not using newer features of the Rust toolchain or their dependencies
69
+
- Costs to users who would benefit from a package using newer features of a toolchain, e.g. reducing build times by migrating to a feature in the standard library from a polyfill
70
+
- Availability of a package to users supporting older Rust versions
71
+
72
+
> **Note:**[Changing `rust-version`](semver.md#env-new-rust) is assumed to be a minor incompatibility
73
+
74
+
> **Recommendation:** Choose a policy for what Rust versions to support and when that is changed so users can compare it with their own policy and,
75
+
> if it isn't compatible,
76
+
> decide whether the loss of general improvements or the risk of a blocking bug that won't be fixed is acceptable or not.
77
+
>
78
+
> The simplest policy to support is to always use the latest Rust version.
79
+
>
80
+
> Depending on your risk profile, the next simplest approach is to continue to support old major or minor versions of your package that support older Rust versions.
81
+
82
+
### Selecting supported Rust versions
83
+
84
+
Users of your package are most likely to track their supported Rust versions to:
85
+
- Their Rust toolchain vendor's support policy, e.g. The Rust Project or a Linux distribution
86
+
- Note: the Rust Project only offers bug fixes and security updates for the latest version.
87
+
- A fixed schedule for users to re-verify their packages with the new toolchain, e.g. the first release of the year, every
88
+
89
+
In addition, users are unlikely to be using the new Rust version immediately but need time to notice and re-verify or might not be aligned on the exact same schedule..
90
+
91
+
Example version policies:
92
+
- "N-2", meaning "latest version with a 2 release grace window for updating"
93
+
- Every even release with a 2 release grace window for updating
94
+
- Every version from this calendar year with a one year grace window for updating
95
+
96
+
> **Note:** To find the minimum `rust-version` compatible with your project as-is, you can use third-party tools like [`cargo-msrv`](https://crates.io/crates/cargo-msrv).
97
+
98
+
### Update timeline
99
+
100
+
When your policy specifies you no longer need to support a Rust version, you can update `rust-version` immediately or when needed.
101
+
102
+
By allowing `rust-version` to drift from your policy,
103
+
you offer users more of a grace window for upgrading.
104
+
However, this is too unpredictable to be relied on for aligning with the Rust version users track.
105
+
106
+
The further `rust-version` drifts from your specified policy,
107
+
the more likely users are to infer a policy you did not intend,
108
+
leading to frustration at the unmet expectations.
109
+
110
+
When drift is allowed,
111
+
there is the question of what is "justifiable enough" to drop supported Versions.
112
+
Each person can come to a reasonably different justification;
113
+
working through that discussion can be frustrating for the involved parties.
114
+
This will disempower those who would want to avoid that type of conflict,
115
+
which is particularly the case for new or casual contributors who either
116
+
feel that they are not in a position to raise the question or
117
+
that the conflict may hurt the chance of their change being merged.
118
+
119
+
### Multiple Policies in a Workspace
120
+
121
+
Cargo allows supporting multiple policies within one workspace.
122
+
123
+
Verifying specific packages under specific Rust versions can get complicated.
124
+
Tools like [`cargo-hack`](https://crates.io/crates/cargo-hack) can help.
potentially limiting access to features of the shared dependency for the workspace member with the higher `rust-version`.
130
+
131
+
To allow users to patch a dependency on one of your workspace members,
132
+
every package in the workspace would need to be loadable in the oldest Rust version supported by the workspace.
133
+
134
+
### One or More Policies
135
+
136
+
One way to mitigate the downsides of supporting older Rust versions is to apply your policy to older major or minor versions of your package that you continue to support.
137
+
You likely still need a policy for what Rust versions the development branch support compared to the release branches for those major or minor versions.
138
+
139
+
Only updating the development branch when "needed"' can help reduce the number of supported release branches.
140
+
141
+
There is the question of what can be backported into these release branches.
142
+
By backporting new functionality between minor versions,
143
+
the next available version would be missing it which could be considered a breaking change, violating SemVer.
144
+
Backporting changes also comes with the risk of introducing bugs.
145
+
146
+
Supporting older versions comes at a cost.
147
+
This cost is dependent on the risk and impact of bugs within the package and what is acceptable for backporting.
148
+
Creating the release branches on-demand and putting the backport burden on the community are ways to balance this cost.
149
+
150
+
There is not yet a way for dependency management tools to report that a non-latest version is still supported,
151
+
shifting the responsibility to users to notice this in documentation.
152
+
153
+
For example, a Rust version support policy could look like:
154
+
- The development branch tracks to the latest stable release from the Rust Project, updated when needed
155
+
- The minor version will be raised when changing `rust-version`
156
+
- The project supports every version for this calendar year, with another year grace window
157
+
- The last minor version that supports a supported Rust version will receive community provided bug fixes
158
+
- Fixes must be backported to all supported minor releases between the development branch and the needed supported Rust version
0 commit comments