@@ -145,9 +145,9 @@ fn lint_overflowing_range_endpoint<'tcx>(
145145 // We need to preserve the literal's suffix,
146146 // as it may determine typing information.
147147 let suffix = match lit. node {
148- LitKind :: Int ( _, LitIntType :: Signed ( s) ) => s. name_str ( ) . to_string ( ) ,
149- LitKind :: Int ( _, LitIntType :: Unsigned ( s) ) => s. name_str ( ) . to_string ( ) ,
150- LitKind :: Int ( _, LitIntType :: Unsuffixed ) => "" . to_string ( ) ,
148+ LitKind :: Int ( _, LitIntType :: Signed ( s) ) => s. name_str ( ) ,
149+ LitKind :: Int ( _, LitIntType :: Unsigned ( s) ) => s. name_str ( ) ,
150+ LitKind :: Int ( _, LitIntType :: Unsuffixed ) => "" ,
151151 _ => bug ! ( ) ,
152152 } ;
153153 let suggestion = format ! ( "{}..={}{}" , start, lit_val - 1 , suffix) ;
@@ -170,24 +170,25 @@ fn lint_overflowing_range_endpoint<'tcx>(
170170// warnings are consistent between 32- and 64-bit platforms.
171171fn int_ty_range ( int_ty : ast:: IntTy ) -> ( i128 , i128 ) {
172172 match int_ty {
173- ast:: IntTy :: Isize => ( i64:: MIN as i128 , i64:: MAX as i128 ) ,
174- ast:: IntTy :: I8 => ( i8:: MIN as i64 as i128 , i8:: MAX as i128 ) ,
175- ast:: IntTy :: I16 => ( i16:: MIN as i64 as i128 , i16:: MAX as i128 ) ,
176- ast:: IntTy :: I32 => ( i32:: MIN as i64 as i128 , i32:: MAX as i128 ) ,
177- ast:: IntTy :: I64 => ( i64:: MIN as i128 , i64:: MAX as i128 ) ,
178- ast:: IntTy :: I128 => ( i128:: MIN as i128 , i128:: MAX ) ,
173+ ast:: IntTy :: Isize => ( i64:: MIN . into ( ) , i64:: MAX . into ( ) ) ,
174+ ast:: IntTy :: I8 => ( i8:: MIN . into ( ) , i8:: MAX . into ( ) ) ,
175+ ast:: IntTy :: I16 => ( i16:: MIN . into ( ) , i16:: MAX . into ( ) ) ,
176+ ast:: IntTy :: I32 => ( i32:: MIN . into ( ) , i32:: MAX . into ( ) ) ,
177+ ast:: IntTy :: I64 => ( i64:: MIN . into ( ) , i64:: MAX . into ( ) ) ,
178+ ast:: IntTy :: I128 => ( i128:: MIN , i128:: MAX ) ,
179179 }
180180}
181181
182182fn uint_ty_range ( uint_ty : ast:: UintTy ) -> ( u128 , u128 ) {
183- match uint_ty {
184- ast:: UintTy :: Usize => ( u64:: MIN as u128 , u64:: MAX as u128 ) ,
185- ast:: UintTy :: U8 => ( u8:: MIN as u128 , u8:: MAX as u128 ) ,
186- ast:: UintTy :: U16 => ( u16:: MIN as u128 , u16:: MAX as u128 ) ,
187- ast:: UintTy :: U32 => ( u32:: MIN as u128 , u32:: MAX as u128 ) ,
188- ast:: UintTy :: U64 => ( u64:: MIN as u128 , u64:: MAX as u128 ) ,
189- ast:: UintTy :: U128 => ( u128:: MIN , u128:: MAX ) ,
190- }
183+ let max = match uint_ty {
184+ ast:: UintTy :: Usize => u64:: MAX . into ( ) ,
185+ ast:: UintTy :: U8 => u8:: MAX . into ( ) ,
186+ ast:: UintTy :: U16 => u16:: MAX . into ( ) ,
187+ ast:: UintTy :: U32 => u32:: MAX . into ( ) ,
188+ ast:: UintTy :: U64 => u64:: MAX . into ( ) ,
189+ ast:: UintTy :: U128 => u128:: MAX ,
190+ } ;
191+ ( 0 , max)
191192}
192193
193194fn get_bin_hex_repr ( cx : & LateContext < ' _ > , lit : & hir:: Lit ) -> Option < String > {
0 commit comments