Auto merge of #102189 - davidtwco:translation-derive-enums, r=compiler-errors

macros: diagnostic derive on enums

Part of #100717.

Extends `#[derive(Diagnostic)]` to work on enums too where each variant acts like a distinct diagnostic - being able to represent diagnostics this way can be quite a bit simpler for some parts of the compiler.

r? `@compiler-errors`
cc `@Xiretza`
This commit is contained in:
bors 2022-09-27 04:39:25 +00:00
commit de0b511daa
6 changed files with 370 additions and 307 deletions

View file

@ -37,10 +37,12 @@ struct HelloWarn {}
#[derive(Diagnostic)]
#[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
//~^ ERROR `#[derive(Diagnostic)]` can only be used on structs
//~^ ERROR unsupported type attribute for diagnostic derive enum
enum DiagnosticOnEnum {
Foo,
//~^ ERROR diagnostic slug not specified
Bar,
//~^ ERROR diagnostic slug not specified
}
#[derive(Diagnostic)]
@ -651,3 +653,21 @@ struct LabelOnStruct {
#[primary_span]
suggestion: Span,
}
#[derive(Diagnostic)]
enum ExampleEnum {
#[diag(typeck::ambiguous_lifetime_bound)]
Foo {
#[primary_span]
sp: Span,
#[note]
note_sp: Span,
},
#[diag(typeck::ambiguous_lifetime_bound)]
Bar {
#[primary_span]
sp: Span,
},
#[diag(typeck::ambiguous_lifetime_bound)]
Baz,
}

View file

