@@ -216,18 +216,18 @@ impl<'a> StringReader<'a> {
216
216
self . with_str_from_to ( start, self . last_pos , f)
217
217
}
218
218
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
220
220
/// adjusted 1 towards each other (assumes that on either side there is a
221
221
/// single-byte delimiter).
222
- pub fn ident_from ( & self , start : BytePos ) -> ast:: Ident {
222
+ pub fn name_from ( & self , start : BytePos ) -> ast:: Name {
223
223
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 )
225
225
}
226
226
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 {
229
229
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 )
231
231
}
232
232
233
233
/// Calls `f` with a string slice of the source text spanning from `start`
@@ -377,7 +377,7 @@ impl<'a> StringReader<'a> {
377
377
return self . with_str_from ( start_bpos, |string| {
378
378
// but comments with only more "/"s are not
379
379
let tok = if is_doc_comment ( string) {
380
- token:: DOC_COMMENT ( str_to_ident ( string) )
380
+ token:: DOC_COMMENT ( token :: intern ( string) )
381
381
} else {
382
382
token:: COMMENT
383
383
} ;
@@ -421,7 +421,7 @@ impl<'a> StringReader<'a> {
421
421
let start = self . last_pos ;
422
422
while !self . curr_is ( '\n' ) && !self . is_eof ( ) { self . bump ( ) ; }
423
423
return Some ( TokenAndSpan {
424
- tok : token:: SHEBANG ( self . ident_from ( start) ) ,
424
+ tok : token:: SHEBANG ( self . name_from ( start) ) ,
425
425
sp : codemap:: mk_sp ( start, self . last_pos )
426
426
} ) ;
427
427
}
@@ -500,7 +500,7 @@ impl<'a> StringReader<'a> {
500
500
self . translate_crlf ( start_bpos, string,
501
501
"bare CR not allowed in block doc-comment" )
502
502
} else { string. into_maybe_owned ( ) } ;
503
- token:: DOC_COMMENT ( str_to_ident ( string. as_slice ( ) ) )
503
+ token:: DOC_COMMENT ( token :: intern ( string. as_slice ( ) ) )
504
504
} else {
505
505
token:: COMMENT
506
506
} ;
@@ -548,17 +548,17 @@ impl<'a> StringReader<'a> {
548
548
}
549
549
'u' | 'i' => {
550
550
self . scan_int_suffix ( ) ;
551
- return token:: LIT_INTEGER ( self . ident_from ( start_bpos) ) ;
551
+ return token:: LIT_INTEGER ( self . name_from ( start_bpos) ) ;
552
552
} ,
553
553
'f' => {
554
554
let last_pos = self . last_pos ;
555
555
self . scan_float_suffix ( ) ;
556
556
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) ) ;
558
558
}
559
559
_ => {
560
560
// just a 0
561
- return token:: LIT_INTEGER ( self . ident_from ( start_bpos) ) ;
561
+ return token:: LIT_INTEGER ( self . name_from ( start_bpos) ) ;
562
562
}
563
563
}
564
564
} else if c. is_digit_radix ( 10 ) {
@@ -571,7 +571,7 @@ impl<'a> StringReader<'a> {
571
571
self . err_span_ ( start_bpos, self . last_pos , "no valid digits found for number" ) ;
572
572
// eat any suffix
573
573
self . scan_int_suffix ( ) ;
574
- return token:: LIT_INTEGER ( str_to_ident ( "0" ) ) ;
574
+ return token:: LIT_INTEGER ( token :: intern ( "0" ) ) ;
575
575
}
576
576
577
577
// might be a float, but don't be greedy if this is actually an
@@ -589,25 +589,25 @@ impl<'a> StringReader<'a> {
589
589
}
590
590
let last_pos = self . last_pos ;
591
591
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) ) ;
593
593
} else if self . curr_is ( 'f' ) {
594
594
// or it might be an integer literal suffixed as a float
595
595
self . scan_float_suffix ( ) ;
596
596
let last_pos = self . last_pos ;
597
597
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) ) ;
599
599
} else {
600
600
// it might be a float if it has an exponent
601
601
if self . curr_is ( 'e' ) || self . curr_is ( 'E' ) {
602
602
self . scan_float_exponent ( ) ;
603
603
self . scan_float_suffix ( ) ;
604
604
let last_pos = self . last_pos ;
605
605
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) ) ;
607
607
}
608
608
// but we certainly have an integer!
609
609
self . scan_int_suffix ( ) ;
610
- return token:: LIT_INTEGER ( self . ident_from ( start_bpos) ) ;
610
+ return token:: LIT_INTEGER ( self . name_from ( start_bpos) ) ;
611
611
}
612
612
}
613
613
@@ -980,7 +980,7 @@ impl<'a> StringReader<'a> {
980
980
start - BytePos ( 1 ) , last_bpos,
981
981
"unterminated character constant" . to_string ( ) ) ;
982
982
}
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" ) } ;
984
984
self . bump ( ) ; // advance curr past token
985
985
return token:: LIT_CHAR ( id) ;
986
986
}
@@ -1010,8 +1010,8 @@ impl<'a> StringReader<'a> {
1010
1010
valid &= self . scan_char_or_byte ( ch_start, ch, /* ascii_only = */ false , '"' ) ;
1011
1011
}
1012
1012
// 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 ( "??" ) } ;
1015
1015
self . bump ( ) ;
1016
1016
return token:: LIT_STR ( id) ;
1017
1017
}
@@ -1076,9 +1076,9 @@ impl<'a> StringReader<'a> {
1076
1076
}
1077
1077
self . bump ( ) ;
1078
1078
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)
1080
1080
} else {
1081
- str_to_ident ( "??" )
1081
+ token :: intern ( "??" )
1082
1082
} ;
1083
1083
return token:: LIT_STR_RAW ( id, hash_count) ;
1084
1084
}
@@ -1168,7 +1168,7 @@ impl<'a> StringReader<'a> {
1168
1168
"unterminated byte constant" . to_string ( ) ) ;
1169
1169
}
1170
1170
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 ( "??" ) } ;
1172
1172
self . bump ( ) ; // advance curr past token
1173
1173
return token:: LIT_BYTE ( id) ;
1174
1174
}
@@ -1190,7 +1190,7 @@ impl<'a> StringReader<'a> {
1190
1190
self . bump ( ) ;
1191
1191
valid &= self . scan_char_or_byte ( ch_start, ch, /* ascii_only = */ true , '"' ) ;
1192
1192
}
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 ( "??" ) } ;
1194
1194
self . bump ( ) ;
1195
1195
return token:: LIT_BINARY ( id) ;
1196
1196
}
@@ -1243,7 +1243,7 @@ impl<'a> StringReader<'a> {
1243
1243
self . bump ( ) ;
1244
1244
}
1245
1245
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) ,
1247
1247
hash_count) ;
1248
1248
}
1249
1249
}
0 commit comments