@@ -155,6 +155,14 @@ pub enum LazyState {
155155 Previous ( NonZeroUsize ) ,
156156}
157157
158+ // FIXME(#59875) `Lazy!(T)` replaces `Lazy<T>`, passing the `Meta` parameter
159+ // manually, instead of relying on the default, to get the correct variance.
160+ // Only needed when `T` itself contains a parameter (e.g. `'tcx`).
161+ macro_rules! Lazy {
162+ ( [ $T: ty] ) => { Lazy <[ $T] , usize >} ;
163+ ( $T: ty) => { Lazy <$T, ( ) >} ;
164+ }
165+
158166#[ derive( RustcEncodable , RustcDecodable ) ]
159167pub struct CrateRoot < ' tcx > {
160168 pub name : Symbol ,
@@ -181,10 +189,10 @@ pub struct CrateRoot<'tcx> {
181189 pub source_map : Lazy < [ syntax_pos:: SourceFile ] > ,
182190 pub def_path_table : Lazy < hir:: map:: definitions:: DefPathTable > ,
183191 pub impls : Lazy < [ TraitImpls ] > ,
184- pub exported_symbols : Lazy < [ ( ExportedSymbol < ' tcx > , SymbolExportLevel ) ] > ,
192+ pub exported_symbols : Lazy ! ( [ ( ExportedSymbol <' tcx>, SymbolExportLevel ) ] ) ,
185193 pub interpret_alloc_index : Lazy < [ u32 ] > ,
186194
187- pub entries_table : Lazy < [ Table < ' tcx > ] > ,
195+ pub entries_table : Lazy ! ( [ Table <Entry < ' tcx>> ] ) ,
188196
189197 pub compiler_builtins : bool ,
190198 pub needs_allocator : bool ,
@@ -219,14 +227,14 @@ pub struct Entry<'tcx> {
219227 pub stability : Option < Lazy < attr:: Stability > > ,
220228 pub deprecation : Option < Lazy < attr:: Deprecation > > ,
221229
222- pub ty : Option < Lazy < Ty < ' tcx > > > ,
230+ pub ty : Option < Lazy ! ( Ty <' tcx>) > ,
223231 pub inherent_impls : Lazy < [ DefIndex ] > ,
224232 pub variances : Lazy < [ ty:: Variance ] > ,
225233 pub generics : Option < Lazy < ty:: Generics > > ,
226- pub predicates : Option < Lazy < ty:: GenericPredicates < ' tcx > > > ,
227- pub predicates_defined_on : Option < Lazy < ty:: GenericPredicates < ' tcx > > > ,
234+ pub predicates : Option < Lazy ! ( ty:: GenericPredicates <' tcx>) > ,
235+ pub predicates_defined_on : Option < Lazy ! ( ty:: GenericPredicates <' tcx>) > ,
228236
229- pub mir : Option < Lazy < mir:: Mir < ' tcx > > > ,
237+ pub mir : Option < Lazy ! ( mir:: Mir <' tcx>) > ,
230238}
231239
232240#[ derive( Copy , Clone , RustcEncodable , RustcDecodable ) ]
@@ -245,22 +253,22 @@ pub enum EntryKind<'tcx> {
245253 Existential ,
246254 Enum ( ReprOptions ) ,
247255 Field ,
248- Variant ( Lazy < VariantData < ' tcx > > ) ,
249- Struct ( Lazy < VariantData < ' tcx > > , ReprOptions ) ,
250- Union ( Lazy < VariantData < ' tcx > > , ReprOptions ) ,
251- Fn ( Lazy < FnData < ' tcx > > ) ,
252- ForeignFn ( Lazy < FnData < ' tcx > > ) ,
256+ Variant ( Lazy ! ( VariantData <' tcx>) ) ,
257+ Struct ( Lazy ! ( VariantData <' tcx>) , ReprOptions ) ,
258+ Union ( Lazy ! ( VariantData <' tcx>) , ReprOptions ) ,
259+ Fn ( Lazy ! ( FnData <' tcx>) ) ,
260+ ForeignFn ( Lazy ! ( FnData <' tcx>) ) ,
253261 Mod ( Lazy < ModData > ) ,
254262 MacroDef ( Lazy < MacroDef > ) ,
255- Closure ( Lazy < ClosureData < ' tcx > > ) ,
256- Generator ( Lazy < GeneratorData < ' tcx > > ) ,
257- Trait ( Lazy < TraitData < ' tcx > > ) ,
258- Impl ( Lazy < ImplData < ' tcx > > ) ,
259- Method ( Lazy < MethodData < ' tcx > > ) ,
263+ Closure ( Lazy ! ( ClosureData <' tcx>) ) ,
264+ Generator ( Lazy ! ( GeneratorData <' tcx>) ) ,
265+ Trait ( Lazy ! ( TraitData <' tcx>) ) ,
266+ Impl ( Lazy ! ( ImplData <' tcx>) ) ,
267+ Method ( Lazy ! ( MethodData <' tcx>) ) ,
260268 AssociatedType ( AssociatedContainer ) ,
261269 AssociatedExistential ( AssociatedContainer ) ,
262270 AssociatedConst ( AssociatedContainer , ConstQualif , Lazy < RenderedConst > ) ,
263- TraitAlias ( Lazy < TraitAliasData < ' tcx > > ) ,
271+ TraitAlias ( Lazy ! ( TraitAliasData <' tcx>) ) ,
264272}
265273
266274/// Additional data for EntryKind::Const and EntryKind::AssociatedConst
@@ -290,7 +298,7 @@ pub struct MacroDef {
290298pub struct FnData < ' tcx > {
291299 pub constness : hir:: Constness ,
292300 pub arg_names : Lazy < [ ast:: Name ] > ,
293- pub sig : Lazy < ty:: PolyFnSig < ' tcx > > ,
301+ pub sig : Lazy ! ( ty:: PolyFnSig <' tcx>) ,
294302}
295303
296304#[ derive( RustcEncodable , RustcDecodable ) ]
@@ -301,7 +309,7 @@ pub struct VariantData<'tcx> {
301309 pub ctor : Option < DefIndex > ,
302310 /// If this is a tuple struct or variant
303311 /// ctor, this is its "function" signature.
304- pub ctor_sig : Option < Lazy < ty:: PolyFnSig < ' tcx > > > ,
312+ pub ctor_sig : Option < Lazy ! ( ty:: PolyFnSig <' tcx>) > ,
305313}
306314
307315#[ derive( RustcEncodable , RustcDecodable ) ]
@@ -310,12 +318,12 @@ pub struct TraitData<'tcx> {
310318 pub paren_sugar : bool ,
311319 pub has_auto_impl : bool ,
312320 pub is_marker : bool ,
313- pub super_predicates : Lazy < ty:: GenericPredicates < ' tcx > > ,
321+ pub super_predicates : Lazy ! ( ty:: GenericPredicates <' tcx>) ,
314322}
315323
316324#[ derive( RustcEncodable , RustcDecodable ) ]
317325pub struct TraitAliasData < ' tcx > {
318- pub super_predicates : Lazy < ty:: GenericPredicates < ' tcx > > ,
326+ pub super_predicates : Lazy ! ( ty:: GenericPredicates <' tcx>) ,
319327}
320328
321329#[ derive( RustcEncodable , RustcDecodable ) ]
@@ -326,7 +334,7 @@ pub struct ImplData<'tcx> {
326334
327335 /// This is `Some` only for impls of `CoerceUnsized`.
328336 pub coerce_unsized_info : Option < ty:: adjustment:: CoerceUnsizedInfo > ,
329- pub trait_ref : Option < Lazy < ty:: TraitRef < ' tcx > > > ,
337+ pub trait_ref : Option < Lazy ! ( ty:: TraitRef <' tcx>) > ,
330338}
331339
332340
@@ -377,7 +385,7 @@ pub struct MethodData<'tcx> {
377385
378386#[ derive( RustcEncodable , RustcDecodable ) ]
379387pub struct ClosureData < ' tcx > {
380- pub sig : Lazy < ty:: PolyFnSig < ' tcx > > ,
388+ pub sig : Lazy ! ( ty:: PolyFnSig <' tcx>) ,
381389}
382390
383391#[ derive( RustcEncodable , RustcDecodable ) ]
0 commit comments