@@ -2055,7 +2055,7 @@ pub enum ConstantKind<'tcx> {
2055
2055
Ty ( ty:: Const < ' tcx > ) ,
2056
2056
2057
2057
/// An unevaluated mir constant which is not part of the type system.
2058
- Unevaluated ( ty :: Unevaluated < ' tcx , Option < Promoted > > , Ty < ' tcx > ) ,
2058
+ Unevaluated ( UnevaluatedConst < ' tcx > , Ty < ' tcx > ) ,
2059
2059
2060
2060
/// This constant cannot go back into the type system, as it represents
2061
2061
/// something the type system cannot handle (e.g. pointers).
@@ -2315,12 +2315,11 @@ impl<'tcx> ConstantKind<'tcx> {
2315
2315
ty:: InlineConstSubsts :: new ( tcx, ty:: InlineConstSubstsParts { parent_substs, ty } )
2316
2316
. substs ;
2317
2317
2318
- let uneval = ty :: Unevaluated {
2318
+ let uneval = UnevaluatedConst {
2319
2319
def : ty:: WithOptConstParam :: unknown ( def_id) . to_global ( ) ,
2320
2320
substs,
2321
2321
promoted : None ,
2322
2322
} ;
2323
-
2324
2323
debug_assert ! ( !uneval. has_free_regions( ) ) ;
2325
2324
2326
2325
Self :: Unevaluated ( uneval, ty)
@@ -2404,7 +2403,7 @@ impl<'tcx> ConstantKind<'tcx> {
2404
2403
2405
2404
let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def. did ) ;
2406
2405
let span = tcx. hir ( ) . span ( hir_id) ;
2407
- let uneval = ty :: Unevaluated :: new ( def. to_global ( ) , substs) ;
2406
+ let uneval = UnevaluatedConst :: new ( def. to_global ( ) , substs) ;
2408
2407
debug ! ( ?span, ?param_env) ;
2409
2408
2410
2409
match tcx. const_eval_resolve ( param_env, uneval, Some ( span) ) {
@@ -2417,7 +2416,7 @@ impl<'tcx> ConstantKind<'tcx> {
2417
2416
// Error was handled in `const_eval_resolve`. Here we just create a
2418
2417
// new unevaluated const and error hard later in codegen
2419
2418
Self :: Unevaluated (
2420
- ty :: Unevaluated {
2419
+ UnevaluatedConst {
2421
2420
def : def. to_global ( ) ,
2422
2421
substs : InternalSubsts :: identity_for_item ( tcx, def. did . to_def_id ( ) ) ,
2423
2422
promoted : None ,
@@ -2440,6 +2439,34 @@ impl<'tcx> ConstantKind<'tcx> {
2440
2439
}
2441
2440
}
2442
2441
2442
+ /// An unevaluated (potentially generic) constant used in MIR.
2443
+ #[ derive( Copy , Clone , Debug , Eq , PartialEq , PartialOrd , Ord , TyEncodable , TyDecodable , Lift ) ]
2444
+ #[ derive( Hash , HashStable ) ]
2445
+ pub struct UnevaluatedConst < ' tcx > {
2446
+ pub def : ty:: WithOptConstParam < DefId > ,
2447
+ pub substs : SubstsRef < ' tcx > ,
2448
+ pub promoted : Option < Promoted > ,
2449
+ }
2450
+
2451
+ impl < ' tcx > UnevaluatedConst < ' tcx > {
2452
+ // FIXME: probably should get rid of this method. It's also wrong to
2453
+ // shrink and then later expand a promoted.
2454
+ #[ inline]
2455
+ pub fn shrink ( self ) -> ty:: UnevaluatedConst < ' tcx > {
2456
+ ty:: UnevaluatedConst { def : self . def , substs : self . substs }
2457
+ }
2458
+ }
2459
+
2460
+ impl < ' tcx > UnevaluatedConst < ' tcx > {
2461
+ #[ inline]
2462
+ pub fn new (
2463
+ def : ty:: WithOptConstParam < DefId > ,
2464
+ substs : SubstsRef < ' tcx > ,
2465
+ ) -> UnevaluatedConst < ' tcx > {
2466
+ UnevaluatedConst { def, substs, promoted : Default :: default ( ) }
2467
+ }
2468
+ }
2469
+
2443
2470
/// A collection of projections into user types.
2444
2471
///
2445
2472
/// They are projections because a binding can occur a part of a
0 commit comments