1
Fork 0

Avoid struct_diagnostic where possible.

It's necessary for `derive(Diagnostic)`, but is best avoided elsewhere
because there are clearer alternatives.

This required adding `Handler::struct_almost_fatal`.
This commit is contained in:
Nicholas Nethercote 2023-12-13 15:19:34 +11:00
parent dc05a30996
commit 7bdb227567
7 changed files with 26 additions and 19 deletions

View file

@ -65,7 +65,7 @@ pub(crate) struct RequiresUnsafe {
impl<'sess> IntoDiagnostic<'sess> for RequiresUnsafe {
#[track_caller]
fn into_diagnostic(self, handler: &'sess Handler) -> DiagnosticBuilder<'sess, ErrorGuaranteed> {
let mut diag = handler.struct_diagnostic(fluent::mir_transform_requires_unsafe);
let mut diag = handler.struct_err(fluent::mir_transform_requires_unsafe);
diag.code(rustc_errors::DiagnosticId::Error("E0133".to_string()));
diag.set_span(self.span);
diag.span_label(self.span, self.details.label());