@@ -49,13 +49,12 @@ impl<'a> StringReader<'a> {
4949 // Make sure external source is loaded first, before accessing it.
5050 // While this can't show up during normal parsing, `retokenize` may
5151 // 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 ) ) ;
5353
54- // FIXME(eddyb) use `Lrc<str>` or similar to avoid cloning the `String`.
5554 let src = if let Some ( src) = & source_file. src {
56- src . clone ( )
55+ Lrc :: clone ( & src )
5756 } else if let Some ( src) = source_file. external_src . borrow ( ) . get_source ( ) {
58- src . clone ( )
57+ Lrc :: clone ( & src )
5958 } else {
6059 sess. span_diagnostic
6160 . bug ( & format ! ( "cannot lex `source_file` without source: {}" , source_file. name) ) ;
@@ -125,10 +124,7 @@ impl<'a> StringReader<'a> {
125124
126125 debug ! ( "try_next_token: {:?}({:?})" , token. kind, self . str_from( start) ) ;
127126
128- // This could use `?`, but that makes code significantly (10-20%) slower.
129- // https://github.com/rust-lang/rust/issues/37939
130127 let kind = self . cook_lexer_token ( token. kind , start) ;
131-
132128 let span = self . mk_sp ( start, self . pos ) ;
133129 Token :: new ( kind, span)
134130 }
@@ -153,15 +149,6 @@ impl<'a> StringReader<'a> {
153149 self . err_span ( self . mk_sp ( from_pos, to_pos) , m)
154150 }
155151
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-
165152 fn struct_fatal_span_char (
166153 & self ,
167154 from_pos : BytePos ,
@@ -380,12 +367,7 @@ impl<'a> StringReader<'a> {
380367 }
381368 rustc_lexer:: LiteralKind :: Float { base, empty_exponent } => {
382369 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" ) ;
389371 }
390372
391373 match base {
@@ -475,8 +457,7 @@ impl<'a> StringReader<'a> {
475457 self . struct_fatal_span_char (
476458 start,
477459 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" ,
480461 bad_char,
481462 )
482463 . emit ( ) ;
0 commit comments