From 10c95375569c7ca90ddc5e0741fbed4498e02167 Mon Sep 17 00:00:00 2001 From: The rustc-dev-guide Cronjob Bot Date: Thu, 26 Jun 2025 04:07:24 +0000 Subject: Preparing for merge from rustc --- src/doc/rustc-dev-guide/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/rust-version b/src/doc/rustc-dev-guide/rust-version index 30ba3070e1f..c986141b654 100644 --- a/src/doc/rustc-dev-guide/rust-version +++ b/src/doc/rustc-dev-guide/rust-version @@ -1 +1 @@ -d1d8e386c5e84c4ba857f56c3291f73c27e2d62a +bc4376fa73b636eb6f2c7d48b1f731d70f022c4b -- cgit 1.4.1-3-g733a5 From 005dd432ed4e6f19a3508908e440f18cb19c4047 Mon Sep 17 00:00:00 2001 From: xizheyin Date: Thu, 26 Jun 2025 22:32:39 +0800 Subject: Add `arguments sharing and isolation` section in `diagnostic-struct` of rdg Signed-off-by: xizheyin --- .../src/diagnostics/diagnostic-structs.md | 47 ++++++++++++++++++---- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md b/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md index e01b8f2f135..ea6cdf024e1 100644 --- a/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md +++ b/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md @@ -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)]` @@ -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: @@ -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 will add their own arguments, +i.e. some fields in their struct, into the subdiagnostic when rendering the message, +so that the parameters in the main diagnostic can be used. +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 restore from the main diagnostic. +This ensures that multiple subdiagnostics do not pollute each other's argument scope. +For example, when using a `Vec`, it iteratively add the same arg over and over again. + +**Same argument override between sub and main diagnostics**: +If a subdiagnostic sets a argument with the same name as a arg already in the master diagnostic, +it will report an error at runtime unless both have exactly the same value. +This +- preserves the flexibility that can that *arguments is allowed to appear in the attributes of the subdiagnostic. +For example, There is a attribute `#[suggestion(code = "{new_vis}")]` in sub-diagnostic, but `new_vis` is the field in main diagnostic struct. +- prevents accidental overwriting or deletion of parameters required by the main diagnostic or other sub-diagnostics. + +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 parameters 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)]` -- cgit 1.4.1-3-g733a5 From e8ff13cd3306c1b234e322e6d4e40fa002d6abff Mon Sep 17 00:00:00 2001 From: xizheyin Date: Fri, 27 Jun 2025 17:44:15 +0800 Subject: Fix typo Signed-off-by: xizheyin --- .../src/diagnostics/diagnostic-structs.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md b/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md index ea6cdf024e1..4e5c3413cb8 100644 --- a/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md +++ b/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md @@ -336,30 +336,30 @@ diagnostic struct. ### Argument sharing and isolation -Subdiagnostics will add their own arguments, -i.e. some fields in their struct, into the subdiagnostic when rendering the message, -so that the parameters in the main diagnostic can be used. +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 restore from the main diagnostic. +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`, it iteratively add the same arg over and over again. +For example, when using a `Vec`, 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 arg already in the master diagnostic, +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. -This -- preserves the flexibility that can that *arguments is allowed to appear in the attributes of the subdiagnostic. -For example, There is a attribute `#[suggestion(code = "{new_vis}")]` in sub-diagnostic, but `new_vis` is the field in main diagnostic struct. -- prevents accidental overwriting or deletion of parameters required by the main diagnostic or other sub-diagnostics. +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 parameters from the main diagnostic with the same name when needed. +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: -- cgit 1.4.1-3-g733a5 From 98c347049ec4d0d942740ddf462cc9c1bb64fd96 Mon Sep 17 00:00:00 2001 From: xizheyin Date: Thu, 26 Jun 2025 22:50:31 +0800 Subject: Add a link to rust-forge to explain where rdg changes should be submitted Signed-off-by: xizheyin --- src/doc/rustc-dev-guide/src/contributing.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/doc/rustc-dev-guide/src/contributing.md b/src/doc/rustc-dev-guide/src/contributing.md index 46d74b96734..b3fcd79ec81 100644 --- a/src/doc/rustc-dev-guide/src/contributing.md +++ b/src/doc/rustc-dev-guide/src/contributing.md @@ -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 `` 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 . -- cgit 1.4.1-3-g733a5 From e9721a69a7c39904d27d1d96f575eeb9c0f37fe3 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Sun, 29 Jun 2025 11:23:19 +0800 Subject: Add broken `./x test library/std` advisory --- .../src/building/how-to-build-and-run.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md b/src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md index c4783002b85..d29cd144810 100644 --- a/src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md +++ b/src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md @@ -2,6 +2,24 @@ +
+ +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 . 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. + +
+ + The compiler is built using a tool called `x.py`. You will need to have Python installed to run it. -- cgit 1.4.1-3-g733a5 From 787a4cc90f540b979f31f3f24e103f35295bf036 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Mon, 30 Jun 2025 06:15:08 +0200 Subject: build-fail directive: make explanation more uniform The last part of the paragraph did not fit --- src/doc/rustc-dev-guide/src/tests/ui.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/tests/ui.md b/src/doc/rustc-dev-guide/src/tests/ui.md index 09dc476d68e..65bd89bafe6 100644 --- a/src/doc/rustc-dev-guide/src/tests/ui.md +++ b/src/doc/rustc-dev-guide/src/tests/ui.md @@ -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. -- cgit 1.4.1-3-g733a5 From 390d1be1c7eb500672f9c982e7de13ed27506aea Mon Sep 17 00:00:00 2001 From: dianne Date: Sun, 29 Jun 2025 21:24:25 -0700 Subject: update AST-to-HIR lowering examples for conditionals and loops - `for` loops now use two `match`es for all of their bindings. I'm not sure this is the most helpful way of conveying that, but it's about as informative as before while staying brief. - `while let` and `if let` don't use `match`; they use `let` expressions in their conditions. Since `if let` no longer has significantly different desugaring and having a whole bullet point for `while` would feel redundant with `for`, I've removed those examples. --- src/doc/rustc-dev-guide/src/hir/lowering.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/hir/lowering.md b/src/doc/rustc-dev-guide/src/hir/lowering.md index 02c69b8609f..c0057a69c10 100644 --- a/src/doc/rustc-dev-guide/src/hir/lowering.md +++ b/src/doc/rustc-dev-guide/src/hir/lowering.md @@ -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) -- cgit 1.4.1-3-g733a5 From 90d54a1276e2061a3bbd547e0d422cf849a0511b Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Thu, 3 Jul 2025 15:30:30 -0700 Subject: adjust docs, after splitting up autodiff into two forward and reverse macros --- src/doc/rustc-dev-guide/src/autodiff/internals.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc-dev-guide/src/autodiff/internals.md b/src/doc/rustc-dev-guide/src/autodiff/internals.md index 0093ef044c8..c1b31a0e4bd 100644 --- a/src/doc/rustc-dev-guide/src/autodiff/internals.md +++ b/src/doc/rustc-dev-guide/src/autodiff/internals.md @@ -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() { -- cgit 1.4.1-3-g733a5 From 9345940c12315c69fb9f4f10cdb463aca581a7ec Mon Sep 17 00:00:00 2001 From: Jakub Beránek Date: Fri, 4 Jul 2025 10:37:42 +0200 Subject: Add josh-sync config file --- src/doc/rustc-dev-guide/josh-sync.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/doc/rustc-dev-guide/josh-sync.toml diff --git a/src/doc/rustc-dev-guide/josh-sync.toml b/src/doc/rustc-dev-guide/josh-sync.toml new file mode 100644 index 00000000000..7882051e233 --- /dev/null +++ b/src/doc/rustc-dev-guide/josh-sync.toml @@ -0,0 +1,3 @@ +org = "rust-lang" +repo = "rustc-dev-guide" +path = "src/doc/rustc-dev-guide" -- cgit 1.4.1-3-g733a5 From ac1a8b398b8c0f33e982ba736d31492d911c3050 Mon Sep 17 00:00:00 2001 From: Jakub Beránek Date: Fri, 4 Jul 2025 11:07:45 +0200 Subject: Prepare for merging from rust-lang/rust This updates the rust-version file to c96a69059ecc618b519da385a6ccd03155aa0237. --- src/doc/rustc-dev-guide/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc-dev-guide/rust-version b/src/doc/rustc-dev-guide/rust-version index c986141b654..e444613e631 100644 --- a/src/doc/rustc-dev-guide/rust-version +++ b/src/doc/rustc-dev-guide/rust-version @@ -1 +1 @@ -bc4376fa73b636eb6f2c7d48b1f731d70f022c4b +c96a69059ecc618b519da385a6ccd03155aa0237 -- cgit 1.4.1-3-g733a5