1
Fork 0

Auto merge of #110092 - clubby789:builtin-macros-translatable, r=compiler-errors

Migrate most of `rustc_builtin_macros` to diagnostic impls

cc #100717

This is a couple of days work, but I decided to stop for now before the PR becomes too big. There's around 50 unresolved failures when `rustc::untranslatable_diagnostic` is denied, which I'll finish addressing once this PR goes thtough

A couple of outputs have changed, but in all instances I think the changes are an improvement/are more consistent with other diagnostics (although I'm happy to revert any which seem worse)
This commit is contained in:
bors 2023-04-11 14:40:54 +00:00
commit 45749b21b7
31 changed files with 978 additions and 349 deletions

View file

@ -392,14 +392,16 @@ impl<'a> DiagnosticDeriveVariantBuilder<'a> {
}
SubdiagnosticKind::Note | SubdiagnosticKind::Help | SubdiagnosticKind::Warn => {
let inner = info.ty.inner_type();
if type_matches_path(inner, &["rustc_span", "Span"]) {
if type_matches_path(inner, &["rustc_span", "Span"])
|| type_matches_path(inner, &["rustc_span", "MultiSpan"])
{
Ok(self.add_spanned_subdiagnostic(binding, &fn_ident, slug))
} else if type_is_unit(inner)
|| (matches!(info.ty, FieldInnerTy::Plain(_)) && type_is_bool(inner))
{
Ok(self.add_subdiagnostic(&fn_ident, slug))
} else {
report_type_error(attr, "`Span`, `bool` or `()`")?
report_type_error(attr, "`Span`, `MultiSpan`, `bool` or `()`")?
}
}
SubdiagnosticKind::Suggestion {