1
Fork 0

Rollup merge of #118933 - nnethercote:cleanup-errors-even-more, r=compiler-errors

Cleanup errors handlers even more

A sequel to #118587.

r? `@compiler-errors`
This commit is contained in:
Jubilee 2023-12-14 16:07:48 -08:00 committed by GitHub
commit 9e872b7cd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 117 additions and 113 deletions

View file

@ -1046,7 +1046,7 @@ impl<'a> IntoDiagnostic<'a> for ExpectedIdentifier {
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
let token_descr = TokenDescription::from_token(&self.token);
let mut diag = handler.struct_diagnostic(match token_descr {
let mut diag = handler.struct_err(match token_descr {
Some(TokenDescription::ReservedIdentifier) => {
fluent::parse_expected_identifier_found_reserved_identifier_str
}
@ -1103,7 +1103,7 @@ impl<'a> IntoDiagnostic<'a> for ExpectedSemi {
) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
let token_descr = TokenDescription::from_token(&self.token);
let mut diag = handler.struct_diagnostic(match token_descr {
let mut diag = handler.struct_err(match token_descr {
Some(TokenDescription::ReservedIdentifier) => {
fluent::parse_expected_semi_found_reserved_identifier_str
}

View file

@ -350,8 +350,7 @@ pub(super) fn check_for_substitution(
let Some((_, ascii_name, token)) = ASCII_ARRAY.iter().find(|&&(s, _, _)| s == ascii_str) else {
let msg = format!("substitution character not found for '{ch}'");
reader.sess.span_diagnostic.span_bug_no_panic(span, msg);
return (None, None);
reader.sess.span_diagnostic.span_bug(span, msg);
};
// special help suggestion for "directed" double quotes

View file

@ -51,8 +51,8 @@ macro_rules! panictry_buffer {
match $e {
Ok(e) => e,
Err(errs) => {
for mut e in errs {
$handler.emit_diagnostic(&mut e);
for e in errs {
$handler.emit_diagnostic(e);
}
FatalError.raise()
}
@ -165,8 +165,8 @@ fn try_file_to_source_file(
fn file_to_source_file(sess: &ParseSess, path: &Path, spanopt: Option<Span>) -> Lrc<SourceFile> {
match try_file_to_source_file(sess, path, spanopt) {
Ok(source_file) => source_file,
Err(mut d) => {
sess.span_diagnostic.emit_diagnostic(&mut d);
Err(d) => {
sess.span_diagnostic.emit_diagnostic(d);
FatalError.raise();
}
}

View file

@ -249,8 +249,8 @@ impl<'a> Parser<'a> {
self.diagnostic().struct_span_err(sp, m)
}
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, m: impl Into<String>) -> ! {
self.diagnostic().span_bug(sp, m)
pub fn span_bug<S: Into<MultiSpan>>(&self, sp: S, msg: impl Into<DiagnosticMessage>) -> ! {
self.diagnostic().span_bug(sp, msg)
}
pub(super) fn diagnostic(&self) -> &'a Handler {