@@ -16,7 +16,7 @@ use rustc_infer::infer::InferCtxt;
1616use rustc_middle:: mir:: abstract_const:: { Node , NodeId , NotConstEvaluatable } ;
1717use rustc_middle:: mir:: interpret:: ErrorHandled ;
1818use rustc_middle:: mir:: { self , Rvalue , StatementKind , TerminatorKind } ;
19- use rustc_middle:: ty:: subst:: { GenericArg , Subst , SubstsRef } ;
19+ use rustc_middle:: ty:: subst:: { Subst , SubstsRef } ;
2020use rustc_middle:: ty:: { self , TyCtxt , TypeFoldable } ;
2121use rustc_session:: lint;
2222use rustc_span:: def_id:: LocalDefId ;
@@ -80,7 +80,7 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
8080 Concrete ,
8181 }
8282 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) {
8484 Node :: Leaf ( leaf) => {
8585 if leaf. has_infer_types_or_consts ( ) {
8686 failure_kind = FailureKind :: MentionsInfer ;
@@ -185,8 +185,8 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
185185pub struct AbstractConst < ' tcx > {
186186 // FIXME: Consider adding something like `IndexSlice`
187187 // and use this here.
188- pub inner : & ' tcx [ Node < ' tcx > ] ,
189- pub substs : SubstsRef < ' tcx > ,
188+ inner : & ' tcx [ Node < ' tcx > ] ,
189+ substs : SubstsRef < ' tcx > ,
190190}
191191
192192impl < ' tcx > AbstractConst < ' tcx > {
@@ -216,10 +216,10 @@ impl<'tcx> AbstractConst<'tcx> {
216216 }
217217
218218 #[ 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 ( ) ;
221221 if let Node :: Leaf ( leaf) = node {
222- node = Node :: Leaf ( leaf. subst ( tcx, substs) ) ;
222+ return Node :: Leaf ( leaf. subst ( tcx, self . substs ) ) ;
223223 }
224224 node
225225 }
@@ -589,7 +589,7 @@ where
589589 f : & mut dyn FnMut ( AbstractConst < ' tcx > ) -> ControlFlow < R > ,
590590 ) -> ControlFlow < R > {
591591 f ( ct) ?;
592- let root = ct. root ( tcx, ct . substs ) ;
592+ let root = ct. root ( tcx) ;
593593 match root {
594594 Node :: Leaf ( _) => ControlFlow :: CONTINUE ,
595595 Node :: Binop ( _, l, r) => {
@@ -617,22 +617,22 @@ pub(super) fn try_unify<'tcx>(
617617 // We substitute generics repeatedly to allow AbstractConsts to unify where a
618618 // ConstKind::Unevalated could be turned into an AbstractConst that would unify e.g.
619619 // 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) {
621621 match AbstractConst :: from_const ( tcx, a_ct) {
622622 Ok ( Some ( a_act) ) => a = a_act,
623623 Ok ( None ) => break ,
624624 Err ( _) => return true ,
625625 }
626626 }
627- while let Node :: Leaf ( b_ct) = b. root ( tcx, b . substs ) {
627+ while let Node :: Leaf ( b_ct) = b. root ( tcx) {
628628 match AbstractConst :: from_const ( tcx, b_ct) {
629629 Ok ( Some ( b_act) ) => b = b_act,
630630 Ok ( None ) => break ,
631631 Err ( _) => return true ,
632632 }
633633 }
634634
635- match ( a. root ( tcx, a . substs ) , b. root ( tcx, b . substs ) ) {
635+ match ( a. root ( tcx) , b. root ( tcx) ) {
636636 ( Node :: Leaf ( a_ct) , Node :: Leaf ( b_ct) ) => {
637637 if a_ct. ty != b_ct. ty {
638638 return false ;
0 commit comments