@@ -127,6 +127,7 @@ pub struct CtxtInterners<'tcx> {
127
127
goal : InternedSet < ' tcx , GoalKind < ' tcx > > ,
128
128
goal_list : InternedSet < ' tcx , List < Goal < ' tcx > > > ,
129
129
projs : InternedSet < ' tcx , List < ProjectionKind < ' tcx > > > ,
130
+ lazy_const : InternedSet < ' tcx , LazyConst < ' tcx > > ,
130
131
}
131
132
132
133
impl < ' gcx : ' tcx , ' tcx > CtxtInterners < ' tcx > {
@@ -144,6 +145,7 @@ impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
144
145
goal : Default :: default ( ) ,
145
146
goal_list : Default :: default ( ) ,
146
147
projs : Default :: default ( ) ,
148
+ lazy_const : Default :: default ( ) ,
147
149
}
148
150
}
149
151
@@ -1072,10 +1074,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1072
1074
self . global_arenas . adt_def . alloc ( def)
1073
1075
}
1074
1076
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 {
1079
1078
self . allocation_interner . borrow_mut ( ) . intern ( alloc, |alloc| {
1080
1079
self . global_arenas . const_allocs . alloc ( alloc)
1081
1080
} )
@@ -1095,10 +1094,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1095
1094
} )
1096
1095
}
1097
1096
1098
- pub fn intern_lazy_const ( self , c : ty:: LazyConst < ' tcx > ) -> & ' tcx ty:: LazyConst < ' tcx > {
1099
- self . global_interners . arena . alloc ( c)
1100
- }
1101
-
1102
1097
pub fn intern_layout ( self , layout : LayoutDetails ) -> & ' gcx LayoutDetails {
1103
1098
self . layout_interner . borrow_mut ( ) . intern ( layout, |layout| {
1104
1099
self . global_arenas . layout . alloc ( layout)
@@ -2238,6 +2233,12 @@ impl<'tcx: 'lcx, 'lcx> Borrow<GoalKind<'lcx>> for Interned<'tcx, GoalKind<'tcx>>
2238
2233
}
2239
2234
}
2240
2235
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
+
2241
2242
impl < ' tcx : ' lcx , ' lcx > Borrow < [ ExistentialPredicate < ' lcx > ] >
2242
2243
for Interned < ' tcx , List < ExistentialPredicate < ' tcx > > > {
2243
2244
fn borrow < ' a > ( & ' a self ) -> & ' a [ ExistentialPredicate < ' lcx > ] {
@@ -2344,7 +2345,8 @@ pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool {
2344
2345
2345
2346
direct_interners ! ( ' tcx,
2346
2347
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>
2348
2350
) ;
2349
2351
2350
2352
macro_rules! slice_interners {
@@ -2529,7 +2531,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
2529
2531
2530
2532
#[ inline]
2531
2533
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 (
2533
2535
ty:: LazyConst :: Evaluated ( ty:: Const :: from_usize ( self . global_tcx ( ) , n) )
2534
2536
) ) )
2535
2537
}
0 commit comments