Skip to content

Commit 96509b4

Browse files
committed
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`.
1 parent e49f447 commit 96509b4

File tree

5 files changed

+13
-19
lines changed

5 files changed

+13
-19
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1236,9 +1236,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12361236
(Some(..), Some(..), HalfOpen) => hir::LangItem::Range,
12371237
(None, Some(..), Closed) => hir::LangItem::RangeToInclusive,
12381238
(Some(..), Some(..), Closed) => unreachable!(),
1239-
(_, None, Closed) => {
1240-
self.diagnostic().span_fatal(span, "inclusive range with no end").raise()
1241-
}
1239+
(_, None, Closed) => self.diagnostic().span_fatal(span, "inclusive range with no end"),
12421240
};
12431241

12441242
let fields = self.arena.alloc_from_iter(

compiler/rustc_errors/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -634,19 +634,19 @@ impl Handler {
634634
DiagnosticBuilder::new(self, Level::Note, msg)
635635
}
636636

637-
pub fn span_fatal(&self, span: impl Into<MultiSpan>, msg: &str) -> FatalError {
637+
pub fn span_fatal(&self, span: impl Into<MultiSpan>, msg: &str) -> ! {
638638
self.emit_diag_at_span(Diagnostic::new(Fatal, msg), span);
639-
FatalError
639+
FatalError.raise()
640640
}
641641

642642
pub fn span_fatal_with_code(
643643
&self,
644644
span: impl Into<MultiSpan>,
645645
msg: &str,
646646
code: DiagnosticId,
647-
) -> FatalError {
647+
) -> ! {
648648
self.emit_diag_at_span(Diagnostic::new_with_code(Fatal, Some(code), msg), span);
649-
FatalError
649+
FatalError.raise()
650650
}
651651

652652
pub fn span_err(&self, span: impl Into<MultiSpan>, msg: &str) {

compiler/rustc_parse/src/lexer/mod.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,11 @@ impl<'a> StringReader<'a> {
148148
None => "unterminated block comment",
149149
};
150150
let last_bpos = self.pos;
151-
self.sess
152-
.span_diagnostic
153-
.struct_span_fatal_with_code(
154-
self.mk_sp(start, last_bpos),
155-
msg,
156-
error_code!(E0758),
157-
)
158-
.emit();
159-
FatalError.raise();
151+
self.sess.span_diagnostic.span_fatal_with_code(
152+
self.mk_sp(start, last_bpos),
153+
msg,
154+
error_code!(E0758),
155+
);
160156
}
161157

162158
// Skip non-doc comments

compiler/rustc_session/src/cgu_reuse_tracker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl CguReuseTracker {
112112
not recorded",
113113
cgu_user_name, cgu_name
114114
);
115-
diag.span_fatal(error_span.0, &msg).raise();
115+
diag.span_fatal(error_span.0, &msg)
116116
}
117117
}
118118
}

compiler/rustc_session/src/session.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -421,15 +421,15 @@ impl Session {
421421
}
422422

423423
pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> ! {
424-
self.diagnostic().span_fatal(sp, msg).raise()
424+
self.diagnostic().span_fatal(sp, msg)
425425
}
426426
pub fn span_fatal_with_code<S: Into<MultiSpan>>(
427427
&self,
428428
sp: S,
429429
msg: &str,
430430
code: DiagnosticId,
431431
) -> ! {
432-
self.diagnostic().span_fatal_with_code(sp, msg, code).raise()
432+
self.diagnostic().span_fatal_with_code(sp, msg, code)
433433
}
434434
pub fn fatal(&self, msg: &str) -> ! {
435435
self.diagnostic().fatal(msg).raise()

0 commit comments

Comments
 (0)