@@ -592,7 +592,7 @@ pub fn integer_lit(s: &str,
592592
593593 let mut base = 10 ;
594594 let orig = s;
595- let mut ty = ast:: UnsuffixedIntLit ( ast :: Plus ) ;
595+ let mut ty = ast:: UnsuffixedIntLit ;
596596
597597 if char_at ( s, 0 ) == '0' && s. len ( ) > 1 {
598598 match char_at ( s, 1 ) {
@@ -624,11 +624,11 @@ pub fn integer_lit(s: &str,
624624 if let Some ( ref suf) = suffix {
625625 if suf. is_empty ( ) { sd. span_bug ( sp, "found empty literal suffix in Some" ) }
626626 ty = match & * * suf {
627- "isize" => ast:: SignedIntLit ( ast:: TyIs , ast :: Plus ) ,
628- "i8" => ast:: SignedIntLit ( ast:: TyI8 , ast :: Plus ) ,
629- "i16" => ast:: SignedIntLit ( ast:: TyI16 , ast :: Plus ) ,
630- "i32" => ast:: SignedIntLit ( ast:: TyI32 , ast :: Plus ) ,
631- "i64" => ast:: SignedIntLit ( ast:: TyI64 , ast :: Plus ) ,
627+ "isize" => ast:: SignedIntLit ( ast:: TyIs ) ,
628+ "i8" => ast:: SignedIntLit ( ast:: TyI8 ) ,
629+ "i16" => ast:: SignedIntLit ( ast:: TyI16 ) ,
630+ "i32" => ast:: SignedIntLit ( ast:: TyI32 ) ,
631+ "i64" => ast:: SignedIntLit ( ast:: TyI64 ) ,
632632 "usize" => ast:: UnsignedIntLit ( ast:: TyUs ) ,
633633 "u8" => ast:: UnsignedIntLit ( ast:: TyU8 ) ,
634634 "u16" => ast:: UnsignedIntLit ( ast:: TyU16 ) ,
@@ -657,9 +657,9 @@ pub fn integer_lit(s: &str,
657657 debug ! ( "integer_lit: the type is {:?}, base {:?}, the new string is {:?}, the original \
658658 string was {:?}, the original suffix was {:?}", ty, base, s, orig, suffix) ;
659659
660- let res = match u64:: from_str_radix ( s, base) . ok ( ) {
661- Some ( r) => r ,
662- None => {
660+ match u64:: from_str_radix ( s, base) {
661+ Ok ( r) => ast :: LitInt ( r , ty ) ,
662+ Err ( _ ) => {
663663 // small bases are lexed as if they were base 10, e.g, the string
664664 // might be `0b10201`. This will cause the conversion above to fail,
665665 // but these cases have errors in the lexer: we don't want to emit
@@ -671,16 +671,8 @@ pub fn integer_lit(s: &str,
671671 if !already_errored {
672672 sd. span_err ( sp, "int literal is too large" ) ;
673673 }
674- 0
674+ ast :: LitInt ( 0 , ty )
675675 }
676- } ;
677-
678- // adjust the sign
679- let sign = ast:: Sign :: new ( res) ;
680- match ty {
681- ast:: SignedIntLit ( t, _) => ast:: LitInt ( res, ast:: SignedIntLit ( t, sign) ) ,
682- ast:: UnsuffixedIntLit ( _) => ast:: LitInt ( res, ast:: UnsuffixedIntLit ( sign) ) ,
683- us@ast:: UnsignedIntLit ( _) => ast:: LitInt ( res, us)
684676 }
685677}
686678
0 commit comments