@@ -155,6 +155,14 @@ pub enum LazyState {
155
155
Previous ( NonZeroUsize ) ,
156
156
}
157
157
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
+
158
166
#[ derive( RustcEncodable , RustcDecodable ) ]
159
167
pub struct CrateRoot < ' tcx > {
160
168
pub name : Symbol ,
@@ -181,10 +189,10 @@ pub struct CrateRoot<'tcx> {
181
189
pub source_map : Lazy < [ syntax_pos:: SourceFile ] > ,
182
190
pub def_path_table : Lazy < hir:: map:: definitions:: DefPathTable > ,
183
191
pub impls : Lazy < [ TraitImpls ] > ,
184
- pub exported_symbols : Lazy < [ ( ExportedSymbol < ' tcx > , SymbolExportLevel ) ] > ,
192
+ pub exported_symbols : Lazy ! ( [ ( ExportedSymbol <' tcx>, SymbolExportLevel ) ] ) ,
185
193
pub interpret_alloc_index : Lazy < [ u32 ] > ,
186
194
187
- pub entries_table : Lazy < [ Table < ' tcx > ] > ,
195
+ pub entries_table : Lazy ! ( [ Table <Entry < ' tcx>> ] ) ,
188
196
189
197
pub compiler_builtins : bool ,
190
198
pub needs_allocator : bool ,
@@ -219,14 +227,14 @@ pub struct Entry<'tcx> {
219
227
pub stability : Option < Lazy < attr:: Stability > > ,
220
228
pub deprecation : Option < Lazy < attr:: Deprecation > > ,
221
229
222
- pub ty : Option < Lazy < Ty < ' tcx > > > ,
230
+ pub ty : Option < Lazy ! ( Ty <' tcx>) > ,
223
231
pub inherent_impls : Lazy < [ DefIndex ] > ,
224
232
pub variances : Lazy < [ ty:: Variance ] > ,
225
233
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>) > ,
228
236
229
- pub mir : Option < Lazy < mir:: Mir < ' tcx > > > ,
237
+ pub mir : Option < Lazy ! ( mir:: Mir <' tcx>) > ,
230
238
}
231
239
232
240
#[ derive( Copy , Clone , RustcEncodable , RustcDecodable ) ]
@@ -245,22 +253,22 @@ pub enum EntryKind<'tcx> {
245
253
Existential ,
246
254
Enum ( ReprOptions ) ,
247
255
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>) ) ,
253
261
Mod ( Lazy < ModData > ) ,
254
262
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>) ) ,
260
268
AssociatedType ( AssociatedContainer ) ,
261
269
AssociatedExistential ( AssociatedContainer ) ,
262
270
AssociatedConst ( AssociatedContainer , ConstQualif , Lazy < RenderedConst > ) ,
263
- TraitAlias ( Lazy < TraitAliasData < ' tcx > > ) ,
271
+ TraitAlias ( Lazy ! ( TraitAliasData <' tcx>) ) ,
264
272
}
265
273
266
274
/// Additional data for EntryKind::Const and EntryKind::AssociatedConst
@@ -290,7 +298,7 @@ pub struct MacroDef {
290
298
pub struct FnData < ' tcx > {
291
299
pub constness : hir:: Constness ,
292
300
pub arg_names : Lazy < [ ast:: Name ] > ,
293
- pub sig : Lazy < ty:: PolyFnSig < ' tcx > > ,
301
+ pub sig : Lazy ! ( ty:: PolyFnSig <' tcx>) ,
294
302
}
295
303
296
304
#[ derive( RustcEncodable , RustcDecodable ) ]
@@ -301,7 +309,7 @@ pub struct VariantData<'tcx> {
301
309
pub ctor : Option < DefIndex > ,
302
310
/// If this is a tuple struct or variant
303
311
/// ctor, this is its "function" signature.
304
- pub ctor_sig : Option < Lazy < ty:: PolyFnSig < ' tcx > > > ,
312
+ pub ctor_sig : Option < Lazy ! ( ty:: PolyFnSig <' tcx>) > ,
305
313
}
306
314
307
315
#[ derive( RustcEncodable , RustcDecodable ) ]
@@ -310,12 +318,12 @@ pub struct TraitData<'tcx> {
310
318
pub paren_sugar : bool ,
311
319
pub has_auto_impl : bool ,
312
320
pub is_marker : bool ,
313
- pub super_predicates : Lazy < ty:: GenericPredicates < ' tcx > > ,
321
+ pub super_predicates : Lazy ! ( ty:: GenericPredicates <' tcx>) ,
314
322
}
315
323
316
324
#[ derive( RustcEncodable , RustcDecodable ) ]
317
325
pub struct TraitAliasData < ' tcx > {
318
- pub super_predicates : Lazy < ty:: GenericPredicates < ' tcx > > ,
326
+ pub super_predicates : Lazy ! ( ty:: GenericPredicates <' tcx>) ,
319
327
}
320
328
321
329
#[ derive( RustcEncodable , RustcDecodable ) ]
@@ -326,7 +334,7 @@ pub struct ImplData<'tcx> {
326
334
327
335
/// This is `Some` only for impls of `CoerceUnsized`.
328
336
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>) > ,
330
338
}
331
339
332
340
@@ -377,7 +385,7 @@ pub struct MethodData<'tcx> {
377
385
378
386
#[ derive( RustcEncodable , RustcDecodable ) ]
379
387
pub struct ClosureData < ' tcx > {
380
- pub sig : Lazy < ty:: PolyFnSig < ' tcx > > ,
388
+ pub sig : Lazy ! ( ty:: PolyFnSig <' tcx>) ,
381
389
}
382
390
383
391
#[ derive( RustcEncodable , RustcDecodable ) ]
0 commit comments