@@ -156,6 +156,14 @@ crate enum LazyState {
156156 Previous ( NonZeroUsize ) ,
157157}
158158
159+ // FIXME(#59875) `Lazy!(T)` replaces `Lazy<T>`, passing the `Meta` parameter
160+ // manually, instead of relying on the default, to get the correct variance.
161+ // Only needed when `T` itself contains a parameter (e.g. `'tcx`).
162+ macro_rules! Lazy {
163+ ( [ $T: ty] ) => { Lazy <[ $T] , usize >} ;
164+ ( $T: ty) => { Lazy <$T, ( ) >} ;
165+ }
166+
159167#[ derive( RustcEncodable , RustcDecodable ) ]
160168crate struct CrateRoot < ' tcx > {
161169 pub name : Symbol ,
@@ -183,10 +191,10 @@ crate struct CrateRoot<'tcx> {
183191 pub source_map : Lazy < [ syntax_pos:: SourceFile ] > ,
184192 pub def_path_table : Lazy < hir:: map:: definitions:: DefPathTable > ,
185193 pub impls : Lazy < [ TraitImpls ] > ,
186- pub exported_symbols : Lazy < [ ( ExportedSymbol < ' tcx > , SymbolExportLevel ) ] > ,
194+ pub exported_symbols : Lazy ! ( [ ( ExportedSymbol <' tcx>, SymbolExportLevel ) ] ) ,
187195 pub interpret_alloc_index : Lazy < [ u32 ] > ,
188196
189- pub entries_table : Lazy < [ Table < ' tcx > ] > ,
197+ pub entries_table : Lazy ! ( [ Table <Entry < ' tcx>> ] ) ,
190198
191199 /// The DefIndex's of any proc macros delcared by
192200 /// this crate
@@ -226,14 +234,14 @@ crate struct Entry<'tcx> {
226234 pub stability : Option < Lazy < attr:: Stability > > ,
227235 pub deprecation : Option < Lazy < attr:: Deprecation > > ,
228236
229- pub ty : Option < Lazy < Ty < ' tcx > > > ,
237+ pub ty : Option < Lazy ! ( Ty <' tcx>) > ,
230238 pub inherent_impls : Lazy < [ DefIndex ] > ,
231239 pub variances : Lazy < [ ty:: Variance ] > ,
232240 pub generics : Option < Lazy < ty:: Generics > > ,
233- pub predicates : Option < Lazy < ty:: GenericPredicates < ' tcx > > > ,
234- pub predicates_defined_on : Option < Lazy < ty:: GenericPredicates < ' tcx > > > ,
241+ pub predicates : Option < Lazy ! ( ty:: GenericPredicates <' tcx>) > ,
242+ pub predicates_defined_on : Option < Lazy ! ( ty:: GenericPredicates <' tcx>) > ,
235243
236- pub mir : Option < Lazy < mir:: Body < ' tcx > > > ,
244+ pub mir : Option < Lazy ! ( mir:: Body <' tcx>) > ,
237245 pub promoted_mir : Option < Lazy < IndexVec < mir:: Promoted , mir:: Body < ' tcx > > > > ,
238246}
239247
@@ -253,22 +261,22 @@ crate enum EntryKind<'tcx> {
253261 OpaqueTy ,
254262 Enum ( ReprOptions ) ,
255263 Field ,
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 > > ) ,
264+ Variant ( Lazy ! ( VariantData <' tcx>) ) ,
265+ Struct ( Lazy ! ( VariantData <' tcx>) , ReprOptions ) ,
266+ Union ( Lazy ! ( VariantData <' tcx>) , ReprOptions ) ,
267+ Fn ( Lazy ! ( FnData <' tcx>) ) ,
268+ ForeignFn ( Lazy ! ( FnData <' tcx>) ) ,
261269 Mod ( Lazy < ModData > ) ,
262270 MacroDef ( Lazy < MacroDef > ) ,
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 > > ) ,
271+ Closure ( Lazy ! ( ClosureData <' tcx>) ) ,
272+ Generator ( Lazy ! ( GeneratorData <' tcx>) ) ,
273+ Trait ( Lazy ! ( TraitData <' tcx>) ) ,
274+ Impl ( Lazy ! ( ImplData <' tcx>) ) ,
275+ Method ( Lazy ! ( MethodData <' tcx>) ) ,
268276 AssocType ( AssocContainer ) ,
269277 AssocOpaqueTy ( AssocContainer ) ,
270278 AssocConst ( AssocContainer , ConstQualif , Lazy < RenderedConst > ) ,
271- TraitAlias ( Lazy < TraitAliasData < ' tcx > > ) ,
279+ TraitAlias ( Lazy ! ( TraitAliasData <' tcx>) ) ,
272280}
273281
274282/// Additional data for EntryKind::Const and EntryKind::AssocConst
@@ -298,7 +306,7 @@ crate struct FnData<'tcx> {
298306 pub asyncness : hir:: IsAsync ,
299307 pub constness : hir:: Constness ,
300308 pub param_names : Lazy < [ ast:: Name ] > ,
301- pub sig : Lazy < ty:: PolyFnSig < ' tcx > > ,
309+ pub sig : Lazy ! ( ty:: PolyFnSig <' tcx>) ,
302310}
303311
304312#[ derive( RustcEncodable , RustcDecodable ) ]
@@ -309,7 +317,7 @@ crate struct VariantData<'tcx> {
309317 pub ctor : Option < DefIndex > ,
310318 /// If this is a tuple struct or variant
311319 /// ctor, this is its "function" signature.
312- pub ctor_sig : Option < Lazy < ty:: PolyFnSig < ' tcx > > > ,
320+ pub ctor_sig : Option < Lazy ! ( ty:: PolyFnSig <' tcx>) > ,
313321}
314322
315323#[ derive( RustcEncodable , RustcDecodable ) ]
@@ -318,12 +326,12 @@ crate struct TraitData<'tcx> {
318326 pub paren_sugar : bool ,
319327 pub has_auto_impl : bool ,
320328 pub is_marker : bool ,
321- pub super_predicates : Lazy < ty:: GenericPredicates < ' tcx > > ,
329+ pub super_predicates : Lazy ! ( ty:: GenericPredicates <' tcx>) ,
322330}
323331
324332#[ derive( RustcEncodable , RustcDecodable ) ]
325333crate struct TraitAliasData < ' tcx > {
326- pub super_predicates : Lazy < ty:: GenericPredicates < ' tcx > > ,
334+ pub super_predicates : Lazy ! ( ty:: GenericPredicates <' tcx>) ,
327335}
328336
329337#[ derive( RustcEncodable , RustcDecodable ) ]
@@ -334,7 +342,7 @@ crate struct ImplData<'tcx> {
334342
335343 /// This is `Some` only for impls of `CoerceUnsized`.
336344 pub coerce_unsized_info : Option < ty:: adjustment:: CoerceUnsizedInfo > ,
337- pub trait_ref : Option < Lazy < ty:: TraitRef < ' tcx > > > ,
345+ pub trait_ref : Option < Lazy ! ( ty:: TraitRef <' tcx>) > ,
338346}
339347
340348
@@ -385,7 +393,7 @@ crate struct MethodData<'tcx> {
385393
386394#[ derive( RustcEncodable , RustcDecodable ) ]
387395crate struct ClosureData < ' tcx > {
388- pub sig : Lazy < ty:: PolyFnSig < ' tcx > > ,
396+ pub sig : Lazy ! ( ty:: PolyFnSig <' tcx>) ,
389397}
390398
391399#[ derive( RustcEncodable , RustcDecodable ) ]
0 commit comments