Skip to content

Commit 8e6bca6

Browse files
committed
Inline and remove StringReader::struct_fatal_span_char.
It has a single call site.
1 parent 4d35981 commit 8e6bca6

File tree

1 file changed

+11
-22
lines changed
  • compiler/rustc_parse/src/lexer

1 file changed

+11
-22
lines changed

compiler/rustc_parse/src/lexer/mod.rs

+11-22
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ use rustc_ast::ast::{self, AttrStyle};
77
use rustc_ast::token::{self, CommentKind, Delimiter, Token, TokenKind};
88
use rustc_ast::tokenstream::TokenStream;
99
use rustc_ast::util::unicode::contains_text_flow_control_chars;
10-
use rustc_errors::{
11-
error_code, Applicability, DiagCtxt, Diagnostic, DiagnosticBuilder, FatalAbort, StashKey,
12-
};
10+
use rustc_errors::{error_code, Applicability, DiagCtxt, Diagnostic, StashKey};
1311
use rustc_lexer::unescape::{self, EscapeError, Mode};
1412
use rustc_lexer::{Base, DocStyle, RawStrError};
1513
use rustc_lexer::{Cursor, LiteralKind};
@@ -344,18 +342,6 @@ impl<'a> StringReader<'a> {
344342
token::Ident(sym, false)
345343
}
346344

347-
fn struct_fatal_span_char(
348-
&self,
349-
from_pos: BytePos,
350-
to_pos: BytePos,
351-
m: &str,
352-
c: char,
353-
) -> DiagnosticBuilder<'a, FatalAbort> {
354-
self.sess
355-
.dcx
356-
.struct_span_fatal(self.mk_sp(from_pos, to_pos), format!("{}: {}", m, escaped_char(c)))
357-
}
358-
359345
/// Detect usages of Unicode codepoints changing the direction of the text on screen and loudly
360346
/// complain about it.
361347
fn lint_unicode_text_flow(&self, start: BytePos) {
@@ -568,13 +554,16 @@ impl<'a> StringReader<'a> {
568554
}
569555

570556
fn report_non_started_raw_string(&self, start: BytePos, bad_char: char) -> ! {
571-
self.struct_fatal_span_char(
572-
start,
573-
self.pos,
574-
"found invalid character; only `#` is allowed in raw string delimitation",
575-
bad_char,
576-
)
577-
.emit()
557+
self.sess
558+
.dcx
559+
.struct_span_fatal(
560+
self.mk_sp(start, self.pos),
561+
format!(
562+
"found invalid character; only `#` is allowed in raw string delimitation: {}",
563+
escaped_char(bad_char)
564+
),
565+
)
566+
.emit()
578567
}
579568

580569
fn report_unterminated_raw_string(

0 commit comments

Comments
 (0)