@@ -12,10 +12,18 @@ use rustc_macros::HashStable;
1212use rustc_target:: abi:: Size ;
1313
1414use super :: ScalarInt ;
15+ /// An unevaluated, potentially generic, constant.
16+ #[ derive( Copy , Clone , Debug , Eq , PartialEq , PartialOrd , Ord , TyEncodable , TyDecodable ) ]
17+ #[ derive( Hash , HashStable ) ]
18+ pub struct Unevaluated < ' tcx > {
19+ pub def : ty:: WithOptConstParam < DefId > ,
20+ pub substs : SubstsRef < ' tcx > ,
21+ pub promoted : Option < Promoted > ,
22+ }
1523
1624/// Represents a constant in Rust.
17- #[ derive( Copy , Clone , Debug , Eq , PartialEq , PartialOrd , Ord , TyEncodable , TyDecodable , Hash ) ]
18- #[ derive( HashStable ) ]
25+ #[ derive( Copy , Clone , Debug , Eq , PartialEq , PartialOrd , Ord , TyEncodable , TyDecodable ) ]
26+ #[ derive( Hash , HashStable ) ]
1927pub enum ConstKind < ' tcx > {
2028 /// A const generic parameter.
2129 Param ( ty:: ParamConst ) ,
@@ -31,7 +39,7 @@ pub enum ConstKind<'tcx> {
3139
3240 /// Used in the HIR by using `Unevaluated` everywhere and later normalizing to one of the other
3341 /// variants when the code is monomorphic enough for that.
34- Unevaluated ( ty :: WithOptConstParam < DefId > , SubstsRef < ' tcx > , Option < Promoted > ) ,
42+ Unevaluated ( Unevaluated < ' tcx > ) ,
3543
3644 /// Used to hold computed value.
3745 Value ( ConstValue < ' tcx > ) ,
@@ -102,7 +110,7 @@ impl<'tcx> ConstKind<'tcx> {
102110 tcx : TyCtxt < ' tcx > ,
103111 param_env : ParamEnv < ' tcx > ,
104112 ) -> Option < Result < ConstValue < ' tcx > , ErrorReported > > {
105- if let ConstKind :: Unevaluated ( def, substs, promoted) = self {
113+ if let ConstKind :: Unevaluated ( Unevaluated { def, substs, promoted } ) = self {
106114 use crate :: mir:: interpret:: ErrorHandled ;
107115
108116 // HACK(eddyb) this erases lifetimes even though `const_eval_resolve`
@@ -132,7 +140,8 @@ impl<'tcx> ConstKind<'tcx> {
132140 let ( param_env, substs) = param_env_and_substs. into_parts ( ) ;
133141 // try to resolve e.g. associated constants to their definition on an impl, and then
134142 // evaluate the const.
135- match tcx. const_eval_resolve ( param_env, def, substs, promoted, None ) {
143+ match tcx. const_eval_resolve ( param_env, ty:: Unevaluated { def, substs, promoted } , None )
144+ {
136145 // NOTE(eddyb) `val` contains no lifetimes/types/consts,
137146 // and we use the original type, so nothing from `substs`
138147 // (which may be identity substs, see above),
0 commit comments