1
Fork 0

Make Diagnostic::span_fatal unconditionally raise an error

It had no callers which didn't immediately call `raise()`, and this
unifies the behavior with `Session`.
This commit is contained in:
Joshua Nelson 2021-03-27 22:45:01 -04:00
parent e49f4471aa
commit 96509b4835
5 changed files with 13 additions and 19 deletions

View file

@ -1236,9 +1236,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
(Some(..), Some(..), HalfOpen) => hir::LangItem::Range, (Some(..), Some(..), HalfOpen) => hir::LangItem::Range,
(None, Some(..), Closed) => hir::LangItem::RangeToInclusive, (None, Some(..), Closed) => hir::LangItem::RangeToInclusive,
(Some(..), Some(..), Closed) => unreachable!(), (Some(..), Some(..), Closed) => unreachable!(),
(_, None, Closed) => { (_, None, Closed) => self.diagnostic().span_fatal(span, "inclusive range with no end"),
self.diagnostic().span_fatal(span, "inclusive range with no end").raise()
}
}; };
let fields = self.arena.alloc_from_iter( let fields = self.arena.alloc_from_iter(

View file

@ -634,9 +634,9 @@ impl Handler {
DiagnosticBuilder::new(self, Level::Note, msg) DiagnosticBuilder::new(self, Level::Note, msg)
} }
pub fn span_fatal(&self, span: impl Into<MultiSpan>, msg: &str) -> FatalError { pub fn span_fatal(&self, span: impl Into<MultiSpan>, msg: &str) -> ! {
self.emit_diag_at_span(Diagnostic::new(Fatal, msg), span); self.emit_diag_at_span(Diagnostic::new(Fatal, msg), span);
FatalError FatalError.raise()
} }
pub fn span_fatal_with_code( pub fn span_fatal_with_code(
@ -644,9 +644,9 @@ impl Handler {
span: impl Into<MultiSpan>, span: impl Into<MultiSpan>,
msg: &str, msg: &str,
code: DiagnosticId, code: DiagnosticId,
) -> FatalError { ) -> ! {
self.emit_diag_at_span(Diagnostic::new_with_code(Fatal, Some(code), msg), span); self.emit_diag_at_span(Diagnostic::new_with_code(Fatal, Some(code), msg), span);
FatalError FatalError.raise()
} }
pub fn span_err(&self, span: impl Into<MultiSpan>, msg: &str) { pub fn span_err(&self, span: impl Into<MultiSpan>, msg: &str) {

View file

@ -148,15 +148,11 @@ impl<'a> StringReader<'a> {
None => "unterminated block comment", None => "unterminated block comment",
}; };
let last_bpos = self.pos; let last_bpos = self.pos;
self.sess self.sess.span_diagnostic.span_fatal_with_code(
.span_diagnostic
.struct_span_fatal_with_code(
self.mk_sp(start, last_bpos), self.mk_sp(start, last_bpos),
msg, msg,
error_code!(E0758), error_code!(E0758),
) );
.emit();
FatalError.raise();
} }
// Skip non-doc comments // Skip non-doc comments

View file

@ -112,7 +112,7 @@ impl CguReuseTracker {
not recorded", not recorded",
cgu_user_name, cgu_name cgu_user_name, cgu_name
); );
diag.span_fatal(error_span.0, &msg).raise(); diag.span_fatal(error_span.0, &msg)
} }
} }
} }

View file

@ -421,7 +421,7 @@ impl Session {
} }
pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! { pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! {
self.diagnostic().span_fatal(sp, msg).raise() self.diagnostic().span_fatal(sp, msg)
} }
pub fn span_fatal_with_code<S: Into<MultiSpan>>( pub fn span_fatal_with_code<S: Into<MultiSpan>>(
&self, &self,
@ -429,7 +429,7 @@ impl Session {
msg: &str, msg: &str,
code: DiagnosticId, code: DiagnosticId,
) -> ! { ) -> ! {
self.diagnostic().span_fatal_with_code(sp, msg, code).raise() self.diagnostic().span_fatal_with_code(sp, msg, code)
} }
pub fn fatal(&self, msg: &str) -> ! { pub fn fatal(&self, msg: &str) -> ! {
self.diagnostic().fatal(msg).raise() self.diagnostic().fatal(msg).raise()