Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
7172f7e
Prepare for merging from rust-lang/rust
invalid-email-address Feb 16, 2026
cca0afa
Merge ref '139651428df8' from rust-lang/rust
invalid-email-address Feb 16, 2026
ca4ff29
Merge pull request #2777 from rust-lang/rustc-pull
tshepang Feb 16, 2026
508cadb
Introduce @bors squash command
reddevilmidzy Feb 18, 2026
7b38904
Merge pull request #2779 from reddevilmidzy/squash
reddevilmidzy Feb 18, 2026
3e47b01
rustdoc.md: consistently use `./x` rather than `./x.py`
DanielEScherzer Feb 19, 2026
cd6103b
Merge pull request #2780 from DanielEScherzer/patch-1
jyn514 Feb 20, 2026
f19de24
document 'x' command in nix-dev-shell
BennoLossin Feb 20, 2026
4479ca7
Merge pull request #2781 from BennoLossin/patch-1
Noratrieb Feb 21, 2026
d5065ee
Update feature gating link in overview.md
reddevilmidzy Feb 21, 2026
99619bc
Merge pull request #2782 from rust-lang/feature-gate
reddevilmidzy Feb 21, 2026
1e4faad
Prepare for merging from rust-lang/rust
invalid-email-address Feb 23, 2026
f624779
Merge ref 'c78a29473a68' from rust-lang/rust
invalid-email-address Feb 23, 2026
d1f5c6a
Merge pull request #2783 from rust-lang/rustc-pull
reddevilmidzy Feb 23, 2026
a2bb73c
all but one test suite support revisions directive
tshepang Feb 23, 2026
7ec895b
Merge pull request #2749 from rust-lang/date-check-compiletest
tshepang Feb 23, 2026
1b1fae3
sembr src/overview.md
tshepang Feb 23, 2026
d7b6327
sembr src/rustdoc.md
tshepang Feb 24, 2026
19646b2
sembr src/git.md
tshepang Feb 24, 2026
687193b
sembr src/queries/incremental-compilation-in-detail.md
tshepang Feb 24, 2026
0331958
improve queries/incremental-compilation-in-detail.md
tshepang Feb 24, 2026
470e4d3
sembr src/queries/incremental-compilation-in-detail.md
tshepang Feb 24, 2026
03b95ba
sembr src/diagnostics/translation.md
tshepang Feb 24, 2026
cdfa734
sembr src/diagnostics/translation.md
tshepang Feb 24, 2026
dbbca6f
sembr src/overview.md
tshepang Feb 24, 2026
8c8856f
split that
tshepang Feb 24, 2026
2fe1a3b
sembr src/building/bootstrapping/what-bootstrapping-does.md
tshepang Feb 24, 2026
49e1fb9
improve building/bootstrapping/what-bootstrapping-does.md
tshepang Feb 24, 2026
b4d7d43
sembr src/debugging-support-in-rustc.md
tshepang Feb 24, 2026
7718cb1
improve debugging-support-in-rustc.md
tshepang Feb 24, 2026
c07987c
avoid abbreviation
tshepang Feb 24, 2026
49bd524
reflow
tshepang Feb 24, 2026
80fbb65
sembr src/diagnostics.md
tshepang Feb 24, 2026
bc60e77
improve diagnostics.md
tshepang Feb 24, 2026
7e58a5e
sembr src/macro-expansion.md
tshepang Feb 24, 2026
aa0f49d
whitespace
tshepang Feb 24, 2026
3ff689c
reflow
tshepang Feb 24, 2026
6ccd682
sembr src/notification-groups/about.md
tshepang Feb 24, 2026
2634de2
sembr src/notification-groups/arm.md
tshepang Feb 24, 2026
e8c4627
sembr src/notification-groups/emscripten.md
tshepang Feb 24, 2026
3c9f81a
reflow
tshepang Feb 24, 2026
43dfa86
sembr src/notification-groups/loongarch.md
tshepang Feb 24, 2026
8433606
sembr src/notification-groups/risc-v.md
tshepang Feb 24, 2026
8c3b46d
sembr src/notification-groups/rust-for-linux.md
tshepang Feb 24, 2026
b64c3e8
sembr src/notification-groups/wasi.md
tshepang Feb 24, 2026
c3f9012
sembr src/notification-groups/windows.md
tshepang Feb 24, 2026
03bee83
sembr src/ty.md
tshepang Feb 24, 2026
fb13b33
extraneous word
tshepang Feb 24, 2026
9582575
a more natural flow
tshepang Feb 24, 2026
1a7e191
improve ty.md
tshepang Feb 24, 2026
eeb3c1e
sembr src/diagnostics/diagnostic-structs.md
tshepang Feb 24, 2026
0b3366b
reflow
tshepang Feb 24, 2026
501e5a9
sembr src/const-generics.md
tshepang Feb 24, 2026
e8d886a
improve const-generics.md
tshepang Feb 24, 2026
1576cfc
sembr src/feature-gate-check.md
tshepang Feb 24, 2026
8ab2737
sembr src/feature-gates.md
tshepang Feb 24, 2026
d54444d
sembr src/syntax-intro.md
tshepang Feb 24, 2026
814e93b
sembr src/ty-module/binders.md
tshepang Feb 24, 2026
5c8f707
improve ty-module/binders.md
tshepang Feb 24, 2026
0495449
overlong
tshepang Feb 24, 2026
40eaca2
sembr src/ty-module/binders.md
tshepang Feb 24, 2026
4eaa3d1
split
tshepang Feb 24, 2026
56b7900
sembr src/ty-module/instantiating-binders.md
tshepang Feb 24, 2026
9a19815
improve ty-module/instantiating-binders.md
tshepang Feb 24, 2026
a5655d0
sembr src/ty-module/param-ty-const-regions.md
tshepang Feb 24, 2026
95d13f0
improve ty-module/param-ty-const-regions.md
tshepang Feb 24, 2026
a283471
Merge pull request #2784 from rust-lang/tshepang/sembr
tshepang Feb 24, 2026
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/ci/sembr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ fn lengthen_lines(content: &str, limit: usize) -> String {
if in_html_div {
continue;
}
if line.trim_end().ends_with("<br>") {
continue;
}
if ignore(line, in_code_block) || REGEX_SPLIT.is_match(line) {
continue;
}
Expand Down
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 @@
44e34e1ac6d7e69b40856cf1403d3da145319c30
c78a29473a68f07012904af11c92ecffa68fcc75

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/doc/rustc-dev-guide/src/building/suggested.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ If you're using the flake, make sure to also update it with the following comman
nix flake update --flake ./src/tools/nix-dev-shell
```

The shell creates a command named `x` that runs the `./x.py` script with all dependencies
set up correctly.

### Note

Note that when using nix on a not-NixOS distribution, it may be necessary to set
Expand Down
78 changes: 53 additions & 25 deletions src/doc/rustc-dev-guide/src/const-generics.md

Large diffs are not rendered by default.

156 changes: 91 additions & 65 deletions src/doc/rustc-dev-guide/src/debugging-support-in-rustc.md

Large diffs are not rendered by default.

445 changes: 223 additions & 222 deletions src/doc/rustc-dev-guide/src/diagnostics.md

Large diffs are not rendered by default.

114 changes: 55 additions & 59 deletions src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ rustc has three diagnostic traits that can be used to create diagnostics:

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.
don't require much logic in deciding whether or not to add additional subdiagnostics.

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
Expand All @@ -16,8 +15,7 @@ Diagnostic can be translated into different languages.

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

Consider the [definition][defn] of the "field already declared" diagnostic
shown below:
Consider the [definition][defn] of the "field already declared" diagnostic shown below:

```rust,ignore
#[derive(Diagnostic)]
Expand All @@ -32,47 +30,47 @@ pub struct FieldAlreadyDeclared {
}
```

`Diagnostic` can only be derived on structs and enums.
`Diagnostic` can only be derived on structs and enums.
Attributes that are placed on the type for structs are placed on each
variants for enums (or vice versa). Each `Diagnostic` has to have one
variants for enums (or vice versa).
Each `Diagnostic` has to have one
attribute, `#[diag(...)]`, applied to the struct or each enum variant.

If an error has an error code (e.g. "E0624"), then that can be specified using
the `code` sub-attribute. Specifying a `code` isn't mandatory, but if you are
the `code` sub-attribute.
Specifying a `code` isn't mandatory, but if you are
porting a diagnostic that uses `Diag` to use `Diagnostic`
then you should keep the code if there was one.

`#[diag(..)]` must provide a message as the first positional argument.
The message is written in English, but might be translated to the locale requested by the user. See
[translation documentation](./translation.md) to learn more about how
`#[diag(..)]` must provide a message as the first positional argument.
The message is written in English, but might be translated to the locale requested by the user.
See [translation documentation](./translation.md) to learn more about how
translatable error messages are written and how they are generated.

Every field of the `Diagnostic` which does not have an annotation is
available in Fluent messages as a variable, like `field_name` in the example
above. Fields can be annotated `#[skip_arg]` if this is undesired.
available in Fluent messages as a variable, like `field_name` in the example above.
Fields can be annotated `#[skip_arg]` if this is undesired.

Using the `#[primary_span]` attribute on a field (that has type `Span`)
indicates the primary span of the diagnostic which will have the main message
of the diagnostic.
indicates the primary span of the diagnostic which will have the main message of the diagnostic.

Diagnostics are more than just their primary message, they often include
labels, notes, help messages and suggestions, all of which can also be
specified on a `Diagnostic`.
labels, notes, help messages and suggestions, all of which can also be specified on a `Diagnostic`.

`#[label]`, `#[help]`, `#[warning]` and `#[note]` can all be applied to fields which have the
type `Span`. Applying any of these attributes will create the corresponding
subdiagnostic with that `Span`. These attributes take a diagnostic message as an argument.
type `Span`.
Applying any of these attributes will create the corresponding subdiagnostic with that `Span`.
These attributes take a diagnostic message as an argument.

Other types have special behavior when used in a `Diagnostic` derive:

- Any attribute applied to an `Option<T>` will only emit a
subdiagnostic if the option is `Some(..)`.
- Any attribute applied to a `Vec<T>` will be repeated for each element of the
vector.
- Any attribute applied to a `Vec<T>` will be repeated for each element of the vector.

`#[help]`, `#[warning]` and `#[note]` can also be applied to the struct itself, in which case
they work exactly like when applied to fields except the subdiagnostic won't
have a `Span`. These attributes can also be applied to fields of type `()` for
they work exactly like when applied to fields except the subdiagnostic won't have a `Span`.
These attributes can also be applied to fields of type `()` for
the same effect, which when combined with the `Option` type can be used to
represent optional `#[note]`/`#[help]`/`#[warning]` subdiagnostics.

Expand All @@ -84,8 +82,8 @@ Suggestions can be emitted using one of four field attributes:
- `#[suggestion_verbose("message", code = "...", applicability = "...")]`

Suggestions must be applied on either a `Span` field or a `(Span,
MachineApplicability)` field. Similarly to other field attributes, a message
needs to be provided which will be shown to the user.
MachineApplicability)` field.
Similarly to other field attributes, a message needs to be provided which will be shown to the user.
`code` specifies the code that should be suggested as a
replacement and is a format string (e.g. `{field_name}` would be replaced by
the value of the `field_name` field of the struct).
Expand Down Expand Up @@ -113,8 +111,8 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a> for FieldAlreadyDeclared {
}
```

