@@ -2055,7 +2055,7 @@ pub enum ConstantKind<'tcx> {
20552055 Ty ( ty:: Const < ' tcx > ) ,
20562056
20572057 /// 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 > ) ,
20592059
20602060 /// This constant cannot go back into the type system, as it represents
20612061 /// something the type system cannot handle (e.g. pointers).
@@ -2315,12 +2315,11 @@ impl<'tcx> ConstantKind<'tcx> {
23152315 ty:: InlineConstSubsts :: new ( tcx, ty:: InlineConstSubstsParts { parent_substs, ty } )
23162316 . substs ;
23172317
2318- let uneval = ty :: Unevaluated {
2318+ let uneval = UnevaluatedConst {
23192319 def : ty:: WithOptConstParam :: unknown ( def_id) . to_global ( ) ,
23202320 substs,
23212321 promoted : None ,
23222322 } ;
2323-
23242323 debug_assert ! ( !uneval. has_free_regions( ) ) ;
23252324
23262325 Self :: Unevaluated ( uneval, ty)
@@ -2404,7 +2403,7 @@ impl<'tcx> ConstantKind<'tcx> {
24042403
24052404 let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def. did ) ;
24062405 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) ;
24082407 debug ! ( ?span, ?param_env) ;
24092408
24102409 match tcx. const_eval_resolve ( param_env, uneval, Some ( span) ) {
@@ -2417,7 +2416,7 @@ impl<'tcx> ConstantKind<'tcx> {
24172416 // Error was handled in `const_eval_resolve`. Here we just create a
24182417 // new unevaluated const and error hard later in codegen
24192418 Self :: Unevaluated (
2420- ty :: Unevaluated {
2419+ UnevaluatedConst {
24212420 def : def. to_global ( ) ,
24222421 substs : InternalSubsts :: identity_for_item ( tcx, def. did . to_def_id ( ) ) ,
24232422 promoted : None ,
@@ -2440,6 +2439,34 @@ impl<'tcx> ConstantKind<'tcx> {
24402439 }
24412440}
24422441
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+
24432470/// A collection of projections into user types.
24442471///
24452472/// They are projections because a binding can occur a part of a
0 commit comments