@@ -127,6 +127,7 @@ pub struct CtxtInterners<'tcx> {
127127 goal : InternedSet < ' tcx , GoalKind < ' tcx > > ,
128128 goal_list : InternedSet < ' tcx , List < Goal < ' tcx > > > ,
129129 projs : InternedSet < ' tcx , List < ProjectionKind < ' tcx > > > ,
130+ lazy_const : InternedSet < ' tcx , LazyConst < ' tcx > > ,
130131}
131132
132133impl < ' gcx : ' tcx , ' tcx > CtxtInterners < ' tcx > {
@@ -144,6 +145,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
144145 goal : Default :: default ( ) ,
145146 goal_list : Default :: default ( ) ,
146147 projs : Default :: default ( ) ,
148+ lazy_const : Default :: default ( ) ,
147149 }
148150 }
149151
@@ -1072,10 +1074,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
10721074 self . global_arenas . adt_def . alloc ( def)
10731075 }
10741076
1075- pub fn intern_const_alloc (
1076- self ,
1077- alloc : Allocation ,
1078- ) -> & ' gcx Allocation {
1077+ pub fn intern_const_alloc ( self , alloc : Allocation ) -> & ' gcx Allocation {
10791078 self . allocation_interner . borrow_mut ( ) . intern ( alloc, |alloc| {
10801079 self . global_arenas . const_allocs . alloc ( alloc)
10811080 } )
@@ -1095,10 +1094,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
10951094 } )
10961095 }
10971096
1098- pub fn intern_lazy_const ( self , c : ty:: LazyConst < ' tcx > ) -> & ' tcx ty:: LazyConst < ' tcx > {
1099- self . global_interners . arena . alloc ( c)
1100- }
1101-
11021097 pub fn intern_layout ( self , layout : LayoutDetails ) -> & ' gcx LayoutDetails {
11031098 self . layout_interner . borrow_mut ( ) . intern ( layout, |layout| {
11041099 self . global_arenas . layout . alloc ( layout)
@@ -2238,6 +2233,12 @@ impl<'tcx: 'lcx, 'lcx> Borrow<GoalKind<'lcx>> for Interned<'tcx, GoalKind<'tcx>>
22382233 }
22392234}
22402235
2236+ impl < ' tcx : ' lcx , ' lcx > Borrow < LazyConst < ' lcx > > for Interned < ' tcx , LazyConst < ' tcx > > {
2237+ fn borrow < ' a > ( & ' a self ) -> & ' a LazyConst < ' lcx > {
2238+ & self . 0
2239+ }
2240+ }
2241+
22412242impl < ' tcx : ' lcx , ' lcx > Borrow < [ ExistentialPredicate < ' lcx > ] >
22422243 for Interned < ' tcx , List < ExistentialPredicate < ' tcx > > > {
22432244 fn borrow < ' a > ( & ' a self ) -> & ' a [ ExistentialPredicate < ' lcx > ] {
@@ -2344,7 +2345,8 @@ pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool {
23442345
23452346direct_interners ! ( ' tcx,
23462347 region: mk_region( |r: & RegionKind | r. keep_in_local_tcx( ) ) -> RegionKind ,
2347- goal: mk_goal( |c: & GoalKind <' _>| keep_local( c) ) -> GoalKind <' tcx>
2348+ goal: mk_goal( |c: & GoalKind <' _>| keep_local( c) ) -> GoalKind <' tcx>,
2349+ lazy_const: mk_lazy_const( |c: & LazyConst <' _>| keep_local( & c) ) -> LazyConst <' tcx>
23482350) ;
23492351
23502352macro_rules! slice_interners {
@@ -2529,7 +2531,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
25292531
25302532 #[ inline]
25312533 pub fn mk_array ( self , ty : Ty < ' tcx > , n : u64 ) -> Ty < ' tcx > {
2532- self . mk_ty ( Array ( ty, self . intern_lazy_const (
2534+ self . mk_ty ( Array ( ty, self . mk_lazy_const (
25332535 ty:: LazyConst :: Evaluated ( ty:: Const :: from_usize ( self . global_tcx ( ) , n) )
25342536 ) ) )
25352537 }
0 commit comments