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/rustc-dev-guide/src/guides/editions.md
+54
Original file line number
Diff line number
Diff line change
@@ -193,6 +193,23 @@ When a user runs `cargo fix --edition`, cargo will pass the `--force-warn rust-2
193
193
flag to force all of these lints to appear during the edition migration.
194
194
Cargo also passes `--cap-lints=allow` so that no other lints interfere with the edition migration.
195
195
196
+
Make sure that the example code sets the correct edition. The example should illustrate the previous edition, and show what the migration warning would look like. For example, this lint for a 2024 migration shows an example in 2021:
197
+
198
+
```rust,ignore
199
+
declare_lint! {
200
+
/// The `keyword_idents_2024` lint detects ...
201
+
///
202
+
/// ### Example
203
+
///
204
+
/// ```rust,edition2021
205
+
/// #![warn(keyword_idents_2024)]
206
+
/// fn gen() {}
207
+
/// ```
208
+
///
209
+
/// {{produces}}
210
+
}
211
+
```
212
+
196
213
Migration lints can be either `Allow` or `Warn` by default.
197
214
If it is `Allow`, users usually won't see this warning unless they are doing an edition migration
198
215
manually or there is a problem during the migration.
@@ -334,3 +351,40 @@ In general it is recommended to avoid these special cases except for very high v
Updating the edition of the standard library itself roughly involves the following process:
358
+
359
+
- Wait until the newly stabilized edition has reached beta and the bootstrap compiler has been updated.
360
+
- Apply migration lints. This can be an involved process since some code is in external submodules[^std-submodules], and the standard library makes heavy use of conditional compilation. Also, running `cargo fix --edition` can be impractical on the standard library itself. One approach is to individually add `#![warn(...)]` at the top of each crate for each lint, run `./x check library`, apply the migrations, remove the `#![warn(...)]` and commit each migration separately. You'll likely need to run `./x check` with `--target` for many different targets to get full coverage (otherwise you'll likely spend days or weeks getting CI to pass)[^ed-docker]. See also the [advanced migration guide] for more tips.
361
+
- Apply migrations to [`backtrace-rs`]. [Example for 2024](https://github.com/rust-lang/backtrace-rs/pull/700). Note that this doesn't update the edition of the crate itself because that is published independently on crates.io, and that would otherwise restrict the minimum Rust version. Consider adding some `#![deny()]` attributes to avoid regressions until its edition gets updated.
362
+
- Apply migrations to [`stdarch`], and update its edition, and formatting. [Example for 2024](https://github.com/rust-lang/stdarch/pull/1710).
363
+
- Post PRs to update the backtrace and stdarch submodules, and wait for those to land.
364
+
- Apply migration lints to the standard library crates, and update their edition. I recommend working one crate at a time starting with `core`. [Example for 2024](https://github.com/rust-lang/rust/pull/138162).
365
+
366
+
[^std-submodules]: This will hopefully change in the future to pull these submodules into `rust-lang/rust`.
367
+
[^ed-docker]: You'll also likely need to do a lot of testing for different targets, and this is where [docker testing](../tests/docker.md) comes in handy.
- Clean up any tests that use the `//@ edition` header to remove the `-Zunstable-options` flag to ensure they are indeed stable. Note: Ideally this should be automated, see [#133582].
383
+
- Bless any tests that change.
384
+
- Update `lint-docs` to default to the new edition.
385
+
386
+
See [example for 2024](https://github.com/rust-lang/rust/pull/133349).
0 commit comments