Now that we've defined our diagnostic, how do we [use it][use]? It's quite
straightforward, just create an instance of the struct and pass it to
Now that we've defined our diagnostic, how do we [use it][use]?
It's quite straightforward, just create an instance of the struct and pass it to
`emit_err` (or `emit_warning`):

```rust,ignore
Expand All @@ -126,8 +124,7 @@ tcx.dcx().emit_err(FieldAlreadyDeclared {
```

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

- `#[diag("message", code = "...")]`
- _Applied to struct or enum variant._
Expand Down Expand Up @@ -164,32 +161,32 @@ following attributes:
- Value is the suggestion message that will be shown to the user.
- See [translation documentation](./translation.md).
- `code = "..."`/`code("...", ...)` (_Mandatory_)
- One or multiple format strings indicating the code to be suggested as a
replacement. Multiple values signify multiple possible replacements.
- One or multiple format strings indicating the code to be suggested as a replacement.
Multiple values signify multiple possible replacements.
- `applicability = "..."` (_Optional_)
- String which must be one of `machine-applicable`, `maybe-incorrect`,
`has-placeholders` or `unspecified`.
- `#[subdiagnostic]`
- _Applied to a type that implements `Subdiagnostic` (from
`#[derive(Subdiagnostic)]`)._
- _Applied to a type that implements `Subdiagnostic` (from `#[derive(Subdiagnostic)]`)._
- Adds the subdiagnostic represented by the subdiagnostic struct.
- `#[primary_span]` (_Optional_)
- _Applied to `Span` fields on `Subdiagnostic`s. Not used for `LintDiagnostic`s._
- _Applied to `Span` fields on `Subdiagnostic`s.
Not used for `LintDiagnostic`s._
- Indicates the primary span of the diagnostic.
- `#[skip_arg]` (_Optional_)
- _Applied to any field._
- Prevents the field from being provided as a diagnostic argument.

