diff options
| author | Jubilee <46493976+workingjubilee@users.noreply.github.com> | 2023-12-14 16:07:48 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-14 16:07:48 -0800 |
| commit | 9e872b7cd8cd28314b9426e13ac586dad6fc9c2e (patch) | |
| tree | 33b238d5fc9b8970f6a89273089982dd0bd7ce56 /compiler/rustc_parse/src | |
| parent | 576a74b8c9dc72704309db8fc12a2f1ca1cd7c59 (diff) | |
| parent | 9a7841251115c79fe7e1c12e2e5d637e19ad940a (diff) | |
| download | rust-9e872b7cd8cd28314b9426e13ac586dad6fc9c2e.tar.gz rust-9e872b7cd8cd28314b9426e13ac586dad6fc9c2e.zip | |
Rollup merge of #118933 - nnethercote:cleanup-errors-even-more, r=compiler-errors
Cleanup errors handlers even more A sequel to #118587. r? `@compiler-errors`
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/errors.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/lexer/unicode_chars.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/lib.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 4 |
4 files changed, 9 insertions, 10 deletions
diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index bc53ab83439..c51a5c095ee 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -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 } diff --git a/compiler/rustc_parse/src/lexer/unicode_chars.rs b/compiler/rustc_parse/src/lexer/unicode_chars.rs index bbfb160ebf7..0dc60688955 100644 --- a/compiler/rustc_parse/src/lexer/unicode_chars.rs +++ b/compiler/rustc_parse/src/lexer/unicode_chars.rs @@ -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 diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 95352dbdc13..9887a85e6a4 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -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(); } } diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 5295172b25e..221fc70d9ff 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -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 { |
