@@ -270,6 +270,10 @@ impl<'tcx> TyCtxt<'tcx> {
270
270
/// Returns the deeply last field of nested structures, or the same type if
271
271
/// not a structure at all. Corresponds to the only possible unsized field,
272
272
/// and its type can be used to determine unsizing strategy.
273
+ ///
274
+ /// Should only be called if `ty` has no inference variables and does not
275
+ /// need its lifetimes preserved (e.g. as part of codegen); otherwise
276
+ /// normalization attempt may cause compiler bugs.
273
277
pub fn struct_tail_erasing_lifetimes ( self ,
274
278
ty : Ty < ' tcx > ,
275
279
param_env : ty:: ParamEnv < ' tcx > )
@@ -287,8 +291,8 @@ impl<'tcx> TyCtxt<'tcx> {
287
291
/// handle `<T as Trait>::Assoc` and `impl Trait`); pass the identity
288
292
/// function to indicate no normalization should take place.
289
293
///
290
- /// See also `struct_tail_erasing_lifetimes`, which is what callers running
291
- /// after type checking should use .
294
+ /// See also `struct_tail_erasing_lifetimes`, which is suitable for use
295
+ /// during codegen .
292
296
pub fn struct_tail_with_normalize ( self ,
293
297
mut ty : Ty < ' tcx > ,
294
298
normalize : impl Fn ( Ty < ' tcx > ) -> Ty < ' tcx > )
@@ -337,7 +341,8 @@ impl<'tcx> TyCtxt<'tcx> {
337
341
/// For `(Foo<Foo<T>>, Foo<dyn Trait>)`, the result will be `(Foo<T>, Trait)`,
338
342
/// whereas struct_tail produces `T`, and `Trait`, respectively.
339
343
///
340
- /// Must only be called after type-checking is complete; otherwise
344
+ /// Should only be called if the types have no inference variables and do
345
+ /// not need their lifetimes preserved (e.g. as part of codegen); otherwise
341
346
/// normalization attempt may cause compiler bugs.
342
347
pub fn struct_lockstep_tails_erasing_lifetimes ( self ,
343
348
source : Ty < ' tcx > ,
@@ -356,8 +361,8 @@ impl<'tcx> TyCtxt<'tcx> {
356
361
/// For `(Foo<Foo<T>>, Foo<dyn Trait>)`, the result will be `(Foo<T>, Trait)`,
357
362
/// whereas struct_tail produces `T`, and `Trait`, respectively.
358
363
///
359
- /// See also struct_lockstep_tails_erasing_lifetimes, which
360
- /// is what callers running after type checking should use .
364
+ /// See also ` struct_lockstep_tails_erasing_lifetimes` , which is suitable for use
365
+ /// during codegen .
361
366
pub fn struct_lockstep_tails_with_normalize ( self ,
362
367
source : Ty < ' tcx > ,
363
368
target : Ty < ' tcx > ,
0 commit comments