Support eager subdiagnostics again
This commit is contained in:
parent
ef4046e4f3
commit
7aff210ead
4 changed files with 29 additions and 30 deletions
|
@ -382,11 +382,27 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
|
||||||
return Ok(quote! { #diag.subdiagnostic(#binding); });
|
return Ok(quote! { #diag.subdiagnostic(#binding); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(Meta::List(_), "subdiagnostic") => {
|
(Meta::List(MetaList { ref nested, .. }), "subdiagnostic") => {
|
||||||
|
if nested.len() == 1
|
||||||
|
&& let Some(NestedMeta::Meta(Meta::Path(path))) = nested.first()
|
||||||
|
&& path.is_ident("eager") {
|
||||||
|
let handler = match &self.parent.kind {
|
||||||
|
DiagnosticDeriveKind::Diagnostic { handler } => handler,
|
||||||
|
DiagnosticDeriveKind::LintDiagnostic => {
|
||||||
throw_invalid_attr!(attr, &meta, |diag| {
|
throw_invalid_attr!(attr, &meta, |diag| {
|
||||||
diag.help("`subdiagnostic` does not support nested attributes")
|
diag.help("eager subdiagnostics are not supported on lints")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
return Ok(quote! { #diag.eager_subdiagnostic(#handler, #binding); });
|
||||||
|
} else {
|
||||||
|
throw_invalid_attr!(attr, &meta, |diag| {
|
||||||
|
diag.help(
|
||||||
|
"`eager` is the only supported nested attribute for `subdiagnostic`",
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#![feature(allow_internal_unstable)]
|
#![feature(allow_internal_unstable)]
|
||||||
#![feature(if_let_guard)]
|
#![feature(if_let_guard)]
|
||||||
|
#![feature(let_chains)]
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
#![feature(proc_macro_diagnostic)]
|
#![feature(proc_macro_diagnostic)]
|
||||||
#![feature(proc_macro_span)]
|
#![feature(proc_macro_span)]
|
||||||
|
|
|
@ -723,7 +723,6 @@ struct SubdiagnosticEagerLint {
|
||||||
#[diag(compiletest_example)]
|
#[diag(compiletest_example)]
|
||||||
struct SubdiagnosticEagerCorrect {
|
struct SubdiagnosticEagerCorrect {
|
||||||
#[subdiagnostic(eager)]
|
#[subdiagnostic(eager)]
|
||||||
//~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute
|
|
||||||
note: Note,
|
note: Note,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,7 +743,6 @@ pub(crate) struct SubdiagnosticWithSuggestion {
|
||||||
#[diag(compiletest_example)]
|
#[diag(compiletest_example)]
|
||||||
struct SubdiagnosticEagerSuggestion {
|
struct SubdiagnosticEagerSuggestion {
|
||||||
#[subdiagnostic(eager)]
|
#[subdiagnostic(eager)]
|
||||||
//~^ ERROR `#[subdiagnostic(...)]` is not a valid attribute
|
|
||||||
sub: SubdiagnosticWithSuggestion,
|
sub: SubdiagnosticWithSuggestion,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -539,7 +539,7 @@ error: `#[subdiagnostic(...)]` is not a valid attribute
|
||||||
LL | #[subdiagnostic(bad)]
|
LL | #[subdiagnostic(bad)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: `subdiagnostic` does not support nested attributes
|
= help: `eager` is the only supported nested attribute for `subdiagnostic`
|
||||||
|
|
||||||
error: `#[subdiagnostic = ...]` is not a valid attribute
|
error: `#[subdiagnostic = ...]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:693:5
|
--> $DIR/diagnostic-derive.rs:693:5
|
||||||
|
@ -553,7 +553,7 @@ error: `#[subdiagnostic(...)]` is not a valid attribute
|
||||||
LL | #[subdiagnostic(bad, bad)]
|
LL | #[subdiagnostic(bad, bad)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: `subdiagnostic` does not support nested attributes
|
= help: `eager` is the only supported nested attribute for `subdiagnostic`
|
||||||
|
|
||||||
error: `#[subdiagnostic(...)]` is not a valid attribute
|
error: `#[subdiagnostic(...)]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:709:5
|
--> $DIR/diagnostic-derive.rs:709:5
|
||||||
|
@ -561,7 +561,7 @@ error: `#[subdiagnostic(...)]` is not a valid attribute
|
||||||
LL | #[subdiagnostic("bad")]
|
LL | #[subdiagnostic("bad")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: `subdiagnostic` does not support nested attributes
|
= help: `eager` is the only supported nested attribute for `subdiagnostic`
|
||||||
|
|
||||||
error: `#[subdiagnostic(...)]` is not a valid attribute
|
error: `#[subdiagnostic(...)]` is not a valid attribute
|
||||||
--> $DIR/diagnostic-derive.rs:717:5
|
--> $DIR/diagnostic-derive.rs:717:5
|
||||||
|
@ -569,38 +569,22 @@ error: `#[subdiagnostic(...)]` is not a valid attribute
|
||||||
LL | #[subdiagnostic(eager)]
|
LL | #[subdiagnostic(eager)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= help: `subdiagnostic` does not support nested attributes
|
= help: eager subdiagnostics are not supported on lints
|
||||||
|
|
||||||
error: `#[subdiagnostic(...)]` is not a valid attribute
|
|
||||||
--> $DIR/diagnostic-derive.rs:725:5
|
|
||||||
|
|
|
||||||
LL | #[subdiagnostic(eager)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= help: `subdiagnostic` does not support nested attributes
|
|
||||||
|
|
||||||
error: `#[subdiagnostic(...)]` is not a valid attribute
|
|
||||||
--> $DIR/diagnostic-derive.rs:746:5
|
|
||||||
|
|
|
||||||
LL | #[subdiagnostic(eager)]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= help: `subdiagnostic` does not support nested attributes
|
|
||||||
|
|
||||||
error: expected at least one string literal for `code(...)`
|
error: expected at least one string literal for `code(...)`
|
||||||
--> $DIR/diagnostic-derive.rs:777:18
|
--> $DIR/diagnostic-derive.rs:775:18
|
||||||
|
|
|
|
||||||
LL | #[suggestion(code())]
|
LL | #[suggestion(code())]
|
||||||
| ^^^^^^
|
| ^^^^^^
|
||||||
|
|
||||||
error: `code(...)` must contain only string literals
|
error: `code(...)` must contain only string literals
|
||||||
--> $DIR/diagnostic-derive.rs:785:23
|
--> $DIR/diagnostic-derive.rs:783:23
|
||||||
|
|
|
|
||||||
LL | #[suggestion(code(foo))]
|
LL | #[suggestion(code(foo))]
|
||||||
| ^^^
|
| ^^^
|
||||||
|
|
||||||
error: `code = "..."`/`code(...)` must contain only string literals
|
error: `code = "..."`/`code(...)` must contain only string literals
|
||||||
--> $DIR/diagnostic-derive.rs:793:18
|
--> $DIR/diagnostic-derive.rs:791:18
|
||||||
|
|
|
|
||||||
LL | #[suggestion(code = 3)]
|
LL | #[suggestion(code = 3)]
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
@ -676,7 +660,7 @@ note: required by a bound in `DiagnosticBuilder::<'a, G>::set_arg`
|
||||||
--> $COMPILER_DIR/rustc_errors/src/diagnostic_builder.rs:LL:CC
|
--> $COMPILER_DIR/rustc_errors/src/diagnostic_builder.rs:LL:CC
|
||||||
= note: this error originates in the derive macro `Diagnostic` which comes from the expansion of the macro `forward` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the derive macro `Diagnostic` which comes from the expansion of the macro `forward` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: aborting due to 85 previous errors
|
error: aborting due to 83 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0277, E0425.
|
Some errors have detailed explanations: E0277, E0425.
|
||||||
For more information about an error, try `rustc --explain E0277`.
|
For more information about an error, try `rustc --explain E0277`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue