@@ -12,10 +12,18 @@ use rustc_macros::HashStable;
12
12
use rustc_target:: abi:: Size ;
13
13
14
14
use 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
+ }
15
23
16
24
/// 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 ) ]
19
27
pub enum ConstKind < ' tcx > {
20
28
/// A const generic parameter.
21
29
Param ( ty:: ParamConst ) ,
@@ -31,7 +39,7 @@ pub enum ConstKind<'tcx> {
31
39
32
40
/// Used in the HIR by using `Unevaluated` everywhere and later normalizing to one of the other
33
41
/// variants when the code is monomorphic enough for that.
34
- Unevaluated ( ty :: WithOptConstParam < DefId > , SubstsRef < ' tcx > , Option < Promoted > ) ,
42
+ Unevaluated ( Unevaluated < ' tcx > ) ,
35
43
36
44
/// Used to hold computed value.
37
45
Value ( ConstValue < ' tcx > ) ,
@@ -102,7 +110,7 @@ impl<'tcx> ConstKind<'tcx> {
102
110
tcx : TyCtxt < ' tcx > ,
103
111
param_env : ParamEnv < ' tcx > ,
104
112
) -> Option < Result < ConstValue < ' tcx > , ErrorReported > > {
105
- if let ConstKind :: Unevaluated ( def, substs, promoted) = self {
113
+ if let ConstKind :: Unevaluated ( Unevaluated { def, substs, promoted } ) = self {
106
114
use crate :: mir:: interpret:: ErrorHandled ;
107
115
108
116
// HACK(eddyb) this erases lifetimes even though `const_eval_resolve`
@@ -132,7 +140,8 @@ impl<'tcx> ConstKind<'tcx> {
132
140
let ( param_env, substs) = param_env_and_substs. into_parts ( ) ;
133
141
// try to resolve e.g. associated constants to their definition on an impl, and then
134
142
// 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
+ {
136
145
// NOTE(eddyb) `val` contains no lifetimes/types/consts,
137
146
// and we use the original type, so nothing from `substs`
138
147
// (which may be identity substs, see above),
0 commit comments