@@ -15,7 +15,7 @@ use rustc_infer::infer::InferCtxt;
15
15
use rustc_middle:: mir;
16
16
use rustc_middle:: mir:: interpret:: ErrorHandled ;
17
17
use rustc_middle:: thir;
18
- use rustc_middle:: thir:: abstract_const:: { Node , NodeId , NotConstEvaluatable } ;
18
+ use rustc_middle:: thir:: abstract_const:: { self , Node , NodeId , NotConstEvaluatable } ;
19
19
use rustc_middle:: ty:: subst:: { Subst , SubstsRef } ;
20
20
use rustc_middle:: ty:: { self , TyCtxt , TypeFoldable } ;
21
21
use rustc_session:: lint;
@@ -91,7 +91,7 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
91
91
92
92
ControlFlow :: CONTINUE
93
93
}
94
- Node :: Cast ( _, ty) => {
94
+ Node :: Cast ( _, _ , ty) => {
95
95
let ty = ty. subst ( tcx, ct. substs ) ;
96
96
if ty. has_infer_types_or_consts ( ) {
97
97
failure_kind = FailureKind :: MentionsInfer ;
@@ -368,10 +368,13 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
368
368
// `ExprKind::Use` happens when a `hir::ExprKind::Cast` is a
369
369
// "coercion cast" i.e. using a coercion or is a no-op.
370
370
// This is important so that `N as usize as usize` doesnt unify with `N as usize`. (untested)
371
- & ExprKind :: Use { source}
372
- | & ExprKind :: Cast { source } => {
371
+ & ExprKind :: Use { source } => {
373
372
let arg = self . recurse_build ( source) ?;
374
- self . nodes . push ( Node :: Cast ( arg, node. ty ) )
373
+ self . nodes . push ( Node :: Cast ( abstract_const:: CastKind :: Use , arg, node. ty ) )
374
+ } ,
375
+ & ExprKind :: Cast { source } => {
376
+ let arg = self . recurse_build ( source) ?;
377
+ self . nodes . push ( Node :: Cast ( abstract_const:: CastKind :: As , arg, node. ty ) )
375
378
} ,
376
379
377
380
// FIXME(generic_const_exprs): We may want to support these.
@@ -494,7 +497,7 @@ where
494
497
recurse ( tcx, ct. subtree ( func) , f) ?;
495
498
args. iter ( ) . try_for_each ( |& arg| recurse ( tcx, ct. subtree ( arg) , f) )
496
499
}
497
- Node :: Cast ( operand, _) => recurse ( tcx, ct. subtree ( operand) , f) ,
500
+ Node :: Cast ( _ , operand, _) => recurse ( tcx, ct. subtree ( operand) , f) ,
498
501
}
499
502
}
500
503
@@ -577,7 +580,7 @@ pub(super) fn try_unify<'tcx>(
577
580
&& iter:: zip ( a_args, b_args)
578
581
. all ( |( & an, & bn) | try_unify ( tcx, a. subtree ( an) , b. subtree ( bn) ) )
579
582
}
580
- ( Node :: Cast ( a_operand, a_ty) , Node :: Cast ( b_operand, b_ty) ) if ( a_ty == b_ty) => {
583
+ ( Node :: Cast ( a_kind , a_operand, a_ty) , Node :: Cast ( b_kind , b_operand, b_ty) ) if ( a_ty == b_ty) && ( a_kind == b_kind ) => {
581
584
try_unify ( tcx, a. subtree ( a_operand) , b. subtree ( b_operand) )
582
585
}
583
586
// use this over `_ => false` to make adding variants to `Node` less error prone
0 commit comments