1
- use crate :: ast;
2
1
use crate :: parse:: ParseSess ;
3
2
use crate :: parse:: token:: { self , Token , TokenKind } ;
4
3
use crate :: symbol:: { sym, Symbol } ;
@@ -328,14 +327,14 @@ impl<'a> StringReader<'a> {
328
327
self . str_from_to ( start, self . pos )
329
328
}
330
329
331
- /// Creates a Name from a given offset to the current offset.
332
- fn name_from ( & self , start : BytePos ) -> ast :: Name {
330
+ /// Creates a Symbol from a given offset to the current offset.
331
+ fn symbol_from ( & self , start : BytePos ) -> Symbol {
333
332
debug ! ( "taking an ident from {:?} to {:?}" , start, self . pos) ;
334
333
Symbol :: intern ( self . str_from ( start) )
335
334
}
336
335
337
- /// As name_from , with an explicit endpoint.
338
- fn name_from_to ( & self , start : BytePos , end : BytePos ) -> ast :: Name {
336
+ /// As symbol_from , with an explicit endpoint.
337
+ fn symbol_from_to ( & self , start : BytePos , end : BytePos ) -> Symbol {
339
338
debug ! ( "taking an ident from {:?} to {:?}" , start, end) ;
340
339
Symbol :: intern ( self . str_from_to ( start, end) )
341
340
}
@@ -440,7 +439,7 @@ impl<'a> StringReader<'a> {
440
439
}
441
440
442
441
/// Eats <XID_start><XID_continue>*, if possible.
443
- fn scan_optional_raw_name ( & mut self ) -> Option < ast :: Name > {
442
+ fn scan_optional_raw_name ( & mut self ) -> Option < Symbol > {
444
443
if !ident_start ( self . ch ) {
445
444
return None ;
446
445
}
@@ -508,7 +507,7 @@ impl<'a> StringReader<'a> {
508
507
}
509
508
510
509
let kind = if doc_comment {
511
- token:: DocComment ( self . name_from ( start_bpos) )
510
+ token:: DocComment ( self . symbol_from ( start_bpos) )
512
511
} else {
513
512
token:: Comment
514
513
} ;
@@ -537,7 +536,7 @@ impl<'a> StringReader<'a> {
537
536
self . bump ( ) ;
538
537
}
539
538
return Some ( Token :: new (
540
- token:: Shebang ( self . name_from ( start) ) ,
539
+ token:: Shebang ( self . symbol_from ( start) ) ,
541
540
self . mk_sp ( start, self . pos ) ,
542
541
) ) ;
543
542
}
@@ -719,17 +718,17 @@ impl<'a> StringReader<'a> {
719
718
let pos = self . pos ;
720
719
self . check_float_base ( start_bpos, pos, base) ;
721
720
722
- ( token:: Float , self . name_from ( start_bpos) )
721
+ ( token:: Float , self . symbol_from ( start_bpos) )
723
722
} else {
724
723
// it might be a float if it has an exponent
725
724
if self . ch_is ( 'e' ) || self . ch_is ( 'E' ) {
726
725
self . scan_float_exponent ( ) ;
727
726
let pos = self . pos ;
728
727
self . check_float_base ( start_bpos, pos, base) ;
729
- return ( token:: Float , self . name_from ( start_bpos) ) ;
728
+ return ( token:: Float , self . symbol_from ( start_bpos) ) ;
730
729
}
731
730
// but we certainly have an integer!
732
- ( token:: Integer , self . name_from ( start_bpos) )
731
+ ( token:: Integer , self . symbol_from ( start_bpos) )
733
732
}
734
733
}
735
734
@@ -831,7 +830,7 @@ impl<'a> StringReader<'a> {
831
830
}
832
831
833
832
// FIXME: perform NFKC normalization here. (Issue #2253)
834
- let name = self . name_from ( start) ;
833
+ let name = self . symbol_from ( start) ;
835
834
if is_raw_ident {
836
835
let span = self . mk_sp ( raw_start, self . pos ) ;
837
836
if !name. can_be_raw ( ) {
@@ -1006,7 +1005,7 @@ impl<'a> StringReader<'a> {
1006
1005
// lifetimes shouldn't end with a single quote
1007
1006
// if we find one, then this is an invalid character literal
1008
1007
if self . ch_is ( '\'' ) {
1009
- let symbol = self . name_from ( start) ;
1008
+ let symbol = self . symbol_from ( start) ;
1010
1009
self . bump ( ) ;
1011
1010
self . validate_char_escape ( start_with_quote) ;
1012
1011
return Ok ( TokenKind :: lit ( token:: Char , symbol, None ) ) ;
@@ -1024,7 +1023,7 @@ impl<'a> StringReader<'a> {
1024
1023
// Include the leading `'` in the real identifier, for macro
1025
1024
// expansion purposes. See #12512 for the gory details of why
1026
1025
// this is necessary.
1027
- return Ok ( token:: Lifetime ( self . name_from ( start_with_quote) ) ) ;
1026
+ return Ok ( token:: Lifetime ( self . symbol_from ( start_with_quote) ) ) ;
1028
1027
}
1029
1028
let msg = "unterminated character literal" ;
1030
1029
let symbol = self . scan_single_quoted_string ( start_with_quote, msg) ;
@@ -1052,7 +1051,7 @@ impl<'a> StringReader<'a> {
1052
1051
} ,
1053
1052
Some ( 'r' ) => {
1054
1053
let ( start, end, hash_count) = self . scan_raw_string ( ) ;
1055
- let symbol = self . name_from_to ( start, end) ;
1054
+ let symbol = self . symbol_from_to ( start, end) ;
1056
1055
self . validate_raw_byte_str_escape ( start, end) ;
1057
1056
1058
1057
( token:: ByteStrRaw ( hash_count) , symbol)
@@ -1073,7 +1072,7 @@ impl<'a> StringReader<'a> {
1073
1072
}
1074
1073
'r' => {
1075
1074
let ( start, end, hash_count) = self . scan_raw_string ( ) ;
1076
- let symbol = self . name_from_to ( start, end) ;
1075
+ let symbol = self . symbol_from_to ( start, end) ;
1077
1076
self . validate_raw_str_escape ( start, end) ;
1078
1077
let suffix = self . scan_optional_raw_name ( ) ;
1079
1078
@@ -1174,7 +1173,7 @@ impl<'a> StringReader<'a> {
1174
1173
1175
1174
fn scan_single_quoted_string ( & mut self ,
1176
1175
start_with_quote : BytePos ,
1177
- unterminated_msg : & str ) -> ast :: Name {
1176
+ unterminated_msg : & str ) -> Symbol {
1178
1177
// assumes that first `'` is consumed
1179
1178
let start = self . pos ;
1180
1179
// lex `'''` as a single char, for recovery
@@ -1206,12 +1205,12 @@ impl<'a> StringReader<'a> {
1206
1205
}
1207
1206
}
1208
1207
1209
- let id = self . name_from ( start) ;
1208
+ let id = self . symbol_from ( start) ;
1210
1209
self . bump ( ) ;
1211
1210
id
1212
1211
}
1213
1212
1214
- fn scan_double_quoted_string ( & mut self , unterminated_msg : & str ) -> ast :: Name {
1213
+ fn scan_double_quoted_string ( & mut self , unterminated_msg : & str ) -> Symbol {
1215
1214
debug_assert ! ( self . ch_is( '\"' ) ) ;
1216
1215
let start_with_quote = self . pos ;
1217
1216
self . bump ( ) ;
@@ -1226,7 +1225,7 @@ impl<'a> StringReader<'a> {
1226
1225
}
1227
1226
self . bump ( ) ;
1228
1227
}
1229
- let id = self . name_from ( start) ;
1228
+ let id = self . symbol_from ( start) ;
1230
1229
self . bump ( ) ;
1231
1230
id
1232
1231
}
0 commit comments