@@ -16,7 +16,7 @@ use rustc_infer::infer::InferCtxt;
16
16
use rustc_middle:: mir:: abstract_const:: { Node , NodeId , NotConstEvaluatable } ;
17
17
use rustc_middle:: mir:: interpret:: ErrorHandled ;
18
18
use rustc_middle:: mir:: { self , Rvalue , StatementKind , TerminatorKind } ;
19
- use rustc_middle:: ty:: subst:: { GenericArg , Subst , SubstsRef } ;
19
+ use rustc_middle:: ty:: subst:: { Subst , SubstsRef } ;
20
20
use rustc_middle:: ty:: { self , TyCtxt , TypeFoldable } ;
21
21
use rustc_session:: lint;
22
22
use rustc_span:: def_id:: LocalDefId ;
@@ -80,7 +80,7 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
80
80
Concrete ,
81
81
}
82
82
let mut failure_kind = FailureKind :: Concrete ;
83
- walk_abstract_const :: < !, _ > ( tcx, ct, |node| match node. root ( tcx, ct . substs ) {
83
+ walk_abstract_const :: < !, _ > ( tcx, ct, |node| match node. root ( tcx) {
84
84
Node :: Leaf ( leaf) => {
85
85
if leaf. has_infer_types_or_consts ( ) {
86
86
failure_kind = FailureKind :: MentionsInfer ;
@@ -185,8 +185,8 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
185
185
pub struct AbstractConst < ' tcx > {
186
186
// FIXME: Consider adding something like `IndexSlice`
187
187
// and use this here.
188
- pub inner : & ' tcx [ Node < ' tcx > ] ,
189
- pub substs : SubstsRef < ' tcx > ,
188
+ inner : & ' tcx [ Node < ' tcx > ] ,
189
+ substs : SubstsRef < ' tcx > ,
190
190
}
191
191
192
192
impl < ' tcx > AbstractConst < ' tcx > {
@@ -216,10 +216,10 @@ impl<'tcx> AbstractConst<'tcx> {
216
216
}
217
217
218
218
#[ inline]
219
- pub fn root ( self , tcx : TyCtxt < ' tcx > , substs : & [ GenericArg < ' tcx > ] ) -> Node < ' tcx > {
220
- let mut node = self . inner . last ( ) . copied ( ) . unwrap ( ) ;
219
+ pub fn root ( self , tcx : TyCtxt < ' tcx > ) -> Node < ' tcx > {
220
+ let node = self . inner . last ( ) . copied ( ) . unwrap ( ) ;
221
221
if let Node :: Leaf ( leaf) = node {
222
- node = Node :: Leaf ( leaf. subst ( tcx, substs) ) ;
222
+ return Node :: Leaf ( leaf. subst ( tcx, self . substs ) ) ;
223
223
}
224
224
node
225
225
}
@@ -589,7 +589,7 @@ where
589
589
f : & mut dyn FnMut ( AbstractConst < ' tcx > ) -> ControlFlow < R > ,
590
590
) -> ControlFlow < R > {
591
591
f ( ct) ?;
592
- let root = ct. root ( tcx, ct . substs ) ;
592
+ let root = ct. root ( tcx) ;
593
593
match root {
594
594
Node :: Leaf ( _) => ControlFlow :: CONTINUE ,
595
595
Node :: Binop ( _, l, r) => {
@@ -617,22 +617,22 @@ pub(super) fn try_unify<'tcx>(
617
617
// We substitute generics repeatedly to allow AbstractConsts to unify where a
618
618
// ConstKind::Unevalated could be turned into an AbstractConst that would unify e.g.
619
619
// Param(N) should unify with Param(T), substs: [Unevaluated("T2", [Unevaluated("T3", [Param(N)])])]
620
- while let Node :: Leaf ( a_ct) = a. root ( tcx, a . substs ) {
620
+ while let Node :: Leaf ( a_ct) = a. root ( tcx) {
621
621
match AbstractConst :: from_const ( tcx, a_ct) {
622
622
Ok ( Some ( a_act) ) => a = a_act,
623
623
Ok ( None ) => break ,
624
624
Err ( _) => return true ,
625
625
}
626
626
}
627
- while let Node :: Leaf ( b_ct) = b. root ( tcx, b . substs ) {
627
+ while let Node :: Leaf ( b_ct) = b. root ( tcx) {
628
628
match AbstractConst :: from_const ( tcx, b_ct) {
629
629
Ok ( Some ( b_act) ) => b = b_act,
630
630
Ok ( None ) => break ,
631
631
Err ( _) => return true ,
632
632
}
633
633
}
634
634
635
- match ( a. root ( tcx, a . substs ) , b. root ( tcx, b . substs ) ) {
635
+ match ( a. root ( tcx) , b. root ( tcx) ) {
636
636
( Node :: Leaf ( a_ct) , Node :: Leaf ( b_ct) ) => {
637
637
if a_ct. ty != b_ct. ty {
638
638
return false ;
0 commit comments