@@ -49,13 +49,12 @@ impl<'a> StringReader<'a> {
49
49
// Make sure external source is loaded first, before accessing it.
50
50
// While this can't show up during normal parsing, `retokenize` may
51
51
// be called with a source file from an external crate.
52
- sess. source_map ( ) . ensure_source_file_source_present ( source_file . clone ( ) ) ;
52
+ sess. source_map ( ) . ensure_source_file_source_present ( Lrc :: clone ( & source_file ) ) ;
53
53
54
- // FIXME(eddyb) use `Lrc<str>` or similar to avoid cloning the `String`.
55
54
let src = if let Some ( src) = & source_file. src {
56
- src . clone ( )
55
+ Lrc :: clone ( & src )
57
56
} else if let Some ( src) = source_file. external_src . borrow ( ) . get_source ( ) {
58
- src . clone ( )
57
+ Lrc :: clone ( & src )
59
58
} else {
60
59
sess. span_diagnostic
61
60
. bug ( & format ! ( "cannot lex `source_file` without source: {}" , source_file. name) ) ;
@@ -125,10 +124,7 @@ impl<'a> StringReader<'a> {
125
124
126
125
debug ! ( "try_next_token: {:?}({:?})" , token. kind, self . str_from( start) ) ;
127
126
128
- // This could use `?`, but that makes code significantly (10-20%) slower.
129
- // https://github.com/rust-lang/rust/issues/37939
130
127
let kind = self . cook_lexer_token ( token. kind , start) ;
131
-
132
128
let span = self . mk_sp ( start, self . pos ) ;
133
129
Token :: new ( kind, span)
134
130
}
@@ -153,15 +149,6 @@ impl<'a> StringReader<'a> {
153
149
self . err_span ( self . mk_sp ( from_pos, to_pos) , m)
154
150
}
155
151
156
- fn struct_span_fatal (
157
- & self ,
158
- from_pos : BytePos ,
159
- to_pos : BytePos ,
160
- m : & str ,
161
- ) -> DiagnosticBuilder < ' a > {
162
- self . sess . span_diagnostic . struct_span_fatal ( self . mk_sp ( from_pos, to_pos) , m)
163
- }
164
-
165
152
fn struct_fatal_span_char (
166
153
& self ,
167
154
from_pos : BytePos ,
@@ -380,12 +367,7 @@ impl<'a> StringReader<'a> {
380
367
}
381
368
rustc_lexer:: LiteralKind :: Float { base, empty_exponent } => {
382
369
if empty_exponent {
383
- let mut err = self . struct_span_fatal (
384
- start,
385
- self . pos ,
386
- "expected at least one digit in exponent" ,
387
- ) ;
388
- err. emit ( ) ;
370
+ self . err_span_ ( start, self . pos , "expected at least one digit in exponent" ) ;
389
371
}
390
372
391
373
match base {
@@ -475,8 +457,7 @@ impl<'a> StringReader<'a> {
475
457
self . struct_fatal_span_char (
476
458
start,
477
459
self . pos ,
478
- "found invalid character; only `#` is allowed \
479
- in raw string delimitation",
460
+ "found invalid character; only `#` is allowed in raw string delimitation" ,
480
461
bad_char,
481
462
)
482
463
. emit ( ) ;
0 commit comments