@ -1,28 +1,39 @@
error: `#[derive(Diagnostic)]` can only be used on structs
error: unsupported type attribute for diagnostic derive enum
--> $DIR/diagnostic-derive.rs:39:1
|
LL | / #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
LL | |
LL | | enum DiagnosticOnEnum {
LL | | Foo,
LL | | Bar,
LL | | }
| |_^
LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:42:5
|
LL | Foo,
| ^^^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:44:5
|
LL | Bar,
| ^^^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
error: `#[diag = ...]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:48:1
--> $DIR/diagnostic-derive.rs:50:1
|
LL | #[diag = "E0123"]
| ^^^^^^^^^^^^^^^^^
error: `#[nonsense(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:53:1
--> $DIR/diagnostic-derive.rs:55:1
|
LL | #[nonsense(typeck::ambiguous_lifetime_bound, code = "E0123")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:53:1
--> $DIR/diagnostic-derive.rs:55:1
|
LL | / #[nonsense(typeck::ambiguous_lifetime_bound, code = "E0123")]
LL | |
@ -34,7 +45,7 @@ LL | | struct InvalidStructAttr {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
error: `#[diag("...")]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:60:8
--> $DIR/diagnostic-derive.rs:62:8
|
LL | #[diag("E0123")]
| ^^^^^^^
@ -42,7 +53,7 @@ LL | #[diag("E0123")]
= help: a diagnostic slug is required as the first argument
error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:60:1
--> $DIR/diagnostic-derive.rs:62:1
|
LL | / #[diag("E0123")]
LL | |
@ -53,7 +64,7 @@ LL | | struct InvalidLitNestedAttr {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
error: `#[diag(nonsense(...))]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:71:8
--> $DIR/diagnostic-derive.rs:73:8
|
LL | #[diag(nonsense("foo"), code = "E0123", slug = "foo")]
| ^^^^^^^^^^^^^^^
@ -61,7 +72,7 @@ LL | #[diag(nonsense("foo"), code = "E0123", slug = "foo")]
= help: a diagnostic slug is required as the first argument
error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:71:1
--> $DIR/diagnostic-derive.rs:73:1
|
LL | / #[diag(nonsense("foo"), code = "E0123", slug = "foo")]
LL | |
@ -72,7 +83,7 @@ LL | | struct InvalidNestedStructAttr1 {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
error: `#[diag(nonsense = ...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:77:8
--> $DIR/diagnostic-derive.rs:79:8
|
LL | #[diag(nonsense = "...", code = "E0123", slug = "foo")]
| ^^^^^^^^^^^^^^^^
@ -80,7 +91,7 @@ LL | #[diag(nonsense = "...", code = "E0123", slug = "foo")]
= help: only `code` is a valid nested attributes following the slug
error: `#[diag(slug = ...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:77:42
--> $DIR/diagnostic-derive.rs:79:42
|
LL | #[diag(nonsense = "...", code = "E0123", slug = "foo")]
| ^^^^^^^^^^^^
@ -88,7 +99,7 @@ LL | #[diag(nonsense = "...", code = "E0123", slug = "foo")]
= help: only `code` is a valid nested attributes following the slug
error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:77:1
--> $DIR/diagnostic-derive.rs:79:1
|
LL | / #[diag(nonsense = "...", code = "E0123", slug = "foo")]
LL | |
@ -100,13 +111,13 @@ LL | | struct InvalidNestedStructAttr2 {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
error: `#[diag(nonsense = ...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:84:8
--> $DIR/diagnostic-derive.rs:86:8
|
LL | #[diag(nonsense = 4, code = "E0123", slug = "foo")]
| ^^^^^^^^^^^^
error: `#[diag(slug = ...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:84:38
--> $DIR/diagnostic-derive.rs:86:38
|
LL | #[diag(nonsense = 4, code = "E0123", slug = "foo")]
| ^^^^^^^^^^^^
@ -114,7 +125,7 @@ LL | #[diag(nonsense = 4, code = "E0123", slug = "foo")]
= help: only `code` is a valid nested attributes following the slug
error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:84:1
--> $DIR/diagnostic-derive.rs:86:1
|
LL | / #[diag(nonsense = 4, code = "E0123", slug = "foo")]
LL | |
@ -126,7 +137,7 @@ LL | | struct InvalidNestedStructAttr3 {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
error: `#[diag(slug = ...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:91:58
--> $DIR/diagnostic-derive.rs:93:58
|
LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0123", slug = "foo")]
| ^^^^^^^^^^^^
@ -134,49 +145,49 @@ LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0123", slug = "foo")]
= help: only `code` is a valid nested attributes following the slug
error: `#[suggestion = ...]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:98:5
--> $DIR/diagnostic-derive.rs:100:5
|
LL | #[suggestion = "bar"]
| ^^^^^^^^^^^^^^^^^^^^^
error: specified multiple times
--> $DIR/diagnostic-derive.rs:105:8
--> $DIR/diagnostic-derive.rs:107:8
|
LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0456")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:104:8
--> $DIR/diagnostic-derive.rs:106:8
|
LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: specified multiple times
--> $DIR/diagnostic-derive.rs:105:49
--> $DIR/diagnostic-derive.rs:107:49
|
LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0456")]
| ^^^^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:104:49
--> $DIR/diagnostic-derive.rs:106:49
|
LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0123")]
| ^^^^^^^
error: specified multiple times
--> $DIR/diagnostic-derive.rs:111:65
--> $DIR/diagnostic-derive.rs:113:65
|
LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0456", code = "E0457")]
| ^^^^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:111:49
--> $DIR/diagnostic-derive.rs:113:49
|
LL | #[diag(typeck::ambiguous_lifetime_bound, code = "E0456", code = "E0457")]
| ^^^^^^^
error: `#[diag(typeck::ambiguous_lifetime_bound)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:116:42
--> $DIR/diagnostic-derive.rs:118:42
|
LL | #[diag(typeck::ambiguous_lifetime_bound, typeck::ambiguous_lifetime_bound, code = "E0456")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -184,7 +195,7 @@ LL | #[diag(typeck::ambiguous_lifetime_bound, typeck::ambiguous_lifetime_bound,
= help: diagnostic slug must be the first argument
error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:121:1
--> $DIR/diagnostic-derive.rs:123:1
|
LL | struct KindNotProvided {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -192,7 +203,7 @@ LL | struct KindNotProvided {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:124:1
--> $DIR/diagnostic-derive.rs:126:1
|
LL | / #[diag(code = "E0456")]
LL | |
@ -202,31 +213,31 @@ LL | | struct SlugNotProvided {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
error: the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/diagnostic-derive.rs:135:5
--> $DIR/diagnostic-derive.rs:137:5
|
LL | #[primary_span]
| ^^^^^^^^^^^^^^^
error: `#[nonsense]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:143:5
--> $DIR/diagnostic-derive.rs:145:5
|
LL | #[nonsense]
| ^^^^^^^^^^^
error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/diagnostic-derive.rs:160:5
--> $DIR/diagnostic-derive.rs:162:5
|
LL | #[label(typeck::label)]
| ^^^^^^^^^^^^^^^^^^^^^^^
error: `name` doesn't refer to a field on this type
--> $DIR/diagnostic-derive.rs:168:45
--> $DIR/diagnostic-derive.rs:170:45
|
LL | #[suggestion(typeck::suggestion, code = "{name}")]
| ^^^^^^^^
error: invalid format string: expected `'}'` but string was terminated
--> $DIR/diagnostic-derive.rs:173:16
--> $DIR/diagnostic-derive.rs:175:16
|
LL | #[derive(Diagnostic)]
| - ^ expected `'}'` in format string
@ -237,7 +248,7 @@ LL | #[derive(Diagnostic)]
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
error: invalid format string: unmatched `}` found
--> $DIR/diagnostic-derive.rs:183:15
--> $DIR/diagnostic-derive.rs:185:15
|
LL | #[derive(Diagnostic)]
| ^ unmatched `}` in format string
@ -246,19 +257,19 @@ LL | #[derive(Diagnostic)]
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/diagnostic-derive.rs:203:5
--> $DIR/diagnostic-derive.rs:205:5
|
LL | #[label(typeck::label)]
| ^^^^^^^^^^^^^^^^^^^^^^^
error: suggestion without `code = "..."`
--> $DIR/diagnostic-derive.rs:221:5
--> $DIR/diagnostic-derive.rs:223:5
|
LL | #[suggestion(typeck::suggestion)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[suggestion(nonsense = ...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:229:18
--> $DIR/diagnostic-derive.rs:231:18
|
LL | #[suggestion(nonsense = "bar")]
| ^^^^^^^^^^^^^^^^
@ -266,13 +277,13 @@ LL | #[suggestion(nonsense = "bar")]
= help: only `code` and `applicability` are valid nested attributes
error: suggestion without `code = "..."`
--> $DIR/diagnostic-derive.rs:229:5
--> $DIR/diagnostic-derive.rs:231:5
|
LL | #[suggestion(nonsense = "bar")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[suggestion(msg = ...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:238:18
--> $DIR/diagnostic-derive.rs:240:18
|
LL | #[suggestion(msg = "bar")]
| ^^^^^^^^^^^
@ -280,13 +291,13 @@ LL | #[suggestion(msg = "bar")]
= help: only `code` and `applicability` are valid nested attributes
error: suggestion without `code = "..."`
--> $DIR/diagnostic-derive.rs:238:5
--> $DIR/diagnostic-derive.rs:240:5
|
LL | #[suggestion(msg = "bar")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: wrong field type for suggestion
--> $DIR/diagnostic-derive.rs:261:5
--> $DIR/diagnostic-derive.rs:263:5
|
LL | / #[suggestion(typeck::suggestion, code = "This is suggested code")]
LL | |
@ -296,55 +307,55 @@ LL | | suggestion: Applicability,
= help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)`
error: specified multiple times
--> $DIR/diagnostic-derive.rs:277:24
--> $DIR/diagnostic-derive.rs:279:24
|
LL | suggestion: (Span, Span, Applicability),
| ^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:277:18
--> $DIR/diagnostic-derive.rs:279:18
|
LL | suggestion: (Span, Span, Applicability),
| ^^^^
error: specified multiple times
--> $DIR/diagnostic-derive.rs:285:33
--> $DIR/diagnostic-derive.rs:287:33
|
LL | suggestion: (Applicability, Applicability, Span),
| ^^^^^^^^^^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:285:18
--> $DIR/diagnostic-derive.rs:287:18
|
LL | suggestion: (Applicability, Applicability, Span),
| ^^^^^^^^^^^^^
error: `#[label = ...]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:292:5
--> $DIR/diagnostic-derive.rs:294:5
|
LL | #[label = "bar"]
| ^^^^^^^^^^^^^^^^
error: specified multiple times
--> $DIR/diagnostic-derive.rs:443:52
--> $DIR/diagnostic-derive.rs:445:52
|
LL | #[suggestion(typeck::suggestion, code = "...", applicability = "maybe-incorrect")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:445:24
--> $DIR/diagnostic-derive.rs:447:24
|
LL | suggestion: (Span, Applicability),
| ^^^^^^^^^^^^^
error: invalid applicability
--> $DIR/diagnostic-derive.rs:451:52
--> $DIR/diagnostic-derive.rs:453:52
|
LL | #[suggestion(typeck::suggestion, code = "...", applicability = "batman")]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[label(foo)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:514:28
--> $DIR/diagnostic-derive.rs:516:28
|
LL | #[label(typeck::label, foo)]
| ^^^
@ -352,19 +363,19 @@ LL | #[label(typeck::label, foo)]
= help: a diagnostic slug must be the first argument to the attribute
error: `#[label(foo = ...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:522:28
--> $DIR/diagnostic-derive.rs:524:28
|
LL | #[label(typeck::label, foo = "...")]
| ^^^^^^^^^^^
error: `#[label(foo(...))]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:530:28
--> $DIR/diagnostic-derive.rs:532:28
|
LL | #[label(typeck::label, foo("..."))]
| ^^^^^^^^^^
error: `#[primary_span]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:543:5
--> $DIR/diagnostic-derive.rs:545:5
|
LL | #[primary_span]
| ^^^^^^^^^^^^^^^
@ -372,13 +383,13 @@ LL | #[primary_span]
= help: the `primary_span` field attribute is not valid for lint diagnostics
error: `#[error(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:563:1
--> $DIR/diagnostic-derive.rs:565:1
|
LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0123")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:563:1
--> $DIR/diagnostic-derive.rs:565:1
|
LL | / #[error(typeck::ambiguous_lifetime_bound, code = "E0123")]
LL | |
@ -390,13 +401,13 @@ LL | | struct ErrorAttribute {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
error: `#[warn_(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:570:1
--> $DIR/diagnostic-derive.rs:572:1
|
LL | #[warn_(typeck::ambiguous_lifetime_bound, code = "E0123")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:570:1
--> $DIR/diagnostic-derive.rs:572:1
|
LL | / #[warn_(typeck::ambiguous_lifetime_bound, code = "E0123")]
LL | |
@ -408,13 +419,13 @@ LL | | struct WarnAttribute {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
error: `#[lint(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:577:1
--> $DIR/diagnostic-derive.rs:579:1
|
LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:577:1
--> $DIR/diagnostic-derive.rs:579:1
|
LL | / #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
LL | |
@ -426,13 +437,13 @@ LL | | struct LintAttributeOnSessionDiag {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(typeck::example_error)]`
error: `#[lint(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:584:1
--> $DIR/diagnostic-derive.rs:586:1
|
LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:584:1
--> $DIR/diagnostic-derive.rs:586:1
|
LL | / #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
LL | |
@ -444,19 +455,19 @@ LL | | struct LintAttributeOnLintDiag {}
= help: specify the slug as the first argument to the attribute, such as `#[diag(typeck::example_error)]`
error: specified multiple times
--> $DIR/diagnostic-derive.rs:593:52
--> $DIR/diagnostic-derive.rs:595:52
|
LL | #[suggestion(typeck::suggestion, code = "...", code = ",,,")]
| ^^^^^^^^^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:593:38
--> $DIR/diagnostic-derive.rs:595:38
|
LL | #[suggestion(typeck::suggestion, code = "...", code = ",,,")]
| ^^^^^^^^^^^^
error: wrong types for suggestion
--> $DIR/diagnostic-derive.rs:602:24
--> $DIR/diagnostic-derive.rs:604:24
|
LL | suggestion: (Span, usize),
| ^^^^^
@ -464,7 +475,7 @@ LL | suggestion: (Span, usize),
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
error: wrong types for suggestion
--> $DIR/diagnostic-derive.rs:610:17
--> $DIR/diagnostic-derive.rs:612:17
|
LL | suggestion: (Span,),
| ^^^^^^^
@ -472,13 +483,13 @@ LL | suggestion: (Span,),
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
error: suggestion without `code = "..."`
--> $DIR/diagnostic-derive.rs:617:5
--> $DIR/diagnostic-derive.rs:619:5
|
LL | #[suggestion(typeck::suggestion)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:624:1
--> $DIR/diagnostic-derive.rs:626:1
|
LL | #[multipart_suggestion(typeck::suggestion)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -486,7 +497,7 @@ LL | #[multipart_suggestion(typeck::suggestion)]
= help: consider creating a `Subdiagnostic` instead
error: `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:627:1
--> $DIR/diagnostic-derive.rs:629:1
|
LL | #[multipart_suggestion()]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -494,7 +505,7 @@ LL | #[multipart_suggestion()]
= help: consider creating a `Subdiagnostic` instead
error: `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:631:5
--> $DIR/diagnostic-derive.rs:633:5
|
LL | #[multipart_suggestion(typeck::suggestion)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -502,7 +513,7 @@ LL | #[multipart_suggestion(typeck::suggestion)]
= help: consider creating a `Subdiagnostic` instead
error: `#[suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:639:1
--> $DIR/diagnostic-derive.rs:641:1
|
LL | #[suggestion(typeck::suggestion, code = "...")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -510,7 +521,7 @@ LL | #[suggestion(typeck::suggestion, code = "...")]
= help: `#[label]` and `#[suggestion]` can only be applied to fields
error: `#[label]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:648:1
--> $DIR/diagnostic-derive.rs:650:1
|
LL | #[label]
| ^^^^^^^^
@ -518,67 +529,67 @@ LL | #[label]
= help: `#[label]` and `#[suggestion]` can only be applied to fields
error: cannot find attribute `nonsense` in this scope
--> $DIR/diagnostic-derive.rs:53:3
--> $DIR/diagnostic-derive.rs:55:3
|
LL | #[nonsense(typeck::ambiguous_lifetime_bound, code = "E0123")]
| ^^^^^^^^
error: cannot find attribute `nonsense` in this scope
--> $DIR/diagnostic-derive.rs:143:7
--> $DIR/diagnostic-derive.rs:145:7
|
LL | #[nonsense]
| ^^^^^^^^
error: cannot find attribute `error` in this scope
--> $DIR/diagnostic-derive.rs:563:3
--> $DIR/diagnostic-derive.rs:565:3
|
LL | #[error(typeck::ambiguous_lifetime_bound, code = "E0123")]
| ^^^^^
error: cannot find attribute `warn_` in this scope
--> $DIR/diagnostic-derive.rs:570:3
--> $DIR/diagnostic-derive.rs:572:3
|
LL | #[warn_(typeck::ambiguous_lifetime_bound, code = "E0123")]
| ^^^^^ help: a built-in attribute with a similar name exists: `warn`
error: cannot find attribute `lint` in this scope
--> $DIR/diagnostic-derive.rs:577:3
--> $DIR/diagnostic-derive.rs:579:3
|
LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
| ^^^^ help: a built-in attribute with a similar name exists: `link`
error: cannot find attribute `lint` in this scope
--> $DIR/diagnostic-derive.rs:584:3
--> $DIR/diagnostic-derive.rs:586:3
|
LL | #[lint(typeck::ambiguous_lifetime_bound, code = "E0123")]
| ^^^^ help: a built-in attribute with a similar name exists: `link`
error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive.rs:624:3
--> $DIR/diagnostic-derive.rs:626:3
|
LL | #[multipart_suggestion(typeck::suggestion)]
| ^^^^^^^^^^^^^^^^^^^^
error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive.rs:627:3
--> $DIR/diagnostic-derive.rs:629:3
|
LL | #[multipart_suggestion()]
| ^^^^^^^^^^^^^^^^^^^^
error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive.rs:631:7
--> $DIR/diagnostic-derive.rs:633:7
|
LL | #[multipart_suggestion(typeck::suggestion)]
| ^^^^^^^^^^^^^^^^^^^^
error[E0425]: cannot find value `nonsense` in module `rustc_errors::fluent`
--> $DIR/diagnostic-derive.rs:66:8
--> $DIR/diagnostic-derive.rs:68:8
|
LL | #[diag(nonsense, code = "E0123")]
| ^^^^^^^^ not found in `rustc_errors::fluent`
error[E0277]: the trait bound `Hello: IntoDiagnosticArg` is not satisfied
--> $DIR/diagnostic-derive.rs:336:10
--> $DIR/diagnostic-derive.rs:338:10
|
LL | #[derive(Diagnostic)]
| ^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello`
@ -591,7 +602,7 @@ LL | arg: impl IntoDiagnosticArg,
| ^^^^^^^^^^^^^^^^^ required by this bound in `DiagnosticBuilder::<'a, G>::set_arg`
= note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 72 previous errors
error: aborting due to 74 previous errors
Some errors have detailed explanations: E0277, E0425.
For more information about an error, try `rustc --explain E0277`.