1
Fork 0

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:
Nicholas Nethercote 2023-12-01 14:08:10 +11:00
parent 71940e0a8a
commit 114380d215
3 changed files with 9 additions and 8 deletions

View file

@ -461,7 +461,7 @@ impl Session {
}
#[rustc_lint_diagnostics]
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> ! {
self.diagnostic().fatal(msg).raise()
self.diagnostic().fatal(msg)
}
#[rustc_lint_diagnostics]
#[track_caller]