1- use crate :: ast;
21use crate :: parse:: ParseSess ;
32use crate :: parse:: token:: { self , Token , TokenKind } ;
43use crate :: symbol:: { sym, Symbol } ;
@@ -328,14 +327,14 @@ impl<'a> StringReader<'a> {
328327 self . str_from_to ( start, self . pos )
329328 }
330329
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 {
333332 debug ! ( "taking an ident from {:?} to {:?}" , start, self . pos) ;
334333 Symbol :: intern ( self . str_from ( start) )
335334 }
336335
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 {
339338 debug ! ( "taking an ident from {:?} to {:?}" , start, end) ;
340339 Symbol :: intern ( self . str_from_to ( start, end) )
341340 }
@@ -440,7 +439,7 @@ impl<'a> StringReader<'a> {
440439 }
441440
442441 /// 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 > {
444443 if !ident_start ( self . ch ) {
445444 return None ;
446445 }
@@ -508,7 +507,7 @@ impl<'a> StringReader<'a> {
508507 }
509508
510509 let kind = if doc_comment {
511- token:: DocComment ( self . name_from ( start_bpos) )
510+ token:: DocComment ( self . symbol_from ( start_bpos) )
512511 } else {
513512 token:: Comment
514513 } ;
@@ -537,7 +536,7 @@ impl<'a> StringReader<'a> {
537536 self . bump ( ) ;
538537 }
539538 return Some ( Token :: new (
540- token:: Shebang ( self . name_from ( start) ) ,
539+ token:: Shebang ( self . symbol_from ( start) ) ,
541540 self . mk_sp ( start, self . pos ) ,
542541 ) ) ;
543542 }
@@ -719,17 +718,17 @@ impl<'a> StringReader<'a> {
719718 let pos = self . pos ;
720719 self . check_float_base ( start_bpos, pos, base) ;
721720
722- ( token:: Float , self . name_from ( start_bpos) )
721+ ( token:: Float , self . symbol_from ( start_bpos) )
723722 } else {
724723 // it might be a float if it has an exponent
725724 if self . ch_is ( 'e' ) || self . ch_is ( 'E' ) {
726725 self . scan_float_exponent ( ) ;
727726 let pos = self . pos ;
728727 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) ) ;
730729 }
731730 // but we certainly have an integer!
732- ( token:: Integer , self . name_from ( start_bpos) )
731+ ( token:: Integer , self . symbol_from ( start_bpos) )
733732 }
734733 }
735734
@@ -831,7 +830,7 @@ impl<'a> StringReader<'a> {
831830 }
832831
833832 // FIXME: perform NFKC normalization here. (Issue #2253)
834- let name = self . name_from ( start) ;
833+ let name = self . symbol_from ( start) ;
835834 if is_raw_ident {
836835 let span = self . mk_sp ( raw_start, self . pos ) ;
837836 if !name. can_be_raw ( ) {
@@ -1006,7 +1005,7 @@ impl<'a> StringReader<'a> {
10061005 // lifetimes shouldn't end with a single quote
10071006 // if we find one, then this is an invalid character literal
10081007 if self . ch_is ( '\'' ) {
1009- let symbol = self . name_from ( start) ;
1008+ let symbol = self . symbol_from ( start) ;
10101009 self . bump ( ) ;
10111010 self . validate_char_escape ( start_with_quote) ;
10121011 return Ok ( TokenKind :: lit ( token:: Char , symbol, None ) ) ;
@@ -1024,7 +1023,7 @@ impl<'a> StringReader<'a> {
10241023 // Include the leading `'` in the real identifier, for macro
10251024 // expansion purposes. See #12512 for the gory details of why
10261025 // 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) ) ) ;
10281027 }
10291028 let msg = "unterminated character literal" ;
10301029 let symbol = self . scan_single_quoted_string ( start_with_quote, msg) ;
@@ -1052,7 +1051,7 @@ impl<'a> StringReader<'a> {
10521051 } ,
10531052 Some ( 'r' ) => {
10541053 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) ;
10561055 self . validate_raw_byte_str_escape ( start, end) ;
10571056
10581057 ( token:: ByteStrRaw ( hash_count) , symbol)
@@ -1073,7 +1072,7 @@ impl<'a> StringReader<'a> {
10731072 }
10741073 'r' => {
10751074 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) ;
10771076 self . validate_raw_str_escape ( start, end) ;
10781077 let suffix = self . scan_optional_raw_name ( ) ;
10791078
@@ -1174,7 +1173,7 @@ impl<'a> StringReader<'a> {
11741173
11751174 fn scan_single_quoted_string ( & mut self ,
11761175 start_with_quote : BytePos ,
1177- unterminated_msg : & str ) -> ast :: Name {
1176+ unterminated_msg : & str ) -> Symbol {
11781177 // assumes that first `'` is consumed
11791178 let start = self . pos ;
11801179 // lex `'''` as a single char, for recovery
@@ -1206,12 +1205,12 @@ impl<'a> StringReader<'a> {
12061205 }
12071206 }
12081207
1209- let id = self . name_from ( start) ;
1208+ let id = self . symbol_from ( start) ;
12101209 self . bump ( ) ;
12111210 id
12121211 }
12131212
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 {
12151214 debug_assert ! ( self . ch_is( '\"' ) ) ;
12161215 let start_with_quote = self . pos ;
12171216 self . bump ( ) ;
@@ -1226,7 +1225,7 @@ impl<'a> StringReader<'a> {
12261225 }
12271226 self . bump ( ) ;
12281227 }
1229- let id = self . name_from ( start) ;
1228+ let id = self . symbol_from ( start) ;
12301229 self . bump ( ) ;
12311230 id
12321231 }
0 commit comments