@@ -123,7 +123,7 @@ impl Constant {
123
123
( & Self :: Str ( ref ls) , & Self :: Str ( ref rs) ) => Some ( ls. cmp ( rs) ) ,
124
124
( & Self :: Char ( ref l) , & Self :: Char ( ref r) ) => Some ( l. cmp ( r) ) ,
125
125
( & Self :: Int ( l) , & Self :: Int ( r) ) => {
126
- if let ty:: Int ( int_ty) = cmp_type. kind {
126
+ if let ty:: Int ( int_ty) = * cmp_type. kind ( ) {
127
127
Some ( sext ( tcx, l, int_ty) . cmp ( & sext ( tcx, r, int_ty) ) )
128
128
} else {
129
129
Some ( l. cmp ( & r) )
@@ -162,7 +162,7 @@ pub fn lit_to_constant(lit: &LitKind, ty: Option<Ty<'_>>) -> Constant {
162
162
FloatTy :: F32 => Constant :: F32 ( is. as_str ( ) . parse ( ) . unwrap ( ) ) ,
163
163
FloatTy :: F64 => Constant :: F64 ( is. as_str ( ) . parse ( ) . unwrap ( ) ) ,
164
164
} ,
165
- LitKind :: Float ( ref is, LitFloatType :: Unsuffixed ) => match ty. expect ( "type of float is known" ) . kind {
165
+ LitKind :: Float ( ref is, LitFloatType :: Unsuffixed ) => match ty. expect ( "type of float is known" ) . kind ( ) {
166
166
ty:: Float ( FloatTy :: F32 ) => Constant :: F32 ( is. as_str ( ) . parse ( ) . unwrap ( ) ) ,
167
167
ty:: Float ( FloatTy :: F64 ) => Constant :: F64 ( is. as_str ( ) . parse ( ) . unwrap ( ) ) ,
168
168
_ => bug ! ( ) ,
@@ -230,7 +230,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
230
230
ExprKind :: Array ( ref vec) => self . multi ( vec) . map ( Constant :: Vec ) ,
231
231
ExprKind :: Tup ( ref tup) => self . multi ( tup) . map ( Constant :: Tuple ) ,
232
232
ExprKind :: Repeat ( ref value, _) => {
233
- let n = match self . typeck_results . expr_ty ( e) . kind {
233
+ let n = match self . typeck_results . expr_ty ( e) . kind ( ) {
234
234
ty:: Array ( _, n) => n. try_eval_usize ( self . lcx . tcx , self . lcx . param_env ) ?,
235
235
_ => span_bug ! ( e. span, "typeck error" ) ,
236
236
} ;
@@ -281,7 +281,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
281
281
Bool ( b) => Some ( Bool ( !b) ) ,
282
282
Int ( value) => {
283
283
let value = !value;
284
- match ty. kind {
284
+ match * ty. kind ( ) {
285
285
ty:: Int ( ity) => Some ( Int ( unsext ( self . lcx . tcx , value as i128 , ity) ) ) ,
286
286
ty:: Uint ( ity) => Some ( Int ( clip ( self . lcx . tcx , value, ity) ) ) ,
287
287
_ => None ,
@@ -295,7 +295,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
295
295
use self :: Constant :: { Int , F32 , F64 } ;
296
296
match * o {
297
297
Int ( value) => {
298
- let ity = match ty. kind {
298
+ let ity = match * ty. kind ( ) {
299
299
ty:: Int ( ity) => ity,
300
300
_ => return None ,
301
301
} ;
@@ -402,7 +402,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
402
402
let l = self . expr ( left) ?;
403
403
let r = self . expr ( right) ;
404
404
match ( l, r) {
405
- ( Constant :: Int ( l) , Some ( Constant :: Int ( r) ) ) => match self . typeck_results . expr_ty_opt ( left) ?. kind {
405
+ ( Constant :: Int ( l) , Some ( Constant :: Int ( r) ) ) => match * self . typeck_results . expr_ty_opt ( left) ?. kind ( ) {
406
406
ty:: Int ( ity) => {
407
407
let l = sext ( self . lcx . tcx , l, ity) ;
408
408
let r = sext ( self . lcx . tcx , r, ity) ;
@@ -495,7 +495,7 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
495
495
use rustc_middle:: mir:: interpret:: { ConstValue , Scalar } ;
496
496
match result. val {
497
497
ty:: ConstKind :: Value ( ConstValue :: Scalar ( Scalar :: Raw { data : d, .. } ) ) => {
498
- match result. ty . kind {
498
+ match result. ty . kind ( ) {
499
499
ty:: Bool => Some ( Constant :: Bool ( d == 1 ) ) ,
500
500
ty:: Uint ( _) | ty:: Int ( _) => Some ( Constant :: Int ( d) ) ,
501
501
ty:: Float ( FloatTy :: F32 ) => Some ( Constant :: F32 ( f32:: from_bits (
@@ -505,7 +505,7 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
505
505
d. try_into ( ) . expect ( "invalid f64 bit representation" ) ,
506
506
) ) ) ,
507
507
ty:: RawPtr ( type_and_mut) => {
508
- if let ty:: Uint ( _) = type_and_mut. ty . kind {
508
+ if let ty:: Uint ( _) = type_and_mut. ty . kind ( ) {
509
509
return Some ( Constant :: RawPtr ( d) ) ;
510
510
}
511
511
None
@@ -514,8 +514,8 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
514
514
_ => None ,
515
515
}
516
516
} ,
517
- ty:: ConstKind :: Value ( ConstValue :: Slice { data, start, end } ) => match result. ty . kind {
518
- ty:: Ref ( _, tam, _) => match tam. kind {
517
+ ty:: ConstKind :: Value ( ConstValue :: Slice { data, start, end } ) => match result. ty . kind ( ) {
518
+ ty:: Ref ( _, tam, _) => match tam. kind ( ) {
519
519
ty:: Str => String :: from_utf8 (
520
520
data. inspect_with_uninit_and_ptr_outside_interpreter ( start..end)
521
521
. to_owned ( ) ,
@@ -526,8 +526,8 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
526
526
} ,
527
527
_ => None ,
528
528
} ,
529
- ty:: ConstKind :: Value ( ConstValue :: ByRef { alloc, offset : _ } ) => match result. ty . kind {
530
- ty:: Array ( sub_type, len) => match sub_type. kind {
529
+ ty:: ConstKind :: Value ( ConstValue :: ByRef { alloc, offset : _ } ) => match result. ty . kind ( ) {
530
+ ty:: Array ( sub_type, len) => match sub_type. kind ( ) {
531
531
ty:: Float ( FloatTy :: F32 ) => match miri_to_const ( len) {
532
532
Some ( Constant :: Int ( len) ) => alloc
533
533
. inspect_with_uninit_and_ptr_outside_interpreter ( 0 ..( 4 * len as usize ) )
0 commit comments