@@ -545,34 +545,34 @@ pub enum UintTy { U8, U16, U32, U64 }
545
545
546
546
impl IntTy {
547
547
pub fn from ( tcx : & ty:: ctxt , t : ast:: IntTy ) -> IntTy {
548
- let t = if let ast:: TyIs = t {
548
+ let t = if let ast:: IntTy :: Is = t {
549
549
tcx. sess . target . int_type
550
550
} else {
551
551
t
552
552
} ;
553
553
match t {
554
- ast:: TyIs => unreachable ! ( ) ,
555
- ast:: TyI8 => IntTy :: I8 ,
556
- ast:: TyI16 => IntTy :: I16 ,
557
- ast:: TyI32 => IntTy :: I32 ,
558
- ast:: TyI64 => IntTy :: I64 ,
554
+ ast:: IntTy :: Is => unreachable ! ( ) ,
555
+ ast:: IntTy :: I8 => IntTy :: I8 ,
556
+ ast:: IntTy :: I16 => IntTy :: I16 ,
557
+ ast:: IntTy :: I32 => IntTy :: I32 ,
558
+ ast:: IntTy :: I64 => IntTy :: I64 ,
559
559
}
560
560
}
561
561
}
562
562
563
563
impl UintTy {
564
564
pub fn from ( tcx : & ty:: ctxt , t : ast:: UintTy ) -> UintTy {
565
- let t = if let ast:: TyUs = t {
565
+ let t = if let ast:: UintTy :: Us = t {
566
566
tcx. sess . target . uint_type
567
567
} else {
568
568
t
569
569
} ;
570
570
match t {
571
- ast:: TyUs => unreachable ! ( ) ,
572
- ast:: TyU8 => UintTy :: U8 ,
573
- ast:: TyU16 => UintTy :: U16 ,
574
- ast:: TyU32 => UintTy :: U32 ,
575
- ast:: TyU64 => UintTy :: U64 ,
571
+ ast:: UintTy :: Us => unreachable ! ( ) ,
572
+ ast:: UintTy :: U8 => UintTy :: U8 ,
573
+ ast:: UintTy :: U16 => UintTy :: U16 ,
574
+ ast:: UintTy :: U32 => UintTy :: U32 ,
575
+ ast:: UintTy :: U64 => UintTy :: U64 ,
576
576
}
577
577
}
578
578
}
@@ -1289,65 +1289,63 @@ fn cast_const<'tcx>(tcx: &ty::ctxt<'tcx>, val: ConstVal, ty: Ty) -> CastResult {
1289
1289
1290
1290
// Issue #23890: If isize/usize, then dispatch to appropriate target representation type
1291
1291
match ( & ty. sty , tcx. sess . target . int_type , tcx. sess . target . uint_type ) {
1292
- ( & ty:: TyInt ( ast:: TyIs ) , ast:: TyI32 , _) => return convert_val ! ( i32 , Int , i64 ) ,
1293
- ( & ty:: TyInt ( ast:: TyIs ) , ast:: TyI64 , _) => return convert_val ! ( i64 , Int , i64 ) ,
1294
- ( & ty:: TyInt ( ast:: TyIs ) , _, _) => panic ! ( "unexpected target.int_type" ) ,
1292
+ ( & ty:: TyInt ( ast:: IntTy :: Is ) , ast:: IntTy :: I32 , _) => return convert_val ! ( i32 , Int , i64 ) ,
1293
+ ( & ty:: TyInt ( ast:: IntTy :: Is ) , ast:: IntTy :: I64 , _) => return convert_val ! ( i64 , Int , i64 ) ,
1294
+ ( & ty:: TyInt ( ast:: IntTy :: Is ) , _, _) => panic ! ( "unexpected target.int_type" ) ,
1295
1295
1296
- ( & ty:: TyUint ( ast:: TyUs ) , _, ast:: TyU32 ) => return convert_val ! ( u32 , Uint , u64 ) ,
1297
- ( & ty:: TyUint ( ast:: TyUs ) , _, ast:: TyU64 ) => return convert_val ! ( u64 , Uint , u64 ) ,
1298
- ( & ty:: TyUint ( ast:: TyUs ) , _, _) => panic ! ( "unexpected target.uint_type" ) ,
1296
+ ( & ty:: TyUint ( ast:: UintTy :: Us ) , _, ast:: UintTy :: U32 ) => return convert_val ! ( u32 , Uint , u64 ) ,
1297
+ ( & ty:: TyUint ( ast:: UintTy :: Us ) , _, ast:: UintTy :: U64 ) => return convert_val ! ( u64 , Uint , u64 ) ,
1298
+ ( & ty:: TyUint ( ast:: UintTy :: Us ) , _, _) => panic ! ( "unexpected target.uint_type" ) ,
1299
1299
1300
1300
_ => { }
1301
1301
}
1302
1302
1303
1303
match ty. sty {
1304
- ty:: TyInt ( ast:: TyIs ) => unreachable ! ( ) ,
1305
- ty:: TyUint ( ast:: TyUs ) => unreachable ! ( ) ,
1304
+ ty:: TyInt ( ast:: IntTy :: Is ) => unreachable ! ( ) ,
1305
+ ty:: TyUint ( ast:: UintTy :: Us ) => unreachable ! ( ) ,
1306
1306
1307
- ty:: TyInt ( ast:: TyI8 ) => convert_val ! ( i8 , Int , i64 ) ,
1308
- ty:: TyInt ( ast:: TyI16 ) => convert_val ! ( i16 , Int , i64 ) ,
1309
- ty:: TyInt ( ast:: TyI32 ) => convert_val ! ( i32 , Int , i64 ) ,
1310
- ty:: TyInt ( ast:: TyI64 ) => convert_val ! ( i64 , Int , i64 ) ,
1307
+ ty:: TyInt ( ast:: IntTy :: I8 ) => convert_val ! ( i8 , Int , i64 ) ,
1308
+ ty:: TyInt ( ast:: IntTy :: I16 ) => convert_val ! ( i16 , Int , i64 ) ,
1309
+ ty:: TyInt ( ast:: IntTy :: I32 ) => convert_val ! ( i32 , Int , i64 ) ,
1310
+ ty:: TyInt ( ast:: IntTy :: I64 ) => convert_val ! ( i64 , Int , i64 ) ,
1311
1311
1312
- ty:: TyUint ( ast:: TyU8 ) => convert_val ! ( u8 , Uint , u64 ) ,
1313
- ty:: TyUint ( ast:: TyU16 ) => convert_val ! ( u16 , Uint , u64 ) ,
1314
- ty:: TyUint ( ast:: TyU32 ) => convert_val ! ( u32 , Uint , u64 ) ,
1315
- ty:: TyUint ( ast:: TyU64 ) => convert_val ! ( u64 , Uint , u64 ) ,
1312
+ ty:: TyUint ( ast:: UintTy :: U8 ) => convert_val ! ( u8 , Uint , u64 ) ,
1313
+ ty:: TyUint ( ast:: UintTy :: U16 ) => convert_val ! ( u16 , Uint , u64 ) ,
1314
+ ty:: TyUint ( ast:: UintTy :: U32 ) => convert_val ! ( u32 , Uint , u64 ) ,
1315
+ ty:: TyUint ( ast:: UintTy :: U64 ) => convert_val ! ( u64 , Uint , u64 ) ,
1316
1316
1317
- ty:: TyFloat ( ast:: TyF32 ) => convert_val ! ( f32 , Float , f64 ) ,
1318
- ty:: TyFloat ( ast:: TyF64 ) => convert_val ! ( f64 , Float , f64 ) ,
1317
+ ty:: TyFloat ( ast:: FloatTy :: F32 ) => convert_val ! ( f32 , Float , f64 ) ,
1318
+ ty:: TyFloat ( ast:: FloatTy :: F64 ) => convert_val ! ( f64 , Float , f64 ) ,
1319
1319
_ => Err ( ErrKind :: CannotCast ) ,
1320
1320
}
1321
1321
}
1322
1322
1323
1323
fn lit_to_const ( sess : & Session , span : Span , lit : & ast:: Lit , ty_hint : Option < Ty > ) -> ConstVal {
1324
1324
match lit. node {
1325
- ast:: LitStr ( ref s, _) => Str ( ( * s) . clone ( ) ) ,
1326
- ast:: LitByteStr ( ref data) => {
1325
+ ast:: LitKind :: Str ( ref s, _) => Str ( ( * s) . clone ( ) ) ,
1326
+ ast:: LitKind :: ByteStr ( ref data) => {
1327
1327
ByteStr ( data. clone ( ) )
1328
1328
}
1329
- ast:: LitByte ( n) => Uint ( n as u64 ) ,
1330
- ast:: LitChar ( n) => Uint ( n as u64 ) ,
1331
- ast:: LitInt ( n, ast:: SignedIntLit ( _ , ast :: Plus ) ) => Int ( n as i64 ) ,
1332
- ast:: LitInt ( n, ast:: UnsuffixedIntLit ( ast :: Plus ) ) => {
1329
+ ast:: LitKind :: Byte ( n) => Uint ( n as u64 ) ,
1330
+ ast:: LitKind :: Char ( n) => Uint ( n as u64 ) ,
1331
+ ast:: LitKind :: Int ( n, ast:: LitIntType :: Signed ( _ ) ) => Int ( n as i64 ) ,
1332
+ ast:: LitKind :: Int ( n, ast:: LitIntType :: Unsuffixed ) => {
1333
1333
match ty_hint. map ( |ty| & ty. sty ) {
1334
1334
Some ( & ty:: TyUint ( _) ) => Uint ( n) ,
1335
1335
_ => Int ( n as i64 )
1336
1336
}
1337
1337
}
1338
- ast:: LitInt ( n, ast:: SignedIntLit ( _, ast:: Minus ) ) |
1339
- ast:: LitInt ( n, ast:: UnsuffixedIntLit ( ast:: Minus ) ) => Int ( -( n as i64 ) ) ,
1340
- ast:: LitInt ( n, ast:: UnsignedIntLit ( _) ) => Uint ( n) ,
1341
- ast:: LitFloat ( ref n, _) |
1342
- ast:: LitFloatUnsuffixed ( ref n) => {
1338
+ ast:: LitKind :: Int ( n, ast:: LitIntType :: Unsigned ( _) ) => Uint ( n) ,
1339
+ ast:: LitKind :: Float ( ref n, _) |
1340
+ ast:: LitKind :: FloatUnsuffixed ( ref n) => {
1343
1341
if let Ok ( x) = n. parse :: < f64 > ( ) {
1344
1342
Float ( x)
1345
1343
} else {
1346
1344
// FIXME(#31407) this is only necessary because float parsing is buggy
1347
1345
sess. span_bug ( span, "could not evaluate float literal (see issue #31407)" ) ;
1348
1346
}
1349
1347
}
1350
- ast:: LitBool ( b) => Bool ( b)
1348
+ ast:: LitKind :: Bool ( b) => Bool ( b)
1351
1349
}
1352
1350
}
1353
1351
0 commit comments