@@ -8,6 +8,7 @@ use self::TyKind::*;
88use crate :: hir;
99use crate :: hir:: def_id:: DefId ;
1010use crate :: infer:: canonical:: Canonical ;
11+ use crate :: mir:: Promoted ;
1112use crate :: mir:: interpret:: ConstValue ;
1213use crate :: middle:: region;
1314use crate :: ty:: subst:: { InternalSubsts , Subst , SubstsRef , GenericArg , GenericArgKind } ;
@@ -2330,7 +2331,7 @@ impl<'tcx> Const<'tcx> {
23302331 tcx : TyCtxt < ' tcx > ,
23312332 param_env : ParamEnv < ' tcx > ,
23322333 ) -> & Const < ' tcx > {
2333- let try_const_eval = |did, param_env : ParamEnv < ' tcx > , substs| {
2334+ let try_const_eval = |did, param_env : ParamEnv < ' tcx > , substs, promoted | {
23342335 let param_env_and_substs = param_env. with_reveal_all ( ) . and ( substs) ;
23352336
23362337 // Avoid querying `tcx.const_eval(...)` with any e.g. inference vars.
@@ -2344,13 +2345,13 @@ impl<'tcx> Const<'tcx> {
23442345 let instance = ty:: Instance :: resolve ( tcx, param_env, did, substs) ?;
23452346 let gid = GlobalId {
23462347 instance,
2347- promoted : None ,
2348+ promoted,
23482349 } ;
23492350 tcx. const_eval ( param_env. and ( gid) ) . ok ( )
23502351 } ;
23512352
23522353 match self . val {
2353- ConstKind :: Unevaluated ( did, substs) => {
2354+ ConstKind :: Unevaluated ( did, substs, promoted ) => {
23542355 // HACK(eddyb) when substs contain e.g. inference variables,
23552356 // attempt using identity substs instead, that will succeed
23562357 // when the expression doesn't depend on any parameters.
@@ -2360,12 +2361,12 @@ impl<'tcx> Const<'tcx> {
23602361 let identity_substs = InternalSubsts :: identity_for_item ( tcx, did) ;
23612362 // The `ParamEnv` needs to match the `identity_substs`.
23622363 let identity_param_env = tcx. param_env ( did) ;
2363- match try_const_eval ( did, identity_param_env, identity_substs) {
2364+ match try_const_eval ( did, identity_param_env, identity_substs, promoted ) {
23642365 Some ( ct) => ct. subst ( tcx, substs) ,
23652366 None => self ,
23662367 }
23672368 } else {
2368- try_const_eval ( did, param_env, substs) . unwrap_or ( self )
2369+ try_const_eval ( did, param_env, substs, promoted ) . unwrap_or ( self )
23692370 }
23702371 } ,
23712372 _ => self ,
@@ -2418,7 +2419,7 @@ pub enum ConstKind<'tcx> {
24182419
24192420 /// Used in the HIR by using `Unevaluated` everywhere and later normalizing to one of the other
24202421 /// variants when the code is monomorphic enough for that.
2421- Unevaluated ( DefId , SubstsRef < ' tcx > ) ,
2422+ Unevaluated ( DefId , SubstsRef < ' tcx > , Option < Promoted > ) ,
24222423
24232424 /// Used to hold computed value.
24242425 Value ( ConstValue < ' tcx > ) ,
0 commit comments