@@ -123,12 +123,12 @@ impl Hash for Constant {
123
123
}
124
124
125
125
impl Constant {
126
- pub fn partial_cmp ( tcx : TyCtxt < ' _ , ' _ , ' _ > , cmp_type : & ty:: TypeVariants < ' _ > , left : & Self , right : & Self ) -> Option < Ordering > {
126
+ pub fn partial_cmp ( tcx : TyCtxt < ' _ , ' _ , ' _ > , cmp_type : & ty:: TyKind < ' _ > , left : & Self , right : & Self ) -> Option < Ordering > {
127
127
match ( left, right) {
128
128
( & Constant :: Str ( ref ls) , & Constant :: Str ( ref rs) ) => Some ( ls. cmp ( rs) ) ,
129
129
( & Constant :: Char ( ref l) , & Constant :: Char ( ref r) ) => Some ( l. cmp ( r) ) ,
130
130
( & Constant :: Int ( l) , & Constant :: Int ( r) ) => {
131
- if let ty:: TyInt ( int_ty) = * cmp_type {
131
+ if let ty:: Int ( int_ty) = * cmp_type {
132
132
Some ( sext ( tcx, l, int_ty) . cmp ( & sext ( tcx, r, int_ty) ) )
133
133
} else {
134
134
Some ( l. cmp ( & r) )
@@ -166,8 +166,8 @@ pub fn lit_to_constant<'tcx>(lit: &LitKind, ty: Ty<'tcx>) -> Constant {
166
166
LitKind :: Int ( n, _) => Constant :: Int ( n) ,
167
167
LitKind :: Float ( ref is, _) |
168
168
LitKind :: FloatUnsuffixed ( ref is) => match ty. sty {
169
- ty:: TyFloat ( FloatTy :: F32 ) => Constant :: F32 ( is. as_str ( ) . parse ( ) . unwrap ( ) ) ,
170
- ty:: TyFloat ( FloatTy :: F64 ) => Constant :: F64 ( is. as_str ( ) . parse ( ) . unwrap ( ) ) ,
169
+ ty:: Float ( FloatTy :: F32 ) => Constant :: F32 ( is. as_str ( ) . parse ( ) . unwrap ( ) ) ,
170
+ ty:: Float ( FloatTy :: F64 ) => Constant :: F64 ( is. as_str ( ) . parse ( ) . unwrap ( ) ) ,
171
171
_ => bug ! ( ) ,
172
172
} ,
173
173
LitKind :: Bool ( b) => Constant :: Bool ( b) ,
@@ -220,7 +220,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
220
220
ExprKind :: Tup ( ref tup) => self . multi ( tup) . map ( Constant :: Tuple ) ,
221
221
ExprKind :: Repeat ( ref value, _) => {
222
222
let n = match self . tables . expr_ty ( e) . sty {
223
- ty:: TyArray ( _, n) => n. assert_usize ( self . tcx ) . expect ( "array length" ) ,
223
+ ty:: Array ( _, n) => n. assert_usize ( self . tcx ) . expect ( "array length" ) ,
224
224
_ => span_bug ! ( e. span, "typeck error" ) ,
225
225
} ;
226
226
self . expr ( value) . map ( |v| Constant :: Repeat ( Box :: new ( v) , n as u64 ) )
@@ -243,8 +243,8 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
243
243
Int ( value) => {
244
244
let value = !value;
245
245
match ty. sty {
246
- ty:: TyInt ( ity) => Some ( Int ( unsext ( self . tcx , value as i128 , ity) ) ) ,
247
- ty:: TyUint ( ity) => Some ( Int ( clip ( self . tcx , value, ity) ) ) ,
246
+ ty:: Int ( ity) => Some ( Int ( unsext ( self . tcx , value as i128 , ity) ) ) ,
247
+ ty:: Uint ( ity) => Some ( Int ( clip ( self . tcx , value, ity) ) ) ,
248
248
_ => None ,
249
249
}
250
250
} ,
@@ -257,7 +257,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
257
257
match * o {
258
258
Int ( value) => {
259
259
let ity = match ty. sty {
260
- ty:: TyInt ( ity) => ity,
260
+ ty:: Int ( ity) => ity,
261
261
_ => return None ,
262
262
} ;
263
263
// sign extend
@@ -336,7 +336,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
336
336
match ( l, r) {
337
337
( Constant :: Int ( l) , Some ( Constant :: Int ( r) ) ) => {
338
338
match self . tables . expr_ty ( left) . sty {
339
- ty:: TyInt ( ity) => {
339
+ ty:: Int ( ity) => {
340
340
let l = sext ( self . tcx , l, ity) ;
341
341
let r = sext ( self . tcx , r, ity) ;
342
342
let zext = |n : i128 | Constant :: Int ( unsext ( self . tcx , n, ity) ) ;
@@ -360,7 +360,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
360
360
_ => None ,
361
361
}
362
362
}
363
- ty:: TyUint ( _) => {
363
+ ty:: Uint ( _) => {
364
364
match op. node {
365
365
BinOpKind :: Add => l. checked_add ( r) . map ( Constant :: Int ) ,
366
366
BinOpKind :: Sub => l. checked_sub ( r) . map ( Constant :: Int ) ,
@@ -429,18 +429,18 @@ pub fn miri_to_const<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, result: &ty::Const<'
429
429
use rustc:: mir:: interpret:: { Scalar , ScalarMaybeUndef , ConstValue } ;
430
430
match result. val {
431
431
ConstValue :: Scalar ( Scalar :: Bits { bits : b, ..} ) => match result. ty . sty {
432
- ty:: TyBool => Some ( Constant :: Bool ( b == 1 ) ) ,
433
- ty:: TyUint ( _) | ty:: TyInt ( _) => Some ( Constant :: Int ( b) ) ,
434
- ty:: TyFloat ( FloatTy :: F32 ) => Some ( Constant :: F32 ( f32:: from_bits ( b as u32 ) ) ) ,
435
- ty:: TyFloat ( FloatTy :: F64 ) => Some ( Constant :: F64 ( f64:: from_bits ( b as u64 ) ) ) ,
432
+ ty:: Bool => Some ( Constant :: Bool ( b == 1 ) ) ,
433
+ ty:: Uint ( _) | ty:: Int ( _) => Some ( Constant :: Int ( b) ) ,
434
+ ty:: Float ( FloatTy :: F32 ) => Some ( Constant :: F32 ( f32:: from_bits ( b as u32 ) ) ) ,
435
+ ty:: Float ( FloatTy :: F64 ) => Some ( Constant :: F64 ( f64:: from_bits ( b as u64 ) ) ) ,
436
436
// FIXME: implement other conversion
437
437
_ => None ,
438
438
} ,
439
439
ConstValue :: ScalarPair ( Scalar :: Ptr ( ptr) ,
440
440
ScalarMaybeUndef :: Scalar (
441
441
Scalar :: Bits { bits : n, .. } ) ) => match result. ty . sty {
442
- ty:: TyRef ( _, tam, _) => match tam. sty {
443
- ty:: TyStr => {
442
+ ty:: Ref ( _, tam, _) => match tam. sty {
443
+ ty:: Str => {
444
444
let alloc = tcx
445
445
. alloc_map
446
446
. lock ( )
0 commit comments