Skip to content

Commit b0e675b

Browse files
committed
Add documentation on how to migration the edition of the standard library
Based on lessons learned from 2024. There's probably still more details to say here since it was a ton of work. These are the major points that I remember.
1 parent 3d23917 commit b0e675b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/doc/rustc-dev-guide/src/guides/editions.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,21 @@ In general it is recommended to avoid these special cases except for very high v
351351
[into-iter]: https://doc.rust-lang.org/nightly/edition-guide/rust-2021/IntoIterator-for-arrays.html
352352
[panic-macro]: https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html
353353
[`non_fmt_panics`]: https://doc.rust-lang.org/nightly/rustc/lints/listing/warn-by-default.html#non-fmt-panics
354+
355+
### Migrating the standard library edition
356+
357+
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.
368+
369+
[advanced migration guide]: https://doc.rust-lang.org/nightly/edition-guide/editions/advanced-migrations.html
370+
[`backtrace-rs`]: https://github.com/rust-lang/backtrace-rs/
371+
[`stdarch`]: https://github.com/rust-lang/stdarch/

0 commit comments

Comments
 (0)