@@ -437,7 +437,19 @@ impl<'a> StringReader<'a> {
437
437
. emit ( ) ;
438
438
( token:: Integer , sym:: integer ( 0 ) )
439
439
} else {
440
- self . validate_int_literal ( base, start, end) ;
440
+ if matches ! ( base, Base :: Binary | Base :: Octal ) {
441
+ let base = base as u32 ;
442
+ let s = self . str_from_to ( start + BytePos ( 2 ) , end) ;
443
+ for ( idx, c) in s. char_indices ( ) {
444
+ if c != '_' && c. to_digit ( base) . is_none ( ) {
445
+ self . err_span_ (
446
+ start + BytePos :: from_usize ( 2 + idx) ,
447
+ start + BytePos :: from_usize ( 2 + idx + c. len_utf8 ( ) ) ,
448
+ & format ! ( "invalid digit for a base {} literal" , base) ,
449
+ ) ;
450
+ }
451
+ }
452
+ }
441
453
( token:: Integer , self . symbol_from_to ( start, end) )
442
454
}
443
455
}
@@ -683,23 +695,6 @@ impl<'a> StringReader<'a> {
683
695
} ) ;
684
696
( kind, Symbol :: intern ( lit_content) )
685
697
}
686
-
687
- fn validate_int_literal ( & self , base : Base , content_start : BytePos , content_end : BytePos ) {
688
- let base = match base {
689
- Base :: Binary => 2 ,
690
- Base :: Octal => 8 ,
691
- _ => return ,
692
- } ;
693
- let s = self . str_from_to ( content_start + BytePos ( 2 ) , content_end) ;
694
- for ( idx, c) in s. char_indices ( ) {
695
- let idx = idx as u32 ;
696
- if c != '_' && c. to_digit ( base) . is_none ( ) {
697
- let lo = content_start + BytePos ( 2 + idx) ;
698
- let hi = content_start + BytePos ( 2 + idx + c. len_utf8 ( ) as u32 ) ;
699
- self . err_span_ ( lo, hi, & format ! ( "invalid digit for a base {} literal" , base) ) ;
700
- }
701
- }
702
- }
703
698
}
704
699
705
700
pub fn nfc_normalize ( string : & str ) -> Symbol {
0 commit comments