Skip to content

Commit 3c8279a

Browse files
committed
Update docs to reflect review feedback.
1 parent e4b8af5 commit 3c8279a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/librustc/ty/util.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ impl<'tcx> TyCtxt<'tcx> {
270270
/// Returns the deeply last field of nested structures, or the same type if
271271
/// not a structure at all. Corresponds to the only possible unsized field,
272272
/// 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.
273277
pub fn struct_tail_erasing_lifetimes(self,
274278
ty: Ty<'tcx>,
275279
param_env: ty::ParamEnv<'tcx>)
@@ -287,8 +291,8 @@ impl<'tcx> TyCtxt<'tcx> {
287291
/// handle `<T as Trait>::Assoc` and `impl Trait`); pass the identity
288292
/// function to indicate no normalization should take place.
289293
///
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.
292296
pub fn struct_tail_with_normalize(self,
293297
mut ty: Ty<'tcx>,
294298
normalize: impl Fn(Ty<'tcx>) -> Ty<'tcx>)
@@ -337,7 +341,8 @@ impl<'tcx> TyCtxt<'tcx> {
337341
/// For `(Foo<Foo<T>>, Foo<dyn Trait>)`, the result will be `(Foo<T>, Trait)`,
338342
/// whereas struct_tail produces `T`, and `Trait`, respectively.
339343
///
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
341346
/// normalization attempt may cause compiler bugs.
342347
pub fn struct_lockstep_tails_erasing_lifetimes(self,
343348
source: Ty<'tcx>,
@@ -356,8 +361,8 @@ impl<'tcx> TyCtxt<'tcx> {
356361
/// For `(Foo<Foo<T>>, Foo<dyn Trait>)`, the result will be `(Foo<T>, Trait)`,
357362
/// whereas struct_tail produces `T`, and `Trait`, respectively.
358363
///
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.
361366
pub fn struct_lockstep_tails_with_normalize(self,
362367
source: Ty<'tcx>,
363368
target: Ty<'tcx>,

0 commit comments

Comments
 (0)