diff options
Diffstat (limited to 'compiler/rustc_errors')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 24 |
2 files changed, 22 insertions, 4 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index bc136aea44d..bf20c7431e4 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -248,7 +248,7 @@ pub trait Emitter: Translate { fluent_args: &FluentArgs<'_>, ) -> (MultiSpan, &'a [CodeSuggestion]) { let mut primary_span = diag.span.clone(); - let suggestions = diag.suggestions.as_ref().map_or(&[][..], |suggestions| &suggestions[..]); + let suggestions = diag.suggestions.as_deref().unwrap_or(&[]); if let Some((sugg, rest)) = suggestions.split_first() { let msg = self.translate_message(&sugg.msg, fluent_args); if rest.is_empty() && diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index f3f1c7534b0..2be36a6eeb4 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -467,6 +467,9 @@ pub enum StashKey { /// When an invalid lifetime e.g. `'2` should be reinterpreted /// as a char literal in the parser LifetimeIsChar, + /// Maybe there was a typo where a comma was forgotten before + /// FRU syntax + MaybeFruTypo, } fn default_track_diagnostic(_: &Diagnostic) {} @@ -1041,13 +1044,24 @@ impl Handler { } pub fn has_errors_or_lint_errors(&self) -> Option<ErrorGuaranteed> { if self.inner.borrow().has_errors_or_lint_errors() { - Some(ErrorGuaranteed(())) + Some(ErrorGuaranteed::unchecked_claim_error_was_emitted()) + } else { + None + } + } + pub fn has_errors_or_delayed_span_bugs(&self) -> Option<ErrorGuaranteed> { + if self.inner.borrow().has_errors_or_delayed_span_bugs() { + Some(ErrorGuaranteed::unchecked_claim_error_was_emitted()) } else { None } } - pub fn has_errors_or_delayed_span_bugs(&self) -> bool { - self.inner.borrow().has_errors_or_delayed_span_bugs() + pub fn is_compilation_going_to_fail(&self) -> Option<ErrorGuaranteed> { + if self.inner.borrow().is_compilation_going_to_fail() { + Some(ErrorGuaranteed::unchecked_claim_error_was_emitted()) + } else { + None + } } pub fn print_error_count(&self, registry: &Registry) { @@ -1481,6 +1495,10 @@ impl HandlerInner { self.err_count() > 0 || self.lint_err_count > 0 || self.warn_count > 0 } + fn is_compilation_going_to_fail(&self) -> bool { + self.has_errors() || self.lint_err_count > 0 || !self.delayed_span_bugs.is_empty() + } + fn abort_if_errors(&mut self) { self.emit_stashed_diagnostics(); |
