@@ -437,7 +437,19 @@ impl<'a> StringReader<'a> {
437437 . emit ( ) ;
438438 ( token:: Integer , sym:: integer ( 0 ) )
439439 } 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+ }
441453 ( token:: Integer , self . symbol_from_to ( start, end) )
442454 }
443455 }
@@ -683,23 +695,6 @@ impl<'a> StringReader<'a> {
683695 } ) ;
684696 ( kind, Symbol :: intern ( lit_content) )
685697 }
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- }
703698}
704699
705700pub fn nfc_normalize ( string : & str ) -> Symbol {
0 commit comments