Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup error handlers some more #118587

Merged
merged 13 commits into from
Dec 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Inline and remove fatal_no_raise.
This makes `Handler::fatal` more like `Handler::{err,warn,bug,note}`.
  • Loading branch information
nnethercote committed Dec 4, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 7811c976d1a6b014bff0fdada7aaaa1774d31b82
13 changes: 3 additions & 10 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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]
@@ -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}")));
}
}

@@ -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>,