Skip to content

Commit 786a53d

Browse files
Rollup merge of #140538 - tshepang:rust-push, r=jieyouxu
rustc-dev-guide subtree update r? ``@ghost``
2 parents 9d7d782 + bf06eaf commit 786a53d

File tree

12 files changed

+393
-151
lines changed

12 files changed

+393
-151
lines changed

src/doc/rustc-dev-guide/.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
if: github.repository == 'rust-lang/rustc-dev-guide'
1515
runs-on: ubuntu-latest
1616
env:
17-
MDBOOK_VERSION: 0.4.21
17+
MDBOOK_VERSION: 0.4.48
1818
MDBOOK_LINKCHECK2_VERSION: 0.9.1
1919
MDBOOK_MERMAID_VERSION: 0.12.6
2020
MDBOOK_TOC_VERSION: 0.11.2

src/doc/rustc-dev-guide/josh-sync/src/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl GitSync {
194194
);
195195
println!(
196196
// Open PR with `subtree update` title to silence the `no-merges` triagebot check
197-
" https://github.com/{UPSTREAM_REPO}/compare/{github_user}:{branch}?quick_pull=1&title=Rustc+dev+guide+subtree+update&body=r?+@ghost"
197+
" https://github.com/{UPSTREAM_REPO}/compare/{github_user}:{branch}?quick_pull=1&title=rustc-dev-guide+subtree+update&body=r?+@ghost"
198198
);
199199

200200
drop(josh);

src/doc/rustc-dev-guide/rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
deb947971c8748f5c6203548ce4af9022f21eaf0
1+
0c33fe2c3d3eecadd17a84b110bb067288a64f1c

src/doc/rustc-dev-guide/src/SUMMARY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
- [ADTs and Generic Arguments](./ty_module/generic_arguments.md)
158158
- [Parameter types/consts/regions](./ty_module/param_ty_const_regions.md)
159159
- [`TypeFolder` and `TypeFoldable`](./ty-fold.md)
160+
- [Aliases and Normalization](./normalization.md)
160161
- [Typing/Param Envs](./typing_parameter_envs.md)
161162
- [Type inference](./type-inference.md)
162163
- [Trait solving](./traits/resolution.md)
@@ -176,7 +177,6 @@
176177
- [Coinduction](./solve/coinduction.md)
177178
- [Caching](./solve/caching.md)
178179
- [Proof trees](./solve/proof-trees.md)
179-
- [Normalization](./solve/normalization.md)
180180
- [Opaque types](./solve/opaque-types.md)
181181
- [Significant changes and quirks](./solve/significant-changes.md)
182182
- [`Unsize` and `CoerceUnsized` traits](./traits/unsize.md)

src/doc/rustc-dev-guide/src/building/bootstrapping/intro.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ of the same compiler.
66

77
This raises a chicken-and-egg paradox: where did the first compiler come from?
88
It must have been written in a different language. In Rust's case it was
9-
[written in OCaml][ocaml-compiler]. However it was abandoned long ago and the
10-
only way to build a modern version of rustc is a slightly less modern
9+
[written in OCaml][ocaml-compiler]. However, it was abandoned long ago, and the
10+
only way to build a modern version of rustc is with a slightly less modern
1111
version.
1212

1313
This is exactly how `x.py` works: it downloads the current beta release of

src/doc/rustc-dev-guide/src/building/bootstrapping/what-bootstrapping-does.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ the same compiler.
88

99
This raises a chicken-and-egg paradox: where did the first compiler come from?
1010
It must have been written in a different language. In Rust's case it was
11-
[written in OCaml][ocaml-compiler]. However it was abandoned long ago and the
12-
only way to build a modern version of `rustc` is a slightly less modern version.
11+
[written in OCaml][ocaml-compiler]. However, it was abandoned long ago, and the
12+
only way to build a modern version of `rustc` is with a slightly less modern version.
1313

1414
This is exactly how [`./x.py`] works: it downloads the current beta release of
1515
`rustc`, then uses it to compile the new compiler.

src/doc/rustc-dev-guide/src/compiler-src.md