## `#[derive(Subdiagnostic)]`
It is common in the compiler to write a function that conditionally adds a
specific subdiagnostic to an error if it is applicable. Oftentimes these
subdiagnostics could be represented using a diagnostic struct even if the
overall diagnostic could not. In this circumstance, the `Subdiagnostic`
specific subdiagnostic to an error if it is applicable.
Oftentimes these subdiagnostics could be represented using a diagnostic struct even if the
overall diagnostic could not.
In this circumstance, the `Subdiagnostic`
derive can be used to represent a partial diagnostic (e.g a note, label, help or
suggestion) as a struct.

Consider the [definition][subdiag_defn] of the "expected return type" label
shown below:
Consider the [definition][subdiag_defn] of the "expected return type" label shown below:

```rust
#[derive(Subdiagnostic)]
Expand All @@ -208,10 +205,10 @@ pub enum ExpectedReturnTypeLabel<'tcx> {
}
```

Like `Diagnostic`, `Subdiagnostic` can be derived for structs or
enums. Attributes that are placed on the type for structs are placed on each
variants for enums (or vice versa). Each `Subdiagnostic` should have one
attribute applied to the struct or each variant, one of:
Like `Diagnostic`, `Subdiagnostic` can be derived for structs or enums.
Attributes that are placed on the type for structs are placed on each
variants for enums (or vice versa).
Each `Subdiagnostic` should have one attribute applied to the struct or each variant, one of:

