@@ -216,18 +216,18 @@ impl<'a> StringReader<'a> {
216216 self . with_str_from_to ( start, self . last_pos , f)
217217 }
218218
219- /// Create an Ident from a given offset to the current offset, each
219+ /// Create a Name from a given offset to the current offset, each
220220 /// adjusted 1 towards each other (assumes that on either side there is a
221221 /// single-byte delimiter).
222- pub fn ident_from ( & self , start : BytePos ) -> ast:: Ident {
222+ pub fn name_from ( & self , start : BytePos ) -> ast:: Name {
223223 debug ! ( "taking an ident from {} to {}" , start, self . last_pos) ;
224- self . with_str_from ( start, str_to_ident )
224+ self . with_str_from ( start, token :: intern )
225225 }
226226
227- /// As ident_from , with an explicit endpoint.
228- pub fn ident_from_to ( & self , start : BytePos , end : BytePos ) -> ast:: Ident {
227+ /// As name_from , with an explicit endpoint.
228+ pub fn name_from_to ( & self , start : BytePos , end : BytePos ) -> ast:: Name {
229229 debug ! ( "taking an ident from {} to {}" , start, end) ;
230- self . with_str_from_to ( start, end, str_to_ident )
230+ self . with_str_from_to ( start, end, token :: intern )
231231 }
232232
233233 /// Calls `f` with a string slice of the source text spanning from `start`
@@ -377,7 +377,7 @@ impl<'a> StringReader<'a> {
377377 return self . with_str_from ( start_bpos, |string| {
378378 // but comments with only more "/"s are not
379379 let tok = if is_doc_comment ( string) {
380- token:: DOC_COMMENT ( str_to_ident ( string) )
380+ token:: DOC_COMMENT ( token :: intern ( string) )
381381 } else {
382382 token:: COMMENT
383383 } ;
@@ -421,7 +421,7 @@ impl<'a> StringReader<'a> {
421421 let start = self . last_pos ;
422422 while !self . curr_is ( '\n' ) && !self . is_eof ( ) { self . bump ( ) ; }
423423 return Some ( TokenAndSpan {
424- tok : token:: SHEBANG ( self . ident_from ( start) ) ,
424+ tok : token:: SHEBANG ( self . name_from ( start) ) ,
425425 sp : codemap:: mk_sp ( start, self . last_pos )
426426 } ) ;
427427 }
@@ -500,7 +500,7 @@ impl<'a> StringReader<'a> {
500500 self . translate_crlf ( start_bpos, string,
501501 "bare CR not allowed in block doc-comment" )
502502 } else { string. into_maybe_owned ( ) } ;
503- token:: DOC_COMMENT ( str_to_ident ( string. as_slice ( ) ) )
503+ token:: DOC_COMMENT ( token :: intern ( string. as_slice ( ) ) )
504504 } else {
505505 token:: COMMENT
506506 } ;
@@ -548,17 +548,17 @@ impl<'a> StringReader<'a> {
548548 }
549549 'u' | 'i' => {
550550 self . scan_int_suffix ( ) ;
551- return token:: LIT_INTEGER ( self . ident_from ( start_bpos) ) ;
551+ return token:: LIT_INTEGER ( self . name_from ( start_bpos) ) ;
552552 } ,
553553 'f' => {
554554 let last_pos = self . last_pos ;
555555 self . scan_float_suffix ( ) ;
556556 self . check_float_base ( start_bpos, last_pos, base) ;
557- return token:: LIT_FLOAT ( self . ident_from ( start_bpos) ) ;
557+ return token:: LIT_FLOAT ( self . name_from ( start_bpos) ) ;
558558 }
559559 _ => {
560560 // just a 0
561- return token:: LIT_INTEGER ( self . ident_from ( start_bpos) ) ;
561+ return token:: LIT_INTEGER ( self . name_from ( start_bpos) ) ;
562562 }
563563 }
564564 } else if c. is_digit_radix ( 10 ) {
@@ -571,7 +571,7 @@ impl<'a> StringReader<'a> {
571571 self . err_span_ ( start_bpos, self . last_pos , "no valid digits found for number" ) ;
572572 // eat any suffix
573573 self . scan_int_suffix ( ) ;
574- return token:: LIT_INTEGER ( str_to_ident ( "0" ) ) ;
574+ return token:: LIT_INTEGER ( token :: intern ( "0" ) ) ;
575575 }
576576
577577 // might be a float, but don't be greedy if this is actually an
@@ -589,25 +589,25 @@ impl<'a> StringReader<'a> {
589589 }
590590 let last_pos = self . last_pos ;
591591 self . check_float_base ( start_bpos, last_pos, base) ;
592- return token:: LIT_FLOAT ( self . ident_from ( start_bpos) ) ;
592+ return token:: LIT_FLOAT ( self . name_from ( start_bpos) ) ;
593593 } else if self . curr_is ( 'f' ) {
594594 // or it might be an integer literal suffixed as a float
595595 self . scan_float_suffix ( ) ;
596596 let last_pos = self . last_pos ;
597597 self . check_float_base ( start_bpos, last_pos, base) ;
598- return token:: LIT_FLOAT ( self . ident_from ( start_bpos) ) ;
598+ return token:: LIT_FLOAT ( self . name_from ( start_bpos) ) ;
599599 } else {
600600 // it might be a float if it has an exponent
601601 if self . curr_is ( 'e' ) || self . curr_is ( 'E' ) {
602602 self . scan_float_exponent ( ) ;
603603 self . scan_float_suffix ( ) ;
604604 let last_pos = self . last_pos ;
605605 self . check_float_base ( start_bpos, last_pos, base) ;
606- return token:: LIT_FLOAT ( self . ident_from ( start_bpos) ) ;
606+ return token:: LIT_FLOAT ( self . name_from ( start_bpos) ) ;
607607 }
608608 // but we certainly have an integer!
609609 self . scan_int_suffix ( ) ;
610- return token:: LIT_INTEGER ( self . ident_from ( start_bpos) ) ;
610+ return token:: LIT_INTEGER ( self . name_from ( start_bpos) ) ;
611611 }
612612 }
613613
@@ -980,7 +980,7 @@ impl<'a> StringReader<'a> {
980980 start - BytePos ( 1 ) , last_bpos,
981981 "unterminated character constant" . to_string ( ) ) ;
982982 }
983- let id = if valid { self . ident_from ( start) } else { str_to_ident ( "0" ) } ;
983+ let id = if valid { self . name_from ( start) } else { token :: intern ( "0" ) } ;
984984 self . bump ( ) ; // advance curr past token
985985 return token:: LIT_CHAR ( id) ;
986986 }
@@ -1010,8 +1010,8 @@ impl<'a> StringReader<'a> {
10101010 valid &= self . scan_char_or_byte ( ch_start, ch, /* ascii_only = */ false , '"' ) ;
10111011 }
10121012 // adjust for the ACSII " at the start of the literal
1013- let id = if valid { self . ident_from ( start_bpos + BytePos ( 1 ) ) }
1014- else { str_to_ident ( "??" ) } ;
1013+ let id = if valid { self . name_from ( start_bpos + BytePos ( 1 ) ) }
1014+ else { token :: intern ( "??" ) } ;
10151015 self . bump ( ) ;
10161016 return token:: LIT_STR ( id) ;
10171017 }
@@ -1076,9 +1076,9 @@ impl<'a> StringReader<'a> {
10761076 }
10771077 self . bump ( ) ;
10781078 let id = if valid {
1079- self . ident_from_to ( content_start_bpos, content_end_bpos)
1079+ self . name_from_to ( content_start_bpos, content_end_bpos)
10801080 } else {
1081- str_to_ident ( "??" )
1081+ token :: intern ( "??" )
10821082 } ;
10831083 return token:: LIT_STR_RAW ( id, hash_count) ;
10841084 }
@@ -1168,7 +1168,7 @@ impl<'a> StringReader<'a> {
11681168 "unterminated byte constant" . to_string ( ) ) ;
11691169 }
11701170
1171- let id = if valid { self . ident_from ( start) } else { str_to_ident ( "??" ) } ;
1171+ let id = if valid { self . name_from ( start) } else { token :: intern ( "??" ) } ;
11721172 self . bump ( ) ; // advance curr past token
11731173 return token:: LIT_BYTE ( id) ;
11741174 }
@@ -1190,7 +1190,7 @@ impl<'a> StringReader<'a> {
11901190 self . bump ( ) ;
11911191 valid &= self . scan_char_or_byte ( ch_start, ch, /* ascii_only = */ true , '"' ) ;
11921192 }
1193- let id = if valid { self . ident_from ( start) } else { str_to_ident ( "??" ) } ;
1193+ let id = if valid { self . name_from ( start) } else { token :: intern ( "??" ) } ;
11941194 self . bump ( ) ;
11951195 return token:: LIT_BINARY ( id) ;
11961196 }
@@ -1243,7 +1243,7 @@ impl<'a> StringReader<'a> {
12431243 self . bump ( ) ;
12441244 }
12451245 self . bump ( ) ;
1246- return token:: LIT_BINARY_RAW ( self . ident_from_to ( content_start_bpos, content_end_bpos) ,
1246+ return token:: LIT_BINARY_RAW ( self . name_from_to ( content_start_bpos, content_end_bpos) ,
12471247 hash_count) ;
12481248 }
12491249}
0 commit comments