@@ -168,25 +168,25 @@ fn lint_overflowing_range_endpoint<'tcx>(
168
168
169
169
// For `isize` & `usize`, be conservative with the warnings, so that the
170
170
// 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 ) {
172
172
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 ) ,
179
179
}
180
180
}
181
181
182
- fn uint_ty_range ( uint_ty : ast :: UintTy ) -> ( u128 , u128 ) {
182
+ fn uint_ty_range ( uint_ty : ty :: UintTy ) -> ( u128 , u128 ) {
183
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 ,
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 ,
190
190
} ;
191
191
( 0 , max)
192
192
}
@@ -258,8 +258,8 @@ fn report_bin_hex_error(
258
258
//
259
259
// No suggestion for: `isize`, `usize`.
260
260
fn 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 :: * ;
263
263
macro_rules! find_fit {
264
264
( $ty: expr, $val: expr, $negative: expr,
265
265
$( $type: ident => [ $( $utypes: expr) ,* ] => [ $( $itypes: expr) ,* ] ) ,+) => {
@@ -302,7 +302,7 @@ fn lint_int_literal<'tcx>(
302
302
type_limits : & TypeLimits ,
303
303
e : & ' tcx hir:: Expr < ' tcx > ,
304
304
lit : & hir:: Lit ,
305
- t : ast :: IntTy ,
305
+ t : ty :: IntTy ,
306
306
v : u128 ,
307
307
) {
308
308
let int_type = t. normalize ( cx. sess ( ) . target . pointer_width ) ;
@@ -314,7 +314,14 @@ fn lint_int_literal<'tcx>(
314
314
// avoiding use of -min to prevent overflow/panic
315
315
if ( negative && v > max + 1 ) || ( !negative && v > max) {
316
316
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
+ ) ;
318
325
return ;
319
326
}
320
327
@@ -351,7 +358,7 @@ fn lint_uint_literal<'tcx>(
351
358
cx : & LateContext < ' tcx > ,
352
359
e : & ' tcx hir:: Expr < ' tcx > ,
353
360
lit : & hir:: Lit ,
354
- t : ast :: UintTy ,
361
+ t : ty :: UintTy ,
355
362
) {
356
363
let uint_type = t. normalize ( cx. sess ( ) . target . pointer_width ) ;
357
364
let ( min, max) = uint_ty_range ( uint_type) ;
@@ -391,7 +398,14 @@ fn lint_uint_literal<'tcx>(
391
398
}
392
399
}
393
400
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
+ ) ;
395
409
return ;
396
410
}
397
411
cx. struct_span_lint ( OVERFLOWING_LITERALS , e. span , |lint| {
@@ -430,8 +444,8 @@ fn lint_literal<'tcx>(
430
444
ty:: Float ( t) => {
431
445
let is_infinite = match lit. node {
432
446
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) ,
435
449
} ,
436
450
_ => bug ! ( ) ,
437
451
} ;
@@ -984,7 +998,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
984
998
help : Some ( "consider using `u32` or `libc::wchar_t` instead" . into ( ) ) ,
985
999
} ,
986
1000
987
- ty:: Int ( ast :: IntTy :: I128 ) | ty:: Uint ( ast :: UintTy :: U128 ) => FfiUnsafe {
1001
+ ty:: Int ( ty :: IntTy :: I128 ) | ty:: Uint ( ty :: UintTy :: U128 ) => FfiUnsafe {
988
1002
ty,
989
1003
reason : "128-bit integers don't currently have a known stable ABI" . into ( ) ,
990
1004
help : None ,
0 commit comments