Convert parse_nested_meta to parse_args_with for #[diagnostic]

This commit is contained in:
Jonathan Brouwer
2026-01-28 08:59:16 +01:00
parent 4a0c044c63
commit 9e61014a8a
3 changed files with 124 additions and 154 deletions
@@ -2,6 +2,7 @@
use proc_macro2::{Ident, Span, TokenStream};
use quote::{format_ident, quote, quote_spanned};
use syn::parse::ParseStream;
use syn::spanned::Spanned;
use syn::{Attribute, Meta, Path, Token, Type, parse_quote};
use synstructure::{BindingInfo, Structure, VariantInfo};
@@ -42,7 +43,7 @@ pub(crate) struct DiagnosticDeriveVariantBuilder {
/// Slug is a mandatory part of the struct attribute as corresponds to the Fluent message that
/// has the actual diagnostic message.
pub slug: SpannedOption<Path>,
pub slug: Option<Path>,
/// Error codes are a optional part of the struct attribute - this is only set to detect
/// multiple specifications.
@@ -111,7 +112,7 @@ pub(crate) fn each_variant<'s, F>(self, structure: &mut Structure<'s>, f: F) ->
impl DiagnosticDeriveVariantBuilder {
pub(crate) fn primary_message(&self) -> Option<&Path> {
match self.slug.value_ref() {
match self.slug.as_ref() {
None => {
span_err(self.span, "diagnostic slug not specified")
.help(
@@ -209,47 +210,54 @@ fn generate_structure_code_for_attr(
let name = attr.path().segments.last().unwrap().ident.to_string();
let name = name.as_str();
let mut first = true;
if name == "diag" {
let mut tokens = TokenStream::new();
attr.parse_nested_meta(|nested| {
let path = &nested.path;
attr.parse_args_with(|input: ParseStream<'_>| {
let mut input = &*input;
let slug_recovery_point = input.fork();
if first && (nested.input.is_empty() || nested.input.peek(Token![,])) {
self.slug.set_once(path.clone(), path.span().unwrap());
first = false;
return Ok(());
let slug = input.parse::<Path>()?;
if input.is_empty() || input.peek(Token![,]) {
self.slug = Some(slug);
} else {
input = &slug_recovery_point;
}
first = false;
let Ok(nested) = nested.value() else {
span_err(
nested.input.span().unwrap(),
"diagnostic slug must be the first argument",
)
.emit();
return Ok(());
};
if path.is_ident("code") {
self.code.set_once((), path.span().unwrap());
let code = nested.parse::<syn::Expr>()?;
tokens.extend(quote! {
diag.code(#code);
});
} else {
span_err(path.span().unwrap(), "unknown argument")
.note("only the `code` parameter is valid after the slug")
while !input.is_empty() {
input.parse::<Token![,]>()?;
// Allow trailing comma
if input.is_empty() {
break;
}
let arg_name: Path = input.parse::<Path>()?;
if input.peek(Token![,]) {
span_err(
arg_name.span().unwrap(),
"diagnostic slug must be the first argument",
)
.emit();
// consume the buffer so we don't have syntax errors from syn
let _ = nested.parse::<TokenStream>();
continue;
}
let arg_name = arg_name.require_ident()?;
input.parse::<Token![=]>()?;
let arg_value = input.parse::<syn::Expr>()?;
match arg_name.to_string().as_str() {
"code" => {
self.code.set_once((), arg_name.span().unwrap());
tokens.extend(quote! {
diag.code(#arg_value);
});
}
_ => {
span_err(arg_name.span().unwrap(), "unknown argument")
.note("only the `code` parameter is valid after the slug")
.emit();
}
}
}
Ok(())
})?;
return Ok(tokens);
}
@@ -80,20 +80,17 @@ struct InvalidNestedStructAttr {}
#[derive(Diagnostic)]
#[diag(nonsense("foo"), code = E0123, slug = "foo")]
//~^ ERROR diagnostic slug must be the first argument
//~| ERROR diagnostic slug not specified
//~^ ERROR derive(Diagnostic): diagnostic slug not specified
struct InvalidNestedStructAttr1 {}
#[derive(Diagnostic)]
#[diag(nonsense = "...", code = E0123, slug = "foo")]
//~^ ERROR unknown argument
//~| ERROR diagnostic slug not specified
//~^ ERROR diagnostic slug not specified
struct InvalidNestedStructAttr2 {}
#[derive(Diagnostic)]
#[diag(nonsense = 4, code = E0123, slug = "foo")]
//~^ ERROR unknown argument
//~| ERROR diagnostic slug not specified
//~^ ERROR diagnostic slug not specified
struct InvalidNestedStructAttr3 {}
#[derive(Diagnostic)]
@@ -113,7 +110,6 @@ struct WrongPlaceField {
#[diag(no_crate_example, code = E0123)]
#[diag(no_crate_example, code = E0456)]
//~^ ERROR specified multiple times
//~^^ ERROR specified multiple times
struct DiagSpecifiedTwice {}
#[derive(Diagnostic)]
@@ -48,12 +48,6 @@ LL | #[diag(code = E0123)]
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug must be the first argument
--> $DIR/diagnostic-derive.rs:82:16
|
LL | #[diag(nonsense("foo"), code = E0123, slug = "foo")]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:82:1
|
@@ -62,32 +56,16 @@ LL | #[diag(nonsense("foo"), code = E0123, slug = "foo")]
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): unknown argument
--> $DIR/diagnostic-derive.rs:88:8
|
LL | #[diag(nonsense = "...", code = E0123, slug = "foo")]
| ^^^^^^^^
|
= note: only the `code` parameter is valid after the slug
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:88:1
--> $DIR/diagnostic-derive.rs:87:1
|
LL | #[diag(nonsense = "...", code = E0123, slug = "foo")]
| ^
|
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): unknown argument
--> $DIR/diagnostic-derive.rs:94:8
|
LL | #[diag(nonsense = 4, code = E0123, slug = "foo")]
| ^^^^^^^^
|
= note: only the `code` parameter is valid after the slug
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:94:1
--> $DIR/diagnostic-derive.rs:92:1
|
LL | #[diag(nonsense = 4, code = E0123, slug = "foo")]
| ^
@@ -95,7 +73,7 @@ LL | #[diag(nonsense = 4, code = E0123, slug = "foo")]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): unknown argument
--> $DIR/diagnostic-derive.rs:100:40
--> $DIR/diagnostic-derive.rs:97:40
|
LL | #[diag(no_crate_example, code = E0123, slug = "foo")]
| ^^^^
@@ -103,55 +81,43 @@ LL | #[diag(no_crate_example, code = E0123, slug = "foo")]
= note: only the `code` parameter is valid after the slug
error: derive(Diagnostic): `#[suggestion = ...]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:107:5
--> $DIR/diagnostic-derive.rs:104:5
|
LL | #[suggestion = "bar"]
| ^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive.rs:114:8
|
LL | #[diag(no_crate_example, code = E0456)]
| ^^^^^^^^^^^^^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:113:8
|
LL | #[diag(no_crate_example, code = E0123)]
| ^^^^^^^^^^^^^^^^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive.rs:114:26
--> $DIR/diagnostic-derive.rs:111:26
|
LL | #[diag(no_crate_example, code = E0456)]
| ^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:113:26
--> $DIR/diagnostic-derive.rs:110:26
|
LL | #[diag(no_crate_example, code = E0123)]
| ^^^^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive.rs:120:40
--> $DIR/diagnostic-derive.rs:116:40
|
LL | #[diag(no_crate_example, code = E0123, code = E0456)]
| ^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:120:26
--> $DIR/diagnostic-derive.rs:116:26
|
LL | #[diag(no_crate_example, code = E0123, code = E0456)]
| ^^^^
error: derive(Diagnostic): diagnostic slug must be the first argument
--> $DIR/diagnostic-derive.rs:125:43
--> $DIR/diagnostic-derive.rs:121:26
|
LL | #[diag(no_crate_example, no_crate::example, code = E0123)]
| ^
| ^^^^^^^^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:130:1
--> $DIR/diagnostic-derive.rs:126:1
|
LL | struct KindNotProvided {}
| ^^^^^^
@@ -159,7 +125,7 @@ LL | struct KindNotProvided {}
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:133:1
--> $DIR/diagnostic-derive.rs:129:1
|
LL | #[diag(code = E0123)]
| ^
@@ -167,31 +133,31 @@ LL | #[diag(code = E0123)]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/diagnostic-derive.rs:144:5
--> $DIR/diagnostic-derive.rs:140:5
|
LL | #[primary_span]
| ^
error: derive(Diagnostic): `#[nonsense]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:152:5
--> $DIR/diagnostic-derive.rs:148:5
|
LL | #[nonsense]
| ^
error: derive(Diagnostic): the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/diagnostic-derive.rs:169:5
--> $DIR/diagnostic-derive.rs:165:5
|
LL | #[label(no_crate_label)]
| ^
error: derive(Diagnostic): `name` doesn't refer to a field on this type
--> $DIR/diagnostic-derive.rs:177:46
--> $DIR/diagnostic-derive.rs:173:46
|
LL | #[suggestion(no_crate_suggestion, code = "{name}")]
| ^^^^^^^^
error: invalid format string: expected `}` but string was terminated
--> $DIR/diagnostic-derive.rs:182:10
--> $DIR/diagnostic-derive.rs:178:10
|
LL | #[derive(Diagnostic)]
| ^^^^^^^^^^ expected `}` in format string
@@ -200,7 +166,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:192:10
--> $DIR/diagnostic-derive.rs:188:10
|
LL | #[derive(Diagnostic)]
| ^^^^^^^^^^ unmatched `}` in format string
@@ -209,19 +175,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: derive(Diagnostic): the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
--> $DIR/diagnostic-derive.rs:212:5
--> $DIR/diagnostic-derive.rs:208:5
|
LL | #[label(no_crate_label)]
| ^
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/diagnostic-derive.rs:231:5
--> $DIR/diagnostic-derive.rs:227:5
|
LL | #[suggestion(no_crate_suggestion)]
| ^
error: derive(Diagnostic): invalid nested attribute
--> $DIR/diagnostic-derive.rs:239:18
--> $DIR/diagnostic-derive.rs:235:18
|
LL | #[suggestion(nonsense = "bar")]
| ^^^^^^^^
@@ -229,13 +195,13 @@ LL | #[suggestion(nonsense = "bar")]
= help: only `no_span`, `style`, `code` and `applicability` are valid nested attributes
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/diagnostic-derive.rs:239:5
--> $DIR/diagnostic-derive.rs:235:5
|
LL | #[suggestion(nonsense = "bar")]
| ^
error: derive(Diagnostic): invalid nested attribute
--> $DIR/diagnostic-derive.rs:248:18
--> $DIR/diagnostic-derive.rs:244:18
|
LL | #[suggestion(msg = "bar")]
| ^^^
@@ -243,13 +209,13 @@ LL | #[suggestion(msg = "bar")]
= help: only `no_span`, `style`, `code` and `applicability` are valid nested attributes
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/diagnostic-derive.rs:248:5
--> $DIR/diagnostic-derive.rs:244:5
|
LL | #[suggestion(msg = "bar")]
| ^
error: derive(Diagnostic): wrong field type for suggestion
--> $DIR/diagnostic-derive.rs:271:5
--> $DIR/diagnostic-derive.rs:267:5
|
LL | #[suggestion(no_crate_suggestion, code = "This is suggested code")]
| ^
@@ -257,79 +223,79 @@ LL | #[suggestion(no_crate_suggestion, code = "This is suggested code")]
= help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)`
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive.rs:287:24
--> $DIR/diagnostic-derive.rs:283:24
|
LL | suggestion: (Span, Span, Applicability),
| ^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:287:18
--> $DIR/diagnostic-derive.rs:283:18
|
LL | suggestion: (Span, Span, Applicability),
| ^^^^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive.rs:295:33
--> $DIR/diagnostic-derive.rs:291:33
|
LL | suggestion: (Applicability, Applicability, Span),
| ^^^^^^^^^^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:295:18
--> $DIR/diagnostic-derive.rs:291:18
|
LL | suggestion: (Applicability, Applicability, Span),
| ^^^^^^^^^^^^^
error: derive(Diagnostic): `#[label = ...]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:302:5
--> $DIR/diagnostic-derive.rs:298:5
|
LL | #[label = "bar"]
| ^
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive.rs:453:5
--> $DIR/diagnostic-derive.rs:449:5
|
LL | #[suggestion(no_crate_suggestion, code = "...", applicability = "maybe-incorrect")]
| ^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:455:24
--> $DIR/diagnostic-derive.rs:451:24
|
LL | suggestion: (Span, Applicability),
| ^^^^^^^^^^^^^
error: derive(Diagnostic): invalid applicability
--> $DIR/diagnostic-derive.rs:461:69
--> $DIR/diagnostic-derive.rs:457:69
|
LL | #[suggestion(no_crate_suggestion, code = "...", applicability = "batman")]
| ^^^^^^^^
error: derive(Diagnostic): the `#[help(...)]` attribute can only be applied to fields of type `Span`, `MultiSpan`, `bool` or `()`
--> $DIR/diagnostic-derive.rs:528:5
--> $DIR/diagnostic-derive.rs:524:5
|
LL | #[help(no_crate_help)]
| ^
error: derive(Diagnostic): a diagnostic slug must be the first argument to the attribute
--> $DIR/diagnostic-derive.rs:537:32
--> $DIR/diagnostic-derive.rs:533:32
|
LL | #[label(no_crate_label, foo)]
| ^
error: derive(Diagnostic): only `no_span` is a valid nested attribute
--> $DIR/diagnostic-derive.rs:545:29
--> $DIR/diagnostic-derive.rs:541:29
|
LL | #[label(no_crate_label, foo = "...")]
| ^^^
error: derive(Diagnostic): only `no_span` is a valid nested attribute
--> $DIR/diagnostic-derive.rs:553:29
--> $DIR/diagnostic-derive.rs:549:29
|
LL | #[label(no_crate_label, foo("..."))]
| ^^^
error: derive(Diagnostic): `#[primary_span]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:565:5
--> $DIR/diagnostic-derive.rs:561:5
|
LL | #[primary_span]
| ^
@@ -337,13 +303,13 @@ LL | #[primary_span]
= help: the `primary_span` field attribute is not valid for lint diagnostics
error: derive(Diagnostic): `#[error(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:585:1
--> $DIR/diagnostic-derive.rs:581:1
|
LL | #[error(no_crate_example, code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:585:1
--> $DIR/diagnostic-derive.rs:581:1
|
LL | #[error(no_crate_example, code = E0123)]
| ^
@@ -351,13 +317,13 @@ LL | #[error(no_crate_example, code = E0123)]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): `#[warn_(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:592:1
--> $DIR/diagnostic-derive.rs:588:1
|
LL | #[warn_(no_crate_example, code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:592:1
--> $DIR/diagnostic-derive.rs:588:1
|
LL | #[warn_(no_crate_example, code = E0123)]
| ^
@@ -365,13 +331,13 @@ LL | #[warn_(no_crate_example, code = E0123)]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): `#[lint(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:599:1
--> $DIR/diagnostic-derive.rs:595:1
|
LL | #[lint(no_crate_example, code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:599:1
--> $DIR/diagnostic-derive.rs:595:1
|
LL | #[lint(no_crate_example, code = E0123)]
| ^
@@ -379,13 +345,13 @@ LL | #[lint(no_crate_example, code = E0123)]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): `#[lint(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:606:1
--> $DIR/diagnostic-derive.rs:602:1
|
LL | #[lint(no_crate_example, code = E0123)]
| ^
error: derive(Diagnostic): diagnostic slug not specified
--> $DIR/diagnostic-derive.rs:606:1
--> $DIR/diagnostic-derive.rs:602:1
|
LL | #[lint(no_crate_example, code = E0123)]
| ^
@@ -393,19 +359,19 @@ LL | #[lint(no_crate_example, code = E0123)]
= help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`
error: derive(Diagnostic): attribute specified multiple times
--> $DIR/diagnostic-derive.rs:615:53
--> $DIR/diagnostic-derive.rs:611:53
|
LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
| ^^^^
|
note: previously specified here
--> $DIR/diagnostic-derive.rs:615:39
--> $DIR/diagnostic-derive.rs:611:39
|
LL | #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
| ^^^^
error: derive(Diagnostic): wrong types for suggestion
--> $DIR/diagnostic-derive.rs:624:24
--> $DIR/diagnostic-derive.rs:620:24
|
LL | suggestion: (Span, usize),
| ^^^^^
@@ -413,7 +379,7 @@ LL | suggestion: (Span, usize),
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
error: derive(Diagnostic): wrong types for suggestion
--> $DIR/diagnostic-derive.rs:632:17
--> $DIR/diagnostic-derive.rs:628:17
|
LL | suggestion: (Span,),
| ^^^^^^^
@@ -421,13 +387,13 @@ LL | suggestion: (Span,),
= help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`
error: derive(Diagnostic): suggestion without `code = "..."`
--> $DIR/diagnostic-derive.rs:639:5
--> $DIR/diagnostic-derive.rs:635:5
|
LL | #[suggestion(no_crate_suggestion)]
| ^
error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:646:1
--> $DIR/diagnostic-derive.rs:642:1
|
LL | #[multipart_suggestion(no_crate_suggestion)]
| ^
@@ -435,7 +401,7 @@ LL | #[multipart_suggestion(no_crate_suggestion)]
= help: consider creating a `Subdiagnostic` instead
error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:649:1
--> $DIR/diagnostic-derive.rs:645:1
|
LL | #[multipart_suggestion()]
| ^
@@ -443,7 +409,7 @@ LL | #[multipart_suggestion()]
= help: consider creating a `Subdiagnostic` instead
error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:653:5
--> $DIR/diagnostic-derive.rs:649:5
|
LL | #[multipart_suggestion(no_crate_suggestion)]
| ^
@@ -451,7 +417,7 @@ LL | #[multipart_suggestion(no_crate_suggestion)]
= help: consider creating a `Subdiagnostic` instead
error: derive(Diagnostic): `#[suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:661:1
--> $DIR/diagnostic-derive.rs:657:1
|
LL | #[suggestion(no_crate_suggestion, code = "...")]
| ^
@@ -459,7 +425,7 @@ LL | #[suggestion(no_crate_suggestion, code = "...")]
= help: `#[label]` and `#[suggestion]` can only be applied to fields
error: derive(Diagnostic): `#[label]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:670:1
--> $DIR/diagnostic-derive.rs:666:1
|
LL | #[label]
| ^
@@ -467,73 +433,73 @@ LL | #[label]
= help: `#[label]` and `#[suggestion]` can only be applied to fields
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:704:5
--> $DIR/diagnostic-derive.rs:700:5
|
LL | #[subdiagnostic(bad)]
| ^
error: derive(Diagnostic): `#[subdiagnostic = ...]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:712:5
--> $DIR/diagnostic-derive.rs:708:5
|
LL | #[subdiagnostic = "bad"]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:720:5
--> $DIR/diagnostic-derive.rs:716:5
|
LL | #[subdiagnostic(bad, bad)]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:728:5
--> $DIR/diagnostic-derive.rs:724:5
|
LL | #[subdiagnostic("bad")]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:736:5
--> $DIR/diagnostic-derive.rs:732:5
|
LL | #[subdiagnostic(eager)]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:744:5
--> $DIR/diagnostic-derive.rs:740:5
|
LL | #[subdiagnostic(eager)]
| ^
error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:765:5
--> $DIR/diagnostic-derive.rs:761:5
|
LL | #[subdiagnostic(eager)]
| ^
error: derive(Diagnostic): expected at least one string literal for `code(...)`
--> $DIR/diagnostic-derive.rs:796:23
--> $DIR/diagnostic-derive.rs:792:23
|
LL | #[suggestion(code())]
| ^
error: derive(Diagnostic): `code(...)` must contain only string literals
--> $DIR/diagnostic-derive.rs:804:23
--> $DIR/diagnostic-derive.rs:800:23
|
LL | #[suggestion(code(foo))]
| ^^^
error: unexpected token, expected `)`
--> $DIR/diagnostic-derive.rs:804:23
--> $DIR/diagnostic-derive.rs:800:23
|
LL | #[suggestion(code(foo))]
| ^^^
error: expected string literal
--> $DIR/diagnostic-derive.rs:813:25
--> $DIR/diagnostic-derive.rs:809:25
|
LL | #[suggestion(code = 3)]
| ^
error: derive(Diagnostic): `#[suggestion(...)]` is not a valid attribute
--> $DIR/diagnostic-derive.rs:828:5
--> $DIR/diagnostic-derive.rs:824:5
|
LL | #[suggestion(no_crate_suggestion, code = "")]
| ^
@@ -549,13 +515,13 @@ LL | #[nonsense(no_crate_example, code = E0123)]
| ^^^^^^^^
error: cannot find attribute `nonsense` in this scope
--> $DIR/diagnostic-derive.rs:152:7
--> $DIR/diagnostic-derive.rs:148:7
|
LL | #[nonsense]
| ^^^^^^^^
error: cannot find attribute `error` in this scope
--> $DIR/diagnostic-derive.rs:585:3
--> $DIR/diagnostic-derive.rs:581:3
|
LL | #[error(no_crate_example, code = E0123)]
| ^^^^^
@@ -567,7 +533,7 @@ LL | struct ErrorAttribute {}
|
error: cannot find attribute `warn_` in this scope
--> $DIR/diagnostic-derive.rs:592:3
--> $DIR/diagnostic-derive.rs:588:3
|
LL | #[warn_(no_crate_example, code = E0123)]
| ^^^^^
@@ -579,7 +545,7 @@ LL + #[warn(no_crate_example, code = E0123)]
|
error: cannot find attribute `lint` in this scope
--> $DIR/diagnostic-derive.rs:599:3
--> $DIR/diagnostic-derive.rs:595:3
|
LL | #[lint(no_crate_example, code = E0123)]
| ^^^^
@@ -591,7 +557,7 @@ LL + #[link(no_crate_example, code = E0123)]
|
error: cannot find attribute `lint` in this scope
--> $DIR/diagnostic-derive.rs:606:3
--> $DIR/diagnostic-derive.rs:602:3
|
LL | #[lint(no_crate_example, code = E0123)]
| ^^^^
@@ -603,7 +569,7 @@ LL + #[link(no_crate_example, code = E0123)]
|
error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive.rs:646:3
--> $DIR/diagnostic-derive.rs:642:3
|
LL | #[multipart_suggestion(no_crate_suggestion)]
| ^^^^^^^^^^^^^^^^^^^^
@@ -615,7 +581,7 @@ LL | struct MultipartSuggestion {
|
error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive.rs:649:3
--> $DIR/diagnostic-derive.rs:645:3
|
LL | #[multipart_suggestion()]
| ^^^^^^^^^^^^^^^^^^^^
@@ -627,7 +593,7 @@ LL | struct MultipartSuggestion {
|
error: cannot find attribute `multipart_suggestion` in this scope
--> $DIR/diagnostic-derive.rs:653:7
--> $DIR/diagnostic-derive.rs:649:7
|
LL | #[multipart_suggestion(no_crate_suggestion)]
| ^^^^^^^^^^^^^^^^^^^^
@@ -641,7 +607,7 @@ LL | #[diag(nonsense, code = E0123)]
| ^^^^^^^^ not found in `crate::fluent_generated`
error[E0425]: cannot find value `__code_34` in this scope
--> $DIR/diagnostic-derive.rs:810:10
--> $DIR/diagnostic-derive.rs:806:10
|
LL | #[derive(Diagnostic)]
| ^^^^^^^^^^ not found in this scope
@@ -649,7 +615,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[E0277]: the trait bound `Hello: IntoDiagArg` is not satisfied
--> $DIR/diagnostic-derive.rs:351:12
--> $DIR/diagnostic-derive.rs:347:12
|
LL | #[derive(Diagnostic)]
| ---------- required by a bound introduced by this call
@@ -670,7 +636,7 @@ note: required by a bound in `Diag::<'a, G>::arg`
= note: in this macro invocation
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 85 previous errors
error: aborting due to 81 previous errors
Some errors have detailed explanations: E0277, E0425.
For more information about an error, try `rustc --explain E0277`.