@@ -21,7 +21,7 @@ use rustc_middle::thir;
21
21
use rustc_middle:: ty:: fast_reject:: SimplifiedType ;
22
22
use rustc_middle:: ty:: query:: Providers ;
23
23
use rustc_middle:: ty:: { self , ReprOptions , Ty } ;
24
- use rustc_middle:: ty:: { GeneratorDiagnosticData , TyCtxt } ;
24
+ use rustc_middle:: ty:: { GeneratorDiagnosticData , ParameterizedOverTcx , TyCtxt } ;
25
25
use rustc_serialize:: opaque:: Encoder ;
26
26
use rustc_session:: config:: SymbolManglingVersion ;
27
27
use rustc_session:: cstore:: { CrateDepKind , ForeignModule , LinkagePreference , NativeLib } ;
@@ -83,6 +83,10 @@ struct LazyValue<T> {
83
83
_marker : PhantomData < fn ( ) -> T > ,
84
84
}
85
85
86
+ impl < T : ParameterizedOverTcx > ParameterizedOverTcx for LazyValue < T > {
87
+ type Value < ' tcx > = LazyValue < T :: Value < ' tcx > > ;
88
+ }
89
+
86
90
impl < T > LazyValue < T > {
87
91
fn from_position ( position : NonZeroUsize ) -> LazyValue < T > {
88
92
LazyValue { position, _marker : PhantomData }
@@ -105,6 +109,10 @@ struct LazyArray<T> {
105
109
_marker : PhantomData < fn ( ) -> T > ,
106
110
}
107
111
112
+ impl < T : ParameterizedOverTcx > ParameterizedOverTcx for LazyArray < T > {
113
+ type Value < ' tcx > = LazyArray < T :: Value < ' tcx > > ;
114
+ }
115
+
108
116
impl < T > LazyArray < T > {
109
117
fn from_position_and_num_elems ( position : NonZeroUsize , num_elems : usize ) -> LazyArray < T > {
110
118
LazyArray { position, num_elems, _marker : PhantomData }
@@ -126,6 +134,10 @@ struct LazyTable<I, T> {
126
134
_marker : PhantomData < fn ( I ) -> T > ,
127
135
}
128
136
137
+ impl < I : ' static , T : ParameterizedOverTcx > ParameterizedOverTcx for LazyTable < I , T > {
138
+ type Value < ' tcx > = LazyTable < I , T :: Value < ' tcx > > ;
139
+ }
140
+
129
141
impl < I , T > LazyTable < I , T > {
130
142
fn from_position_and_encoded_size (
131
143
position : NonZeroUsize ,
@@ -199,7 +211,7 @@ pub(crate) struct ProcMacroData {
199
211
/// a normal crate, much of what we serialized would be unusable in addition
200
212
/// to being unused.
201
213
#[ derive( MetadataEncodable , MetadataDecodable ) ]
202
- pub ( crate ) struct CrateRoot < ' tcx > {
214
+ pub ( crate ) struct CrateRoot {
203
215
name : Symbol ,
204
216
triple : TargetTriple ,
205
217
extra_filename : String ,
@@ -226,16 +238,16 @@ pub(crate) struct CrateRoot<'tcx> {
226
238
interpret_alloc_index : LazyArray < u32 > ,
227
239
proc_macro_data : Option < ProcMacroData > ,
228
240
229
- tables : LazyTables < ' tcx > ,
241
+ tables : LazyTables ,
230
242
debugger_visualizers : LazyArray < rustc_span:: DebuggerVisualizerFile > ,
231
243
232
- exported_symbols : LazyArray < ( ExportedSymbol < ' tcx > , SymbolExportInfo ) > ,
244
+ exported_symbols : LazyArray < ( ExportedSymbol < ' static > , SymbolExportInfo ) > ,
233
245
234
246
syntax_contexts : SyntaxContextTable ,
235
247
expn_data : ExpnDataTable ,
236
248
expn_hashes : ExpnHashTable ,
237
249
238
- def_path_hash_map : LazyValue < DefPathHashMapRef < ' tcx > > ,
250
+ def_path_hash_map : LazyValue < DefPathHashMapRef < ' static > > ,
239
251
240
252
source_map : LazyArray < rustc_span:: SourceFile > ,
241
253
@@ -301,17 +313,17 @@ pub(crate) struct IncoherentImpls {
301
313
macro_rules! define_tables {
302
314
( $( $name: ident: Table <$IDX: ty, $T: ty>) ,+ $( , ) ?) => {
303
315
#[ derive( MetadataEncodable , MetadataDecodable ) ]
304
- pub ( crate ) struct LazyTables < ' tcx> {
316
+ pub ( crate ) struct LazyTables {
305
317
$( $name: LazyTable <$IDX, $T>) ,+
306
318
}
307
319
308
320
#[ derive( Default ) ]
309
- struct TableBuilders < ' tcx> {
321
+ struct TableBuilders {
310
322
$( $name: TableBuilder <$IDX, $T>) ,+
311
323
}
312
324
313
- impl < ' tcx> TableBuilders < ' tcx> {
314
- fn encode( & self , buf: & mut Encoder ) -> LazyTables < ' tcx> {
325
+ impl TableBuilders {
326
+ fn encode( & self , buf: & mut Encoder ) -> LazyTables {
315
327
LazyTables {
316
328
$( $name: self . $name. encode( buf) ) ,+
317
329
}
@@ -333,23 +345,23 @@ define_tables! {
333
345
lookup_const_stability: Table <DefIndex , LazyValue <attr:: ConstStability >>,
334
346
lookup_deprecation_entry: Table <DefIndex , LazyValue <attr:: Deprecation >>,
335
347
// As an optimization, a missing entry indicates an empty `&[]`.
336
- explicit_item_bounds: Table <DefIndex , LazyArray <( ty:: Predicate <' tcx >, Span ) >>,
337
- explicit_predicates_of: Table <DefIndex , LazyValue <ty:: GenericPredicates <' tcx >>>,
348
+ explicit_item_bounds: Table <DefIndex , LazyArray <( ty:: Predicate <' static >, Span ) >>,
349
+ explicit_predicates_of: Table <DefIndex , LazyValue <ty:: GenericPredicates <' static >>>,
338
350
generics_of: Table <DefIndex , LazyValue <ty:: Generics >>,
339
351
// As an optimization, a missing entry indicates an empty `&[]`.
340
- inferred_outlives_of: Table <DefIndex , LazyArray <( ty:: Predicate <' tcx >, Span ) >>,
341
- super_predicates_of: Table <DefIndex , LazyValue <ty:: GenericPredicates <' tcx >>>,
342
- type_of: Table <DefIndex , LazyValue <Ty <' tcx >>>,
352
+ inferred_outlives_of: Table <DefIndex , LazyArray <( ty:: Predicate <' static >, Span ) >>,
353
+ super_predicates_of: Table <DefIndex , LazyValue <ty:: GenericPredicates <' static >>>,
354
+ type_of: Table <DefIndex , LazyValue <Ty <' static >>>,
343
355
variances_of: Table <DefIndex , LazyArray <ty:: Variance >>,
344
- fn_sig: Table <DefIndex , LazyValue <ty:: PolyFnSig <' tcx >>>,
356
+ fn_sig: Table <DefIndex , LazyValue <ty:: PolyFnSig <' static >>>,
345
357
codegen_fn_attrs: Table <DefIndex , LazyValue <CodegenFnAttrs >>,
346
- impl_trait_ref: Table <DefIndex , LazyValue <ty:: TraitRef <' tcx >>>,
347
- const_param_default: Table <DefIndex , LazyValue <rustc_middle:: ty:: Const <' tcx >>>,
348
- optimized_mir: Table <DefIndex , LazyValue <mir:: Body <' tcx >>>,
349
- mir_for_ctfe: Table <DefIndex , LazyValue <mir:: Body <' tcx >>>,
350
- promoted_mir: Table <DefIndex , LazyValue <IndexVec <mir:: Promoted , mir:: Body <' tcx >>>>,
358
+ impl_trait_ref: Table <DefIndex , LazyValue <ty:: TraitRef <' static >>>,
359
+ const_param_default: Table <DefIndex , LazyValue <rustc_middle:: ty:: Const <' static >>>,
360
+ optimized_mir: Table <DefIndex , LazyValue <mir:: Body <' static >>>,
361
+ mir_for_ctfe: Table <DefIndex , LazyValue <mir:: Body <' static >>>,
362
+ promoted_mir: Table <DefIndex , LazyValue <IndexVec <mir:: Promoted , mir:: Body <' static >>>>,
351
363
// FIXME(compiler-errors): Why isn't this a LazyArray?
352
- thir_abstract_const: Table <DefIndex , LazyValue <& ' tcx [ thir:: abstract_const:: Node <' tcx >] >>,
364
+ thir_abstract_const: Table <DefIndex , LazyValue <& ' static [ thir:: abstract_const:: Node <' static >] >>,
353
365
impl_parent: Table <DefIndex , RawDefId >,
354
366
impl_polarity: Table <DefIndex , ty:: ImplPolarity >,
355
367
impl_constness: Table <DefIndex , hir:: Constness >,
@@ -376,7 +388,7 @@ define_tables! {
376
388
def_keys: Table <DefIndex , LazyValue <DefKey >>,
377
389
def_path_hashes: Table <DefIndex , DefPathHash >,
378
390
proc_macro_quoted_spans: Table <usize , LazyValue <Span >>,
379
- generator_diagnostic_data: Table <DefIndex , LazyValue <GeneratorDiagnosticData <' tcx >>>,
391
+ generator_diagnostic_data: Table <DefIndex , LazyValue <GeneratorDiagnosticData <' static >>>,
380
392
may_have_doc_links: Table <DefIndex , ( ) >,
381
393
}
382
394
@@ -477,3 +489,14 @@ pub fn provide(providers: &mut Providers) {
477
489
encoder:: provide ( providers) ;
478
490
decoder:: provide ( providers) ;
479
491
}
492
+
493
+ trivially_parameterized_over_tcx ! {
494
+ VariantData ,
495
+ AssocFnData ,
496
+ EntryKind ,
497
+ RawDefId ,
498
+ TraitImpls ,
499
+ IncoherentImpls ,
500
+ CrateRoot ,
501
+ CrateDep ,
502
+ }
0 commit comments