+18-15
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,20 @@ huge. There is also the `rustc` crate which is the actual binary (i.e. the
6262
[`rustc_driver`] crate, which drives the various parts of compilation in other
6363
crates.
6464

65-
The dependency structure of these crates is complex, but roughly it is
65+
The dependency order of these crates is complex, but roughly it is
6666
something like this:
6767

68-
- `rustc` (the binary) calls [`rustc_driver::main`][main].
69-
- [`rustc_driver`] depends on a lot of other crates, but the main one is
70-
[`rustc_interface`].
71-
- [`rustc_interface`] depends on most of the other compiler crates. It
72-
is a fairly generic interface for driving the whole compilation.
73-
- Most of the other `rustc_*` crates depend on [`rustc_middle`],
74-
which defines a lot of central data structures in the compiler.
75-
- [`rustc_middle`] and most of the other crates depend on a
76-
handful of crates representing the early parts of the
77-
compiler (e.g. the parser), fundamental data structures (e.g.
78-
[`Span`]), or error reporting: [`rustc_data_structures`],
79-
[`rustc_span`], [`rustc_errors`], etc.
68+
1. `rustc` (the binary) calls [`rustc_driver::main`][main].
69+
1. [`rustc_driver`] depends on a lot of other crates, but the main one is
70+
[`rustc_interface`].
71+
1. [`rustc_interface`] depends on most of the other compiler crates. It is a
72+
fairly generic interface for driving the whole compilation.
73+
1. Most of the other `rustc_*` crates depend on [`rustc_middle`], which defines
74+
a lot of central data structures in the compiler.
75+
1. [`rustc_middle`] and most of the other crates depend on a handful of crates
76+
representing the early parts of the compiler (e.g. the parser), fundamental
77+
data structures (e.g. [`Span`]), or error reporting:
78+
[`rustc_data_structures`], [`rustc_span`], [`rustc_errors`], etc.
8079

8180
[`rustc_data_structures`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/index.html
8281
[`rustc_driver`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/index.html
@@ -87,8 +86,12 @@ something like this:
8786
[`Span`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/struct.Span.html
8887
[main]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/fn.main.html
8988

90-
You can see the exact dependencies by reading the [`Cargo.toml`] for the various
91-
crates, just like a normal Rust crate.
89+
You can see the exact dependencies by running `cargo tree`,
90+
just like you would for any other Rust package:
91+
92+
```console
93+
cargo tree --package rustc_driver
94+
```
9295

9396
One final thing: [`src/llvm-project`] is a submodule for our fork of LLVM.
9497
During bootstrapping, LLVM is built and the [`compiler/rustc_llvm`] crate

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

+54
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,23 @@ When a user runs `cargo fix --edition`, cargo will pass the `--force-warn rust-2
193193
flag to force all of these lints to appear during the edition migration.
194194
Cargo also passes `--cap-lints=allow` so that no other lints interfere with the edition migration.
195195

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+
196213
Migration lints can be either `Allow` or `Warn` by default.
197214
If it is `Allow`, users usually won't see this warning unless they are doing an edition migration
198215
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
334351
[into-iter]: https://doc.rust-lang.org/nightly/edition-guide/rust-2021/IntoIterator-for-arrays.html
335352
[panic-macro]: https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html
336353
[`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/
372+
373+
## Stabilizing an edition
374+
375+
After the edition team has given the go-ahead, the process for stabilizing an edition is roughly:
376+
377+
- Update [`LATEST_STABLE_EDITION`].
378+
- Update [`Edition::is_stable`].
379+
- Hunt and find any document that refers to edition by number, and update it:
380+
- [`--edition` flag](https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/command-line-arguments.md#--edition-specify-the-edition-to-use)
381+
- [Rustdoc attributes](https://github.com/rust-lang/rust/blob/master/src/doc/rustdoc/src/write-documentation/documentation-tests.md#attributes)
382+
- 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).
387+
388+
[`LATEST_STABLE_EDITION`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/edition/constant.LATEST_STABLE_EDITION.html
389+
[`Edition::is_stable`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/edition/enum.Edition.html#method.is_stable
390+
[#133582]: https://github.com/rust-lang/rust/issues/133582

0 commit comments

Comments
 (0)