Skip to content

rustc-dev-guide subtree update #143420

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

Merged
merged 20 commits into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
10c9537
Preparing for merge from rustc
invalid-email-address Jun 26, 2025
fdf44db
Merge from rustc
invalid-email-address Jun 26, 2025
fe2fd8a
Merge pull request #2479 from rust-lang/rustc-pull
tshepang Jun 26, 2025
005dd43
Add `arguments sharing and isolation` section in `diagnostic-struct` …
xizheyin Jun 26, 2025
e8ff13c
Fix typo
xizheyin Jun 27, 2025
61dafd7
Merge pull request #2480 from xizheyin/argument-sharing-and-isolation
oli-obk Jun 27, 2025
98c3470
Add a link to rust-forge to explain where rdg changes should be submi…
xizheyin Jun 26, 2025
84abd4e
Merge pull request #2481 from xizheyin/submit-in-rdg-or-r
tshepang Jun 28, 2025
e9721a6
Add broken `./x test library/std` advisory
jieyouxu Jun 29, 2025
5628341
Merge pull request #2482 from jieyouxu/download-rustc
Kobzol Jun 29, 2025
787a4cc
build-fail directive: make explanation more uniform
tshepang Jun 30, 2025
390d1be
update AST-to-HIR lowering examples for conditionals and loops
dianne Jun 30, 2025
67e53f2
Merge pull request #2485 from dianne/update-cond-loop-desugaring
Noratrieb Jun 30, 2025
e82121f
Merge pull request #2483 from rust-lang/tshepang-patch-1
jieyouxu Jul 1, 2025
90d54a1
adjust docs, after splitting up autodiff into two forward and reverse…
ZuseZ4 Jul 3, 2025
3fd6613
Merge pull request #2488 from rust-lang/autodiff-doc-updates
ZuseZ4 Jul 3, 2025
9345940
Add josh-sync config file
Kobzol Jul 4, 2025
ac1a8b3
Prepare for merging from rust-lang/rust
Kobzol Jul 4, 2025
c33dd1b
Merge ref 'c96a69059ecc' from rust-lang/rust
Kobzol Jul 4, 2025
ad97597
Merge pull request #2489 from Kobzol/pull
jieyouxu Jul 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/doc/rustc-dev-guide/josh-sync.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org = "rust-lang"
repo = "rustc-dev-guide"
path = "src/doc/rustc-dev-guide"
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide/rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d1d8e386c5e84c4ba857f56c3291f73c27e2d62a
c96a69059ecc618b519da385a6ccd03155aa0237
4 changes: 2 additions & 2 deletions src/doc/rustc-dev-guide/src/autodiff/internals.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ The `std::autodiff` module in Rust allows differentiable programming:

```rust
#![feature(autodiff)]
use std::autodiff::autodiff;
use std::autodiff::*;

// f(x) = x * x, f'(x) = 2.0 * x
// bar therefore returns (x * x, 2.0 * x)
#[autodiff(bar, Reverse, Active, Active)]
#[autodiff_reverse(bar, Active, Active)]
fn foo(x: f32) -> f32 { x * x }

fn main() {
Expand Down
18 changes: 18 additions & 0 deletions src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

<!-- toc -->

<div class="warning">

For `profile = "library"` users, or users who use `download-rustc = true | "if-unchanged"`, please be advised that
the `./x test library/std` flow where `download-rustc` is active (i.e. no compiler changes) is currently broken.
This is tracked in <https://github.com/rust-lang/rust/issues/142505>. Only the `./x test` flow is affected in this
case, `./x {check,build} library/std` should still work.

In the short-term, you may need to disable `download-rustc` for `./x test library/std`. This can be done either by:

1. `./x test library/std --set rust.download-rustc=false`
2. Or set `rust.download-rustc=false` in `bootstrap.toml`.

Unfortunately that will require building the stage 1 compiler. The bootstrap team is working on this, but
implementing a maintainable fix is taking some time.

</div>


The compiler is built using a tool called `x.py`. You will need to
have Python installed to run it.

Expand Down
4 changes: 4 additions & 0 deletions src/doc/rustc-dev-guide/src/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,10 @@ Just a few things to keep in mind:
it might benefit from having a Table of Contents at the beginning,
which you can auto-generate by including the `<!-- toc -->` marker at the top.

#### ⚠️ Note: Where to contribute `rustc-dev-guide` changes

For detailed information about where to contribute rustc-dev-guide changes and the benefits of doing so, see [the rustc-dev-guide working group documentation](https://forge.rust-lang.org/wg-rustc-dev-guide/index.html#where-to-contribute-rustc-dev-guide-changes).

## Issue triage

Please see <https://forge.rust-lang.org/release/issue-triaging.html>.
Expand Down
47 changes: 39 additions & 8 deletions src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Diagnostic and subdiagnostic structs
rustc has three diagnostic traits that can be used to create diagnostics:
`Diagnostic`, `LintDiagnostic`, and `Subdiagnostic`. For simple diagnostics,
instead of using the `Diag` API to create and emit diagnostics,
derived impls can be used. They are only suitable for simple diagnostics that
`Diagnostic`, `LintDiagnostic`, and `Subdiagnostic`.

For simple diagnostics,
derived impls can be used, e.g. `#[derive(Diagnostic)]`. They are only suitable for simple diagnostics that
don't require much logic in deciding whether or not to add additional
subdiagnostics.

