@@ -592,7 +592,7 @@ pub fn integer_lit(s: &str,
592
592
593
593
let mut base = 10 ;
594
594
let orig = s;
595
- let mut ty = ast:: UnsuffixedIntLit ( ast :: Plus ) ;
595
+ let mut ty = ast:: UnsuffixedIntLit ;
596
596
597
597
if char_at ( s, 0 ) == '0' && s. len ( ) > 1 {
598
598
match char_at ( s, 1 ) {
@@ -624,11 +624,11 @@ pub fn integer_lit(s: &str,
624
624
if let Some ( ref suf) = suffix {
625
625
if suf. is_empty ( ) { sd. span_bug ( sp, "found empty literal suffix in Some" ) }
626
626
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 ) ,
632
632
"usize" => ast:: UnsignedIntLit ( ast:: TyUs ) ,
633
633
"u8" => ast:: UnsignedIntLit ( ast:: TyU8 ) ,
634
634
"u16" => ast:: UnsignedIntLit ( ast:: TyU16 ) ,
@@ -657,9 +657,9 @@ pub fn integer_lit(s: &str,
657
657
debug ! ( "integer_lit: the type is {:?}, base {:?}, the new string is {:?}, the original \
658
658
string was {:?}, the original suffix was {:?}", ty, base, s, orig, suffix) ;
659
659
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 ( _ ) => {
663
663
// small bases are lexed as if they were base 10, e.g, the string
664
664
// might be `0b10201`. This will cause the conversion above to fail,
665
665
// but these cases have errors in the lexer: we don't want to emit
@@ -671,16 +671,8 @@ pub fn integer_lit(s: &str,
671
671
if !already_errored {
672
672
sd. span_err ( sp, "int literal is too large" ) ;
673
673
}
674
- 0
674
+ ast :: LitInt ( 0 , ty )
675
675
}
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)
684
676
}
685
677
}
686
678
0 commit comments