Give Handler::fatal
and Session::fatal
the same return type.
Currently, `Handler::fatal` returns `FatalError`. But `Session::fatal` returns `!`, because it calls `Handler::fatal` and then calls `raise` on the result. This inconsistency is unfortunate. This commit changes `Handler::fatal` to do the `raise` itself, changing its return type to `!`. This is safe because there are only two calls to `Handler::fatal`, one in `rustc_session` and one in `rustc_codegen_cranelift`, and they both call `raise` on the result. `HandlerInner::fatal` still returns `FatalError`, so I renamed it `fatal_no_raise` to emphasise the return type difference.
This commit is contained in:
parent
71940e0a8a
commit
114380d215
3 changed files with 9 additions and 8 deletions
|
@ -1034,10 +1034,9 @@ impl Handler {
|
|||
db
|
||||
}
|
||||
|
||||
// NOTE: intentionally doesn't raise an error so rustc_codegen_ssa only reports fatal errors in the main thread
|
||||
#[rustc_lint_diagnostics]
|
||||
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> FatalError {
|
||||
self.inner.borrow_mut().fatal(msg)
|
||||
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> ! {
|
||||
self.inner.borrow_mut().fatal_no_raise(msg).raise()
|
||||
}
|
||||
|
||||
#[rustc_lint_diagnostics]
|
||||
|
@ -1469,10 +1468,10 @@ impl HandlerInner {
|
|||
DiagnosticMessage::Str(warnings),
|
||||
)),
|
||||
(_, 0) => {
|
||||
let _ = self.fatal(errors);
|
||||
let _ = self.fatal_no_raise(errors);
|
||||
}
|
||||
(_, _) => {
|
||||
let _ = self.fatal(format!("{errors}; {warnings}"));
|
||||
let _ = self.fatal_no_raise(format!("{errors}; {warnings}"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1631,7 +1630,9 @@ impl HandlerInner {
|
|||
self.emit_diagnostic(&mut Diagnostic::new(FailureNote, msg));
|
||||
}
|
||||
|
||||
fn fatal(&mut self, msg: impl Into<DiagnosticMessage>) -> FatalError {
|
||||
// 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(Fatal, msg);
|
||||
FatalError
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue