@@ -545,34 +545,34 @@ pub enum UintTy { U8, U16, U32, U64 }
545545
546546impl IntTy {
547547 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 {
549549 tcx. sess . target . int_type
550550 } else {
551551 t
552552 } ;
553553 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 ,
559559 }
560560 }
561561}
562562
563563impl UintTy {
564564 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 {
566566 tcx. sess . target . uint_type
567567 } else {
568568 t
569569 } ;
570570 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 ,
576576 }
577577 }
578578}
@@ -1289,65 +1289,63 @@ fn cast_const<'tcx>(tcx: &ty::ctxt<'tcx>, val: ConstVal, ty: Ty) -> CastResult {
12891289
12901290 // Issue #23890: If isize/usize, then dispatch to appropriate target representation type
12911291 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" ) ,
12951295
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" ) ,
12991299
13001300 _ => { }
13011301 }
13021302
13031303 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 ! ( ) ,
13061306
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 ) ,
13111311
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 ) ,
13161316
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 ) ,
13191319 _ => Err ( ErrKind :: CannotCast ) ,
13201320 }
13211321}
13221322
13231323fn lit_to_const ( sess : & Session , span : Span , lit : & ast:: Lit , ty_hint : Option < Ty > ) -> ConstVal {
13241324 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) => {
13271327 ByteStr ( data. clone ( ) )
13281328 }
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 ) => {
13331333 match ty_hint. map ( |ty| & ty. sty ) {
13341334 Some ( & ty:: TyUint ( _) ) => Uint ( n) ,
13351335 _ => Int ( n as i64 )
13361336 }
13371337 }
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) => {
13431341 if let Ok ( x) = n. parse :: < f64 > ( ) {
13441342 Float ( x)
13451343 } else {
13461344 // FIXME(#31407) this is only necessary because float parsing is buggy
13471345 sess. span_bug ( span, "could not evaluate float literal (see issue #31407)" ) ;
13481346 }
13491347 }
1350- ast:: LitBool ( b) => Bool ( b)
1348+ ast:: LitKind :: Bool ( b) => Bool ( b)
13511349 }
13521350}
13531351
0 commit comments