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>
This commit is contained in:
parent
e5d9371b30
commit
dca88612b9
4 changed files with 16 additions and 3 deletions
|
@ -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 {
|
||||
|
|
|
@ -73,6 +73,7 @@ decl_derive!(
|
|||
skip_arg,
|
||||
primary_span,
|
||||
label,
|
||||
subdiagnostic,
|
||||
suggestion,
|
||||
suggestion_short,
|
||||
suggestion_hidden,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue