Explain RPITs in the way they actually work
This commit is contained in:
parent
5b4549dd13
commit
30f787800a
@ -545,17 +545,23 @@ fn sanity_check_found_hidden_type<'tcx>(
|
|||||||
/// }
|
/// }
|
||||||
/// fn func<'a>(x: &'a ()) -> impl Id<Assoc = impl Sized + 'a> { x }
|
/// fn func<'a>(x: &'a ()) -> impl Id<Assoc = impl Sized + 'a> { x }
|
||||||
/// // desugared to
|
/// // desugared to
|
||||||
|
/// fn func<'a>(x: &'a () -> Outer<'a, Assoc = Inner<'a>> {
|
||||||
|
/// // Note that in contrast to other nested items, RPIT type aliases can
|
||||||
|
/// // access their parents' generics.
|
||||||
///
|
///
|
||||||
/// // hidden type is `&'bDup ()`
|
/// // hidden type is `&'aDupOuter ()`
|
||||||
/// // During wfcheck the hidden type of `Inner` is `&'a ()`, but
|
/// // During wfcheck the hidden type of `Inner<'aDupOuter>` is `&'a ()`, but
|
||||||
/// // `typeof(Inner<'b, 'bDup>) = &'bDup ()`.
|
/// // `typeof(Inner<'aDupOuter>) = &'aDupOuter ()`.
|
||||||
/// // So we walk the signature of `func` to find the use of `Inner<'static, 'a>`
|
/// // So we walk the signature of `func` to find the use of `Inner<'a>`
|
||||||
/// // and then use that to replace the lifetimes in the hidden type, obtaining
|
/// // and then use that to replace the lifetimes in the hidden type, obtaining
|
||||||
/// // `&'a ()`.
|
/// // `&'a ()`.
|
||||||
/// type Outer<'b, 'bDup> = impl Id<Assoc = Inner<'b, 'bDup>>;
|
/// type Outer<'aDupOuter> = impl Id<Assoc = Inner<'aDupOuter>>;
|
||||||
/// // hidden type is `&'cDup ()`
|
///
|
||||||
/// type Inner<'c, 'cDup> = impl Sized + 'cDup;
|
/// // hidden type is `&'aDupInner ()`
|
||||||
/// fn func<'a>(x: &'a () -> Outer<'static, 'a> { x }
|
/// type Inner<'aDupInner> = impl Sized + 'aDupInner;
|
||||||
|
///
|
||||||
|
/// x
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn find_and_apply_rpit_args<'tcx>(
|
fn find_and_apply_rpit_args<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
|
Loading…
Reference in New Issue
Block a user