- `#[label(..)]` for defining a label
- `#[note(..)]` for defining a note
Expand All @@ -224,15 +221,14 @@ See [translation documentation](./translation.md) to learn more about how
translatable error messages are generated.

Using the `#[primary_span]` attribute on a field (with type `Span`) will denote
the primary span of the subdiagnostic. A primary span is only necessary for a
label or suggestion, which can not be spanless.
the primary span of the subdiagnostic.
A primary span is only necessary for a label or suggestion, which can not be spanless.

Every field of the type/variant which does not have an annotation is available
in Fluent messages as a variable. Fields can be annotated `#[skip_arg]` if this
is undesired.
in Fluent messages as a variable.
Fields can be annotated `#[skip_arg]` if this is undesired.

Like `Diagnostic`, `Subdiagnostic` supports `Option<T>` and
`Vec<T>` fields.
Like `Diagnostic`, `Subdiagnostic` supports `Option<T>` and `Vec<T>` fields.

Suggestions can be emitted using one of four attributes on the type/variant:

Expand All @@ -241,8 +237,7 @@ Suggestions can be emitted using one of four attributes on the type/variant:
- `#[suggestion_short("...", code = "...", applicability = "...")]`
- `#[suggestion_verbose("...", code = "...", applicability = "...")]`

Suggestions require `#[primary_span]` be set on a field and can have the
following sub-attributes:
Suggestions require `#[primary_span]` be set on a field and can have the following sub-attributes:

