Skip to content

Commit

Permalink
Inline and remove fatal_no_raise.
Browse files Browse the repository at this point in the history
This makes `Handler::fatal` more like `Handler::{err,warn,bug,note}`.
  • Loading branch information
nnethercote committed Dec 4, 2023
1 parent 49703f0 commit 9010a90
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ impl Handler {

#[rustc_lint_diagnostics]
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> ! {
self.inner.borrow_mut().fatal_no_raise(msg).raise()
DiagnosticBuilder::<FatalError>::new(self, Fatal, msg).emit().raise()
}

#[rustc_lint_diagnostics]
Expand Down Expand Up @@ -1181,10 +1181,10 @@ impl Handler {
DiagnosticMessage::Str(warnings),
)),
(_, 0) => {
let _ = inner.fatal_no_raise(errors);
inner.emit_diagnostic(&mut Diagnostic::new(Fatal, errors));
}
(_, _) => {
let _ = inner.fatal_no_raise(format!("{errors}; {warnings}"));
inner.emit_diagnostic(&mut Diagnostic::new(Fatal, format!("{errors}; {warnings}")));
}
}

Expand Down Expand Up @@ -1592,13 +1592,6 @@ impl HandlerInner {
self.emit_diagnostic(&mut Diagnostic::new(FailureNote, msg));
}

// Note: unlike `Handler::fatal`, this doesn't return `!`, because that is
// inappropriate for some of its call sites.
fn fatal_no_raise(&mut self, msg: impl Into<DiagnosticMessage>) -> FatalError {
self.emit_diagnostic(&mut Diagnostic::new(Fatal, msg));
FatalError
}

fn flush_delayed(
&mut self,
bugs: impl IntoIterator<Item = DelayedDiagnostic>,
Expand Down

0 comments on commit 9010a90

Please sign in to comment.