55
66use crate :: mir:: ProjectionKind ;
77use crate :: mir:: interpret:: ConstValue ;
8- use crate :: ty:: { self , Lift , Ty , TyCtxt } ;
8+ use crate :: ty:: { self , Lift , Ty , TyCtxt , ConstVid , InferConst } ;
99use crate :: ty:: fold:: { TypeFoldable , TypeFolder , TypeVisitor } ;
1010use rustc_data_structures:: indexed_vec:: { IndexVec , Idx } ;
1111use smallvec:: SmallVec ;
1212use crate :: mir:: interpret;
1313
14+ use std:: marker:: PhantomData ;
1415use std:: rc:: Rc ;
1516
1617///////////////////////////////////////////////////////////////////////////
@@ -49,6 +50,7 @@ CloneTypeFoldableAndLiftImpls! {
4950 crate :: ty:: BoundRegion ,
5051 crate :: ty:: ClosureKind ,
5152 crate :: ty:: IntVarValue ,
53+ crate :: ty:: ParamConst ,
5254 crate :: ty:: ParamTy ,
5355 crate :: ty:: UniverseIndex ,
5456 crate :: ty:: Variance ,
@@ -503,6 +505,14 @@ impl<'a, 'tcx> Lift<'tcx> for ConstValue<'a> {
503505 type Lifted = ConstValue < ' tcx > ;
504506 fn lift_to_tcx < ' b , ' gcx > ( & self , tcx : TyCtxt < ' b , ' gcx , ' tcx > ) -> Option < Self :: Lifted > {
505507 match * self {
508+ ConstValue :: Param ( param) => Some ( ConstValue :: Param ( param) ) ,
509+ ConstValue :: Infer ( infer) => {
510+ Some ( ConstValue :: Infer ( match infer {
511+ InferConst :: Var ( vid) => InferConst :: Var ( vid. lift_to_tcx ( tcx) ?) ,
512+ InferConst :: Fresh ( i) => InferConst :: Fresh ( i) ,
513+ InferConst :: Canonical ( debrujin, var) => InferConst :: Canonical ( debrujin, var) ,
514+ } ) )
515+ }
506516 ConstValue :: Scalar ( x) => Some ( ConstValue :: Scalar ( x) ) ,
507517 ConstValue :: Slice ( x, y) => Some ( ConstValue :: Slice ( x, y) ) ,
508518 ConstValue :: ByRef ( ptr, alloc) => Some ( ConstValue :: ByRef (
@@ -512,6 +522,16 @@ impl<'a, 'tcx> Lift<'tcx> for ConstValue<'a> {
512522 }
513523}
514524
525+ impl < ' a , ' tcx > Lift < ' tcx > for ConstVid < ' a > {
526+ type Lifted = ConstVid < ' tcx > ;
527+ fn lift_to_tcx < ' b , ' gcx > ( & self , _: TyCtxt < ' b , ' gcx , ' tcx > ) -> Option < Self :: Lifted > {
528+ Some ( ConstVid {
529+ index : self . index ,
530+ phantom : PhantomData ,
531+ } )
532+ }
533+ }
534+
515535///////////////////////////////////////////////////////////////////////////
516536// TypeFoldable implementations.
517537//
0 commit comments