@@ -168,25 +168,25 @@ fn lint_overflowing_range_endpoint<'tcx>(
168168
169169// For `isize` & `usize`, be conservative with the warnings, so that the
170170// warnings are consistent between 32- and 64-bit platforms.
171- fn int_ty_range ( int_ty : ast :: IntTy ) -> ( i128 , i128 ) {
171+ fn int_ty_range ( int_ty : ty :: IntTy ) -> ( i128 , i128 ) {
172172 match int_ty {
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 ) ,
173+ ty :: IntTy :: Isize => ( i64:: MIN . into ( ) , i64:: MAX . into ( ) ) ,
174+ ty :: IntTy :: I8 => ( i8:: MIN . into ( ) , i8:: MAX . into ( ) ) ,
175+ ty :: IntTy :: I16 => ( i16:: MIN . into ( ) , i16:: MAX . into ( ) ) ,
176+ ty :: IntTy :: I32 => ( i32:: MIN . into ( ) , i32:: MAX . into ( ) ) ,
177+ ty :: IntTy :: I64 => ( i64:: MIN . into ( ) , i64:: MAX . into ( ) ) ,
178+ ty :: IntTy :: I128 => ( i128:: MIN , i128:: MAX ) ,
179179 }
180180}
181181
182- fn uint_ty_range ( uint_ty : ast :: UintTy ) -> ( u128 , u128 ) {
182+ fn uint_ty_range ( uint_ty : ty :: UintTy ) -> ( u128 , u128 ) {
183183 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 ,
184+ ty :: UintTy :: Usize => u64:: MAX . into ( ) ,
185+ ty :: UintTy :: U8 => u8:: MAX . into ( ) ,
186+ ty :: UintTy :: U16 => u16:: MAX . into ( ) ,
187+ ty :: UintTy :: U32 => u32:: MAX . into ( ) ,
188+ ty :: UintTy :: U64 => u64:: MAX . into ( ) ,
189+ ty :: UintTy :: U128 => u128:: MAX ,
190190 } ;
191191 ( 0 , max)
192192}
@@ -258,8 +258,8 @@ fn report_bin_hex_error(
258258//
259259// No suggestion for: `isize`, `usize`.
260260fn get_type_suggestion ( t : Ty < ' _ > , val : u128 , negative : bool ) -> Option < & ' static str > {
261- use rustc_ast :: IntTy :: * ;
262- use rustc_ast :: UintTy :: * ;
261+ use ty :: IntTy :: * ;
262+ use ty :: UintTy :: * ;
263263 macro_rules! find_fit {
264264 ( $ty: expr, $val: expr, $negative: expr,
265265 $( $type: ident => [ $( $utypes: expr) ,* ] => [ $( $itypes: expr) ,* ] ) ,+) => {
@@ -302,7 +302,7 @@ fn lint_int_literal<'tcx>(
302302 type_limits : & TypeLimits ,
303303 e : & ' tcx hir:: Expr < ' tcx > ,
304304 lit : & hir:: Lit ,
305- t : ast :: IntTy ,
305+ t : ty :: IntTy ,
306306 v : u128 ,
307307) {
308308 let int_type = t. normalize ( cx. sess ( ) . target . pointer_width ) ;
@@ -314,7 +314,14 @@ fn lint_int_literal<'tcx>(
314314 // avoiding use of -min to prevent overflow/panic
315315 if ( negative && v > max + 1 ) || ( !negative && v > max) {
316316 if let Some ( repr_str) = get_bin_hex_repr ( cx, lit) {
317- report_bin_hex_error ( cx, e, attr:: IntType :: SignedInt ( t) , repr_str, v, negative) ;
317+ report_bin_hex_error (
318+ cx,
319+ e,
320+ attr:: IntType :: SignedInt ( ty:: ast_int_ty ( t) ) ,
321+ repr_str,
322+ v,
323+ negative,
324+ ) ;
318325 return ;
319326 }
320327
@@ -351,7 +358,7 @@ fn lint_uint_literal<'tcx>(
351358 cx : & LateContext < ' tcx > ,
352359 e : & ' tcx hir:: Expr < ' tcx > ,
353360 lit : & hir:: Lit ,
354- t : ast :: UintTy ,
361+ t : ty :: UintTy ,
355362) {
356363 let uint_type = t. normalize ( cx. sess ( ) . target . pointer_width ) ;
357364 let ( min, max) = uint_ty_range ( uint_type) ;
@@ -391,7 +398,14 @@ fn lint_uint_literal<'tcx>(
391398 }
392399 }
393400 if let Some ( repr_str) = get_bin_hex_repr ( cx, lit) {
394- report_bin_hex_error ( cx, e, attr:: IntType :: UnsignedInt ( t) , repr_str, lit_val, false ) ;
401+ report_bin_hex_error (
402+ cx,
403+ e,
404+ attr:: IntType :: UnsignedInt ( ty:: ast_uint_ty ( t) ) ,
405+ repr_str,
406+ lit_val,
407+ false ,
408+ ) ;
395409 return ;
396410 }
397411 cx. struct_span_lint ( OVERFLOWING_LITERALS , e. span , |lint| {
@@ -430,8 +444,8 @@ fn lint_literal<'tcx>(
430444 ty:: Float ( t) => {
431445 let is_infinite = match lit. node {
432446 ast:: LitKind :: Float ( v, _) => match t {
433- ast :: FloatTy :: F32 => v. as_str ( ) . parse ( ) . map ( f32:: is_infinite) ,
434- ast :: FloatTy :: F64 => v. as_str ( ) . parse ( ) . map ( f64:: is_infinite) ,
447+ ty :: FloatTy :: F32 => v. as_str ( ) . parse ( ) . map ( f32:: is_infinite) ,
448+ ty :: FloatTy :: F64 => v. as_str ( ) . parse ( ) . map ( f64:: is_infinite) ,
435449 } ,
436450 _ => bug ! ( ) ,
437451 } ;
@@ -984,7 +998,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
984998 help : Some ( "consider using `u32` or `libc::wchar_t` instead" . into ( ) ) ,
985999 } ,
9861000
987- ty:: Int ( ast :: IntTy :: I128 ) | ty:: Uint ( ast :: UintTy :: U128 ) => FfiUnsafe {
1001+ ty:: Int ( ty :: IntTy :: I128 ) | ty:: Uint ( ty :: UintTy :: U128 ) => FfiUnsafe {
9881002 ty,
9891003 reason : "128-bit integers don't currently have a known stable ABI" . into ( ) ,
9901004 help : None ,
0 commit comments