diff options
| author | David Wood <david.wood@huawei.com> | 2022-04-27 05:59:48 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-04-29 02:12:10 +0100 |
| commit | dca88612b96db761f86ab66d85836baf0e804910 (patch) | |
| tree | f101647c89de3247357a3d5a6db8f63f63528fcd /compiler/rustc_macros/src | |
| parent | e5d9371b302ff0d368ea6e075769eb4b2709b2ba (diff) | |
| download | rust-dca88612b96db761f86ab66d85836baf0e804910.tar.gz rust-dca88612b96db761f86ab66d85836baf0e804910.zip | |
macros: add interop between diagnostic derives
Add `#[subdiagnostic]` field attribute to the diagnostic derive which is applied to fields that have types which use the subdiagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'compiler/rustc_macros/src')
| -rw-r--r-- | compiler/rustc_macros/src/diagnostics/diagnostic.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_macros/src/lib.rs | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic.rs b/compiler/rustc_macros/src/diagnostics/diagnostic.rs index c163f233b47..f49166433fa 100644 --- a/compiler/rustc_macros/src/diagnostics/diagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/diagnostic.rs @@ -404,9 +404,10 @@ impl SessionDiagnosticDeriveBuilder { report_error_if_not_applied_to_span(attr, &info)?; Ok(self.add_subdiagnostic(field_binding, name, name)) } + "subdiagnostic" => Ok(quote! { #diag.subdiagnostic(*#field_binding); }), _ => throw_invalid_attr!(attr, &meta, |diag| { diag - .help("only `skip_arg`, `primary_span`, `label`, `note` and `help` are valid field attributes") + .help("only `skip_arg`, `primary_span`, `label`, `note`, `help` and `subdiagnostic` are valid field attributes") }), }, Meta::NameValue(MetaNameValue { lit: syn::Lit::Str(ref s), .. }) => match name { diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs index ed2021e7d74..b01e01414e8 100644 --- a/compiler/rustc_macros/src/lib.rs +++ b/compiler/rustc_macros/src/lib.rs @@ -73,6 +73,7 @@ decl_derive!( skip_arg, primary_span, label, + subdiagnostic, suggestion, suggestion_short, suggestion_hidden, |
