Skip to content

Commit e49f447

Browse files
committed
Remove some unnecessary uses of struct_span_fatal
All of them immediately called `emit()` then `raise()`, so they could just call `span_fatal` directly.
1 parent 955fdae commit e49f447

File tree

1 file changed

+20
-36
lines changed
  • compiler/rustc_parse/src/lexer

1 file changed

+20
-36
lines changed

compiler/rustc_parse/src/lexer/mod.rs

+20-36
Original file line numberDiff line numberDiff line change
@@ -315,57 +315,41 @@ impl<'a> StringReader<'a> {
315315
let (lit_kind, mode, prefix_len, postfix_len) = match kind {
316316
rustc_lexer::LiteralKind::Char { terminated } => {
317317
if !terminated {
318-
self.sess
319-
.span_diagnostic
320-
.struct_span_fatal_with_code(
321-
self.mk_sp(start, suffix_start),
322-
"unterminated character literal",
323-
error_code!(E0762),
324-
)
325-
.emit();
326-
FatalError.raise();
318+
self.sess.span_diagnostic.span_fatal_with_code(
319+
self.mk_sp(start, suffix_start),
320+
"unterminated character literal",
321+
error_code!(E0762),
322+
)
327323
}
328324
(token::Char, Mode::Char, 1, 1) // ' '
329325
}
330326
rustc_lexer::LiteralKind::Byte { terminated } => {
331327
if !terminated {
332-
self.sess
333-
.span_diagnostic
334-
.struct_span_fatal_with_code(
335-
self.mk_sp(start + BytePos(1), suffix_start),
336-
"unterminated byte constant",
337-
error_code!(E0763),
338-
)
339-
.emit();
340-
FatalError.raise();
328+
self.sess.span_diagnostic.span_fatal_with_code(
329+
self.mk_sp(start + BytePos(1), suffix_start),
330+
"unterminated byte constant",
331+
error_code!(E0763),
332+
)
341333
}
342334
(token::Byte, Mode::Byte, 2, 1) // b' '
343335
}
344336
rustc_lexer::LiteralKind::Str { terminated } => {
345337
if !terminated {
346-
self.sess
347-
.span_diagnostic
348-
.struct_span_fatal_with_code(
349-
self.mk_sp(start, suffix_start),
350-
"unterminated double quote string",
351-
error_code!(E0765),
352-
)
353-
.emit();
354-
FatalError.raise();
338+
self.sess.span_diagnostic.span_fatal_with_code(
339+
self.mk_sp(start, suffix_start),
340+
"unterminated double quote string",
341+
error_code!(E0765),
342+
)
355343
}
356344
(token::Str, Mode::Str, 1, 1) // " "
357345
}
358346
rustc_lexer::LiteralKind::ByteStr { terminated } => {
359347
if !terminated {
360-
self.sess
361-
.span_diagnostic
362-
.struct_span_fatal_with_code(
363-
self.mk_sp(start + BytePos(1), suffix_start),
364-
"unterminated double quote byte string",
365-
error_code!(E0766),
366-
)
367-
.emit();
368-
FatalError.raise();
348+
self.sess.span_diagnostic.span_fatal_with_code(
349+
self.mk_sp(start + BytePos(1), suffix_start),
350+
"unterminated double quote byte string",
351+
error_code!(E0766),
352+
)
369353
}
370354
(token::ByteStr, Mode::ByteStr, 2, 1) // b" "
371355
}

0 commit comments

Comments
 (0)