@@ -156,6 +156,14 @@ crate enum LazyState {
156
156
Previous ( NonZeroUsize ) ,
157
157
}
158
158
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
+
159
167
#[ derive( RustcEncodable , RustcDecodable ) ]
160
168
crate struct CrateRoot < ' tcx > {
161
169
pub name : Symbol ,
@@ -183,10 +191,10 @@ crate struct CrateRoot<'tcx> {
183
191
pub source_map : Lazy < [ syntax_pos:: SourceFile ] > ,
184
192
pub def_path_table : Lazy < hir:: map:: definitions:: DefPathTable > ,
185
193
pub impls : Lazy < [ TraitImpls ] > ,
186
- pub exported_symbols : Lazy < [ ( ExportedSymbol < ' tcx > , SymbolExportLevel ) ] > ,
194
+ pub exported_symbols : Lazy ! ( [ ( ExportedSymbol <' tcx>, SymbolExportLevel ) ] ) ,
187
195
pub interpret_alloc_index : Lazy < [ u32 ] > ,
188
196
189
- pub entries_table : Lazy < [ Table < ' tcx > ] > ,
197
+ pub entries_table : Lazy ! ( [ Table <Entry < ' tcx>> ] ) ,
190
198
191
199
/// The DefIndex's of any proc macros delcared by
192
200
/// this crate
@@ -226,14 +234,14 @@ crate struct Entry<'tcx> {
226
234
pub stability : Option < Lazy < attr:: Stability > > ,
227
235
pub deprecation : Option < Lazy < attr:: Deprecation > > ,
228
236
229
- pub ty : Option < Lazy < Ty < ' tcx > > > ,
237
+ pub ty : Option < Lazy ! ( Ty <' tcx>) > ,
230
238
pub inherent_impls : Lazy < [ DefIndex ] > ,
231
239
pub variances : Lazy < [ ty:: Variance ] > ,
232
240
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>) > ,
235
243
236
- pub mir : Option < Lazy < mir:: Body < ' tcx > > > ,
244
+ pub mir : Option < Lazy ! ( mir:: Body <' tcx>) > ,
237
245
pub promoted_mir : Option < Lazy < IndexVec < mir:: Promoted , mir:: Body < ' tcx > > > > ,
238
246
}
239
247
@@ -253,22 +261,22 @@ crate enum EntryKind<'tcx> {
253
261
OpaqueTy ,
254
262
Enum ( ReprOptions ) ,
255
263
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>) ) ,
261
269
Mod ( Lazy < ModData > ) ,
262
270
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>) ) ,
268
276
AssocType ( AssocContainer ) ,
269
277
AssocOpaqueTy ( AssocContainer ) ,
270
278
AssocConst ( AssocContainer , ConstQualif , Lazy < RenderedConst > ) ,
271
- TraitAlias ( Lazy < TraitAliasData < ' tcx > > ) ,
279
+ TraitAlias ( Lazy ! ( TraitAliasData <' tcx>) ) ,
272
280
}
273
281
274
282
/// Additional data for EntryKind::Const and EntryKind::AssocConst
@@ -298,7 +306,7 @@ crate struct FnData<'tcx> {
298
306
pub asyncness : hir:: IsAsync ,
299
307
pub constness : hir:: Constness ,
300
308
pub param_names : Lazy < [ ast:: Name ] > ,
301
- pub sig : Lazy < ty:: PolyFnSig < ' tcx > > ,
309
+ pub sig : Lazy ! ( ty:: PolyFnSig <' tcx>) ,
302
310
}
303
311
304
312
#[ derive( RustcEncodable , RustcDecodable ) ]
@@ -309,7 +317,7 @@ crate struct VariantData<'tcx> {
309
317
pub ctor : Option < DefIndex > ,
310
318
/// If this is a tuple struct or variant
311
319
/// ctor, this is its "function" signature.
312
- pub ctor_sig : Option < Lazy < ty:: PolyFnSig < ' tcx > > > ,
320
+ pub ctor_sig : Option < Lazy ! ( ty:: PolyFnSig <' tcx>) > ,
313
321
}
314
322
315
323
#[ derive( RustcEncodable , RustcDecodable ) ]
@@ -318,12 +326,12 @@ crate struct TraitData<'tcx> {
318
326
pub paren_sugar : bool ,
319
327
pub has_auto_impl : bool ,
320
328
pub is_marker : bool ,
321
- pub super_predicates : Lazy < ty:: GenericPredicates < ' tcx > > ,
329
+ pub super_predicates : Lazy ! ( ty:: GenericPredicates <' tcx>) ,
322
330
}
323
331
324
332
#[ derive( RustcEncodable , RustcDecodable ) ]
325
333
crate struct TraitAliasData < ' tcx > {
326
- pub super_predicates : Lazy < ty:: GenericPredicates < ' tcx > > ,
334
+ pub super_predicates : Lazy ! ( ty:: GenericPredicates <' tcx>) ,
327
335
}
328
336
329
337
#[ derive( RustcEncodable , RustcDecodable ) ]
@@ -334,7 +342,7 @@ crate struct ImplData<'tcx> {
334
342
335
343
/// This is `Some` only for impls of `CoerceUnsized`.
336
344
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>) > ,
338
346
}
339
347
340
348
@@ -385,7 +393,7 @@ crate struct MethodData<'tcx> {
385
393
386
394
#[ derive( RustcEncodable , RustcDecodable ) ]
387
395
crate struct ClosureData < ' tcx > {
388
- pub sig : Lazy < ty:: PolyFnSig < ' tcx > > ,
396
+ pub sig : Lazy ! ( ty:: PolyFnSig <' tcx>) ,
389
397
}
390
398
391
399
#[ derive( RustcEncodable , RustcDecodable ) ]
0 commit comments