@@ -21,7 +21,7 @@ use rustc_middle::thir;
2121use rustc_middle:: ty:: fast_reject:: SimplifiedType ;
2222use rustc_middle:: ty:: query:: Providers ;
2323use rustc_middle:: ty:: { self , ReprOptions , Ty } ;
24- use rustc_middle:: ty:: { GeneratorDiagnosticData , TyCtxt } ;
24+ use rustc_middle:: ty:: { GeneratorDiagnosticData , ParameterizedOverTcx , TyCtxt } ;
2525use rustc_serialize:: opaque:: Encoder ;
2626use rustc_session:: config:: SymbolManglingVersion ;
2727use rustc_session:: cstore:: { CrateDepKind , ForeignModule , LinkagePreference , NativeLib } ;
@@ -83,6 +83,10 @@ struct LazyValue<T> {
8383 _marker : PhantomData < fn ( ) -> T > ,
8484}
8585
86+ impl < T : ParameterizedOverTcx > ParameterizedOverTcx for LazyValue < T > {
87+ type Value < ' tcx > = LazyValue < T :: Value < ' tcx > > ;
88+ }
89+
8690impl < T > LazyValue < T > {
8791 fn from_position ( position : NonZeroUsize ) -> LazyValue < T > {
8892 LazyValue { position, _marker : PhantomData }
@@ -105,6 +109,10 @@ struct LazyArray<T> {
105109 _marker : PhantomData < fn ( ) -> T > ,
106110}
107111
112+ impl < T : ParameterizedOverTcx > ParameterizedOverTcx for LazyArray < T > {
113+ type Value < ' tcx > = LazyArray < T :: Value < ' tcx > > ;
114+ }
115+
108116impl < T > LazyArray < T > {
109117 fn from_position_and_num_elems ( position : NonZeroUsize , num_elems : usize ) -> LazyArray < T > {
110118 LazyArray { position, num_elems, _marker : PhantomData }
@@ -126,6 +134,10 @@ struct LazyTable<I, T> {
126134 _marker : PhantomData < fn ( I ) -> T > ,
127135}
128136
137+ impl < I : ' static , T : ParameterizedOverTcx > ParameterizedOverTcx for LazyTable < I , T > {
138+ type Value < ' tcx > = LazyTable < I , T :: Value < ' tcx > > ;
139+ }
140+
129141impl < I , T > LazyTable < I , T > {
130142 fn from_position_and_encoded_size (
131143 position : NonZeroUsize ,
@@ -199,7 +211,7 @@ pub(crate) struct ProcMacroData {
199211/// a normal crate, much of what we serialized would be unusable in addition
200212/// to being unused.
201213#[ derive( MetadataEncodable , MetadataDecodable ) ]
202- pub ( crate ) struct CrateRoot < ' tcx > {
214+ pub ( crate ) struct CrateRoot {
203215 name : Symbol ,
204216 triple : TargetTriple ,
205217 extra_filename : String ,
@@ -226,16 +238,16 @@ pub(crate) struct CrateRoot<'tcx> {
226238 interpret_alloc_index : LazyArray < u32 > ,
227239 proc_macro_data : Option < ProcMacroData > ,
228240
229- tables : LazyTables < ' tcx > ,
241+ tables : LazyTables ,
230242 debugger_visualizers : LazyArray < rustc_span:: DebuggerVisualizerFile > ,
231243
232- exported_symbols : LazyArray < ( ExportedSymbol < ' tcx > , SymbolExportInfo ) > ,
244+ exported_symbols : LazyArray < ( ExportedSymbol < ' static > , SymbolExportInfo ) > ,
233245
234246 syntax_contexts : SyntaxContextTable ,
235247 expn_data : ExpnDataTable ,
236248 expn_hashes : ExpnHashTable ,
237249
238- def_path_hash_map : LazyValue < DefPathHashMapRef < ' tcx > > ,
250+ def_path_hash_map : LazyValue < DefPathHashMapRef < ' static > > ,
239251
240252 source_map : LazyArray < rustc_span:: SourceFile > ,
241253
@@ -301,17 +313,17 @@ pub(crate) struct IncoherentImpls {
301313macro_rules! define_tables {
302314 ( $( $name: ident: Table <$IDX: ty, $T: ty>) ,+ $( , ) ?) => {
303315 #[ derive( MetadataEncodable , MetadataDecodable ) ]
304- pub ( crate ) struct LazyTables < ' tcx> {
316+ pub ( crate ) struct LazyTables {
305317 $( $name: LazyTable <$IDX, $T>) ,+
306318 }
307319
308320 #[ derive( Default ) ]
309- struct TableBuilders < ' tcx> {
321+ struct TableBuilders {
310322 $( $name: TableBuilder <$IDX, $T>) ,+
311323 }
312324
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 {
315327 LazyTables {
316328 $( $name: self . $name. encode( buf) ) ,+
317329 }
@@ -333,23 +345,23 @@ define_tables! {
333345 lookup_const_stability: Table <DefIndex , LazyValue <attr:: ConstStability >>,
334346 lookup_deprecation_entry: Table <DefIndex , LazyValue <attr:: Deprecation >>,
335347 // 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 >>>,
338350 generics_of: Table <DefIndex , LazyValue <ty:: Generics >>,
339351 // 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 >>>,
343355 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 >>>,
345357 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 >>>>,
351363 // 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 >] >>,
353365 impl_parent: Table <DefIndex , RawDefId >,
354366 impl_polarity: Table <DefIndex , ty:: ImplPolarity >,
355367 impl_constness: Table <DefIndex , hir:: Constness >,
@@ -376,7 +388,7 @@ define_tables! {
376388 def_keys: Table <DefIndex , LazyValue <DefKey >>,
377389 def_path_hashes: Table <DefIndex , DefPathHash >,
378390 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 >>>,
380392 may_have_doc_links: Table <DefIndex , ( ) >,
381393}
382394
@@ -477,3 +489,14 @@ pub fn provide(providers: &mut Providers) {
477489 encoder:: provide ( providers) ;
478490 decoder:: provide ( providers) ;
479491}
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