- The first positional argument specifies the message which will be shown to the user.
- `code` specifies the code that should be suggested as a replacement and is a
Expand Down Expand Up @@ -276,8 +271,7 @@ impl<'tcx> Subdiagnostic for ExpectedReturnTypeLabel<'tcx> {

Once defined, a subdiagnostic can be used by passing it to the `subdiagnostic`
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.
diagnostic or by assigning it to a `#[subdiagnostic]`-annotated field of a diagnostic struct.

### Argument sharing and isolation

Expand Down Expand Up @@ -310,22 +304,24 @@ Additionally, subdiagnostics can access arguments from the main diagnostic with
`#[derive(Subdiagnostic)]` supports the following attributes:

- `#[label("message")]`, `#[help("message")]`, `#[warning("message")]` or `#[note("message")]`
- _Applied to struct or enum variant. Mutually exclusive with struct/enum variant attributes._
- _Applied to struct or enum variant.
Mutually exclusive with struct/enum variant attributes._
- _Mandatory_
- Defines the type to be representing a label, help or note.
- Message (_Mandatory_)
- The diagnostic message that will be shown to the user.
- See [translation documentation](./translation.md).
- `#[suggestion{,_hidden,_short,_verbose}("message", code = "...", applicability = "...")]`
- _Applied to struct or enum variant. Mutually exclusive with struct/enum variant attributes._
- _Applied to struct or enum variant.
Mutually exclusive with struct/enum variant attributes._
- _Mandatory_
- Defines the type to be representing a suggestion.
- Message (_Mandatory_)
- The diagnostic message that will be shown to the user.
- See [translation documentation](./translation.md).
- `code = "..."`/`code("...", ...)` (_Mandatory_)
- One or multiple format strings indicating the code to be suggested as a
replacement. Multiple values signify multiple possible replacements.
- One or multiple format strings indicating the code to be suggested as a replacement.
Multiple values signify multiple possible replacements.
- `applicability = "..."` (_Optional_)
- _Mutually exclusive with `#[applicability]` on a field._
- Value is the applicability of the suggestion.
Expand All @@ -335,7 +331,8 @@ Additionally, subdiagnostics can access arguments from the main diagnostic with
- `has-placeholders`
- `unspecified`
- `#[multipart_suggestion{,_hidden,_short,_verbose}("message", applicability = "...")]`
- _Applied to struct or enum variant. Mutually exclusive with struct/enum variant attributes._
- _Applied to struct or enum variant.
Mutually exclusive with struct/enum variant attributes._
- _Mandatory_
- Defines the type to be representing a multipart suggestion.
- Message (_Mandatory_): see `#[suggestion]`
Expand All @@ -348,8 +345,7 @@ to multipart suggestions)
- _Applied to `Span` fields._
- Indicates the span to be one part of the multipart suggestion.
- `code = "..."` (_Mandatory_)
- Value is a format string indicating the code to be suggested as a
replacement.
- Value is a format string indicating the code to be suggested as a replacement.
- `#[applicability]` (_Optional_; only applicable to (simple and multipart) suggestions)
- _Applied to `Applicability` fields._
- Indicates the applicability of the suggestion.
Expand Down
Loading
Loading