@@ -32,13 +32,20 @@ trait ProcessQueryValue<'tcx, T> {
3232 fn process_decoded ( self , _tcx : TyCtxt < ' tcx > , _err : impl Fn ( ) -> !) -> T ;
3333}
3434
35- impl < T > ProcessQueryValue < ' _ , Option < T > > for Option < T > {
35+ impl < T > ProcessQueryValue < ' _ , T > for T {
3636 #[ inline( always) ]
37- fn process_decoded ( self , _tcx : TyCtxt < ' _ > , _err : impl Fn ( ) -> !) -> Option < T > {
37+ fn process_decoded ( self , _tcx : TyCtxt < ' _ > , _err : impl Fn ( ) -> !) -> T {
3838 self
3939 }
4040}
4141
42+ impl < ' tcx , T > ProcessQueryValue < ' tcx , ty:: EarlyBinder < ' tcx , T > > for T {
43+ #[ inline( always) ]
44+ fn process_decoded ( self , _tcx : TyCtxt < ' _ > , _err : impl Fn ( ) -> !) -> ty:: EarlyBinder < ' tcx , T > {
45+ ty:: EarlyBinder :: bind ( self )
46+ }
47+ }
48+
4249impl < T > ProcessQueryValue < ' _ , T > for Option < T > {
4350 #[ inline( always) ]
4451 fn process_decoded ( self , _tcx : TyCtxt < ' _ > , err : impl Fn ( ) -> !) -> T {
@@ -69,6 +76,24 @@ impl<'a, 'tcx, T: Copy + Decodable<DecodeContext<'a, 'tcx>>> ProcessQueryValue<'
6976 }
7077}
7178
79+ impl < ' a , ' tcx , T : Copy + Decodable < DecodeContext < ' a , ' tcx > > >
80+ ProcessQueryValue < ' tcx , ty:: EarlyBinder < ' tcx , & ' tcx [ T ] > >
81+ for Option < DecodeIterator < ' a , ' tcx , T > >
82+ {
83+ #[ inline( always) ]
84+ fn process_decoded (
85+ self ,
86+ tcx : TyCtxt < ' tcx > ,
87+ _err : impl Fn ( ) -> !,
88+ ) -> ty:: EarlyBinder < ' tcx , & ' tcx [ T ] > {
89+ ty:: EarlyBinder :: bind ( if let Some ( iter) = self {
90+ tcx. arena . alloc_from_iter ( iter)
91+ } else {
92+ & [ ]
93+ } )
94+ }
95+ }
96+
7297impl < ' a , ' tcx , T : Copy + Decodable < DecodeContext < ' a , ' tcx > > >
7398 ProcessQueryValue < ' tcx , Option < & ' tcx [ T ] > > for Option < DecodeIterator < ' a , ' tcx , T > >
7499{
@@ -103,7 +128,12 @@ macro_rules! provide_one {
103128 provide_one! {
104129 $tcx, $def_id, $other, $cdata, $name => {
105130 let lazy = $cdata. root. tables. $name. get( $cdata, $def_id. index) ;
106- if lazy. is_default( ) { & [ ] } else { $tcx. arena. alloc_from_iter( lazy. decode( ( $cdata, $tcx) ) ) }
131+ let value = if lazy. is_default( ) {
132+ & [ ] as & [ _]
133+ } else {
134+ $tcx. arena. alloc_from_iter( lazy. decode( ( $cdata, $tcx) ) )
135+ } ;
136+ value. process_decoded( $tcx, || panic!( "{:?} does not have a {:?}" , $def_id, stringify!( $name) ) )
107137 }
108138 }
109139 } ;
@@ -212,15 +242,15 @@ impl IntoArgs for (CrateNum, SimplifiedType) {
212242}
213243
214244provide ! { tcx, def_id, other, cdata,
215- explicit_item_bounds => { cdata . get_explicit_item_bounds ( def_id . index , tcx ) }
216- explicit_item_super_predicates => { cdata . get_explicit_item_super_predicates ( def_id . index , tcx ) }
245+ explicit_item_bounds => { table_defaulted_array }
246+ explicit_item_super_predicates => { table_defaulted_array }
217247 explicit_predicates_of => { table }
218248 generics_of => { table }
219249 inferred_outlives_of => { table_defaulted_array }
220- explicit_super_predicates_of => { table }
221- explicit_implied_predicates_of => { table }
250+ explicit_super_predicates_of => { table_defaulted_array }
251+ explicit_implied_predicates_of => { table_defaulted_array }
222252 type_of => { table }
223- type_alias_is_lazy => { cdata . root . tables . type_alias_is_lazy . get ( cdata , def_id . index ) }
253+ type_alias_is_lazy => { table_direct }
224254 variances_of => { table }
225255 fn_sig => { table }
226256 codegen_fn_attrs => { table }
@@ -241,7 +271,7 @@ provide! { tcx, def_id, other, cdata,
241271 lookup_default_body_stability => { table }
242272 lookup_deprecation_entry => { table }
243273 params_in_repr => { table }
244- unused_generic_params => { cdata . root . tables . unused_generic_params . get ( cdata , def_id . index ) }
274+ unused_generic_params => { table_direct }
245275 def_kind => { cdata. def_kind( def_id. index) }
246276 impl_parent => { table }
247277 defaultness => { table_direct }
@@ -287,9 +317,7 @@ provide! { tcx, def_id, other, cdata,
287317 . process_decoded( tcx, || panic!( "{def_id:?} does not have trait_impl_trait_tys" ) ) )
288318 }
289319
290- associated_type_for_effects => {
291- table
292- }
320+ associated_type_for_effects => { table }
293321 associated_types_for_impl_traits_in_associated_fn => { table_defaulted_array }
294322
295323 visibility => { cdata. get_visibility( def_id. index) }
@@ -310,7 +338,7 @@ provide! { tcx, def_id, other, cdata,
310338 item_attrs => { tcx. arena. alloc_from_iter( cdata. get_item_attrs( def_id. index, tcx. sess) ) }
311339 is_mir_available => { cdata. is_item_mir_available( def_id. index) }
312340 is_ctfe_mir_available => { cdata. is_ctfe_mir_available( def_id. index) }
313- cross_crate_inlinable => { cdata . cross_crate_inlinable ( def_id . index ) }
341+ cross_crate_inlinable => { table_direct }
314342
315343 dylib_dependency_formats => { cdata. get_dylib_dependency_formats( tcx) }
316344 is_private_dep => { cdata. private_dep }
0 commit comments