|
1 | 1 | # Diagnostic and subdiagnostic structs |
2 | | -rustc has three diagnostic traits that can be used to create diagnostics: |
3 | | -`Diagnostic`, `LintDiagnostic`, and `Subdiagnostic`. |
| 2 | +rustc has two diagnostic traits that can be used to create diagnostics: |
| 3 | +`Diagnostic` and `Subdiagnostic`. |
4 | 4 |
|
5 | 5 | For simple diagnostics, |
6 | 6 | derived impls can be used, e.g. `#[derive(Diagnostic)]`. They are only suitable for simple diagnostics that |
7 | 7 | don't require much logic in deciding whether or not to add additional subdiagnostics. |
8 | 8 |
|
9 | 9 | In cases where diagnostics require more complex or dynamic behavior, such as conditionally adding subdiagnostics, |
10 | 10 | customizing the rendering logic, or selecting messages at runtime, you will need to manually implement |
11 | | -the corresponding trait (`Diagnostic`, `LintDiagnostic`, or `Subdiagnostic`). |
| 11 | +the corresponding trait (`Diagnostic` or `Subdiagnostic`). |
12 | 12 | This approach provides greater flexibility and is recommended for diagnostics that go beyond simple, static structures. |
13 | 13 |
|
14 | 14 | Diagnostic can be translated into different languages. |
15 | 15 |
|
16 | | -## `#[derive(Diagnostic)]` and `#[derive(LintDiagnostic)]` |
| 16 | +## `#[derive(Diagnostic)]` |
17 | 17 |
|
18 | 18 | Consider the [definition][defn] of the "field already declared" diagnostic shown below: |
19 | 19 |
|
@@ -123,8 +123,8 @@ tcx.dcx().emit_err(FieldAlreadyDeclared { |
123 | 123 | }); |
124 | 124 | ``` |
125 | 125 |
|
126 | | -### Reference for `#[derive(Diagnostic)]` and `#[derive(LintDiagnostic)]` |
127 | | -`#[derive(Diagnostic)]` and `#[derive(LintDiagnostic)]` support the following attributes: |
| 126 | +### Reference for `#[derive(Diagnostic)]` |
| 127 | +`#[derive(Diagnostic)]` supports the following attributes: |
128 | 128 |
|
129 | 129 | - `#[diag("message", code = "...")]` |
130 | 130 | - _Applied to struct or enum variant._ |
@@ -171,7 +171,6 @@ tcx.dcx().emit_err(FieldAlreadyDeclared { |
171 | 171 | - Adds the subdiagnostic represented by the subdiagnostic struct. |
172 | 172 | - `#[primary_span]` (_Optional_) |
173 | 173 | - _Applied to `Span` fields on `Subdiagnostic`s. |
174 | | - Not used for `LintDiagnostic`s._ |
175 | 174 | - Indicates the primary span of the diagnostic. |
176 | 175 | - `#[skip_arg]` (_Optional_) |
177 | 176 | - _Applied to any field._ |
|
0 commit comments