Such diagnostic can be translated into
different languages and each has a slug that uniquely identifies the
diagnostic.
In cases where diagnostics require more complex or dynamic behavior, such as conditionally adding subdiagnostics,
customizing the rendering logic, or selecting messages at runtime, you will need to manually implement
the corresponding trait (`Diagnostic`, `LintDiagnostic`, or `Subdiagnostic`).
This approach provides greater flexibility and is recommended for diagnostics that go beyond simple, static structures.

Diagnostic can be translated into different languages and each has a slug that uniquely identifies the diagnostic.

## `#[derive(Diagnostic)]` and `#[derive(LintDiagnostic)]`

Expand Down Expand Up @@ -142,7 +146,7 @@ tcx.dcx().emit_err(FieldAlreadyDeclared {
});
```

### Reference
### Reference for `#[derive(Diagnostic)]` and `#[derive(LintDiagnostic)]`
`#[derive(Diagnostic)]` and `#[derive(LintDiagnostic)]` support the
following attributes:

Expand Down Expand Up @@ -330,7 +334,34 @@ function ([example][subdiag_use_1] and [example][subdiag_use_2]) on a
diagnostic or by assigning it to a `#[subdiagnostic]`-annotated field of a
diagnostic struct.

### Reference
### Argument sharing and isolation

Subdiagnostics add their own arguments (i.e., certain fields in their structure) to the `Diag` structure before rendering the information.
`Diag` structure also stores the arguments from the main diagnostic, so the subdiagnostic can also use the arguments from the main diagnostic.

However, when a subdiagnostic is added to a main diagnostic by implementing `#[derive(Subdiagnostic)]`,
the following rules, introduced in [rust-lang/rust#142724](https://github.com/rust-lang/rust/pull/142724)
apply to the handling of arguments (i.e., variables used in Fluent messages):

**Argument isolation between sub diagnostics**:
Arguments set by a subdiagnostic are only available during the rendering of that subdiagnostic.
After the subdiagnostic is rendered, all arguments it introduced are restored from the main diagnostic.
This ensures that multiple subdiagnostics do not pollute each other's argument scope.
For example, when using a `Vec<Subdiag>`, it iteratively adds the same argument over and over again.

**Same argument override between sub and main diagnostics**:
If a subdiagnostic sets a argument with the same name as a arguments already in the main diagnostic,
it will report an error at runtime unless both have exactly the same value.
It has two benefits:
- preserves the flexibility that arguments in the main diagnostic are allowed to appear in the attributes of the subdiagnostic.
For example, There is an attribute `#[suggestion(code = "{new_vis}")]` in the subdiagnostic, but `new_vis` is the field in the main diagnostic struct.
- prevents accidental overwriting or deletion of arguments required by the main diagnostic or other subdiagnostics.

These rules guarantee that arguments injected by subdiagnostics are strictly scoped to their own rendering.
The main diagnostic's arguments remain unaffected by subdiagnostic logic, even in the presence of name collisions.
Additionally, subdiagnostics can access arguments from the main diagnostic with the same name when needed.

### Reference for `#[derive(Subdiagnostic)]`
`#[derive(Subdiagnostic)]` supports the following attributes:

- `#[label(slug)]`, `#[help(slug)]`, `#[warning(slug)]` or `#[note(slug)]`
Expand Down
6 changes: 2 additions & 4 deletions src/doc/rustc-dev-guide/src/hir/lowering.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ of such structures include but are not limited to

* Parenthesis
* Removed without replacement, the tree structure makes order explicit
* `for` loops and `while (let)` loops
* Converted to `loop` + `match` and some `let` bindings
* `if let`
* Converted to `match`
* `for` loops
* Converted to `match` + `loop` + `match`
* Universal `impl Trait`
* Converted to generic arguments
(but with some flags, to know that the user didn't write them)
Expand Down
6 changes: 3 additions & 3 deletions src/doc/rustc-dev-guide/src/tests/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,9 @@ even run the resulting program. Just add one of the following
- `//@ check-fail` — compilation should fail (the codegen phase is skipped).
This is the default for UI tests.
- `//@ build-fail` — compilation should fail during the codegen phase.
This will run `rustc` twice, once to verify that it compiles successfully
without the codegen phase, then a second time the full compile should
fail.
This will run `rustc` twice:
- First time is to ensure that the compile succeeds without the codegen phase
- Second time is to ensure that the full compile fails
- `//@ run-fail` — compilation should succeed, but running the resulting
binary should fail.

Expand Down
Loading