1
Fork 0

Disallow #[primary_span] on LintDiagnostics

This commit is contained in:
Xiretza 2022-08-19 15:04:34 +02:00
parent a960f8304c
commit bd0d3f745d
4 changed files with 30 additions and 6 deletions

View file

@ -340,11 +340,20 @@ impl DiagnosticDeriveBuilder {
Ok(quote! {})
}
"primary_span" => {
report_error_if_not_applied_to_span(attr, &info)?;
match self.kind {
DiagnosticDeriveKind::SessionDiagnostic => {
report_error_if_not_applied_to_span(attr, &info)?;
Ok(quote! {
#diag.set_span(#binding);
})
Ok(quote! {
#diag.set_span(#binding);
})
}
DiagnosticDeriveKind::LintDiagnostic => {
throw_invalid_attr!(attr, &meta, |diag| {
diag.help("the `primary_span` field attribute is not valid for lint diagnostics")
})
}
}
}
"label" => {
report_error_if_not_applied_to_span(attr, &info)?;