Function rustc_middle::ty::is_ancestor_or_same_capture
source · pub fn is_ancestor_or_same_capture(
proj_possible_ancestor: &[ProjectionKind],
proj_capture: &[ProjectionKind]
) -> bool
Expand description
Return true if the proj_possible_ancestor
represents an ancestor path
to proj_capture
or proj_possible_ancestor
is same as proj_capture
,
assuming they both start off of the same root variable.
Note: It’s the caller’s responsibility to ensure that both lists of projections start off of the same root variable.
Eg: 1. foo.x
which is represented using projections=[Field(x)]
is an ancestor of
foo.x.y
which is represented using projections=[Field(x), Field(y)]
.
Note both foo.x
and foo.x.y
start off of the same root variable foo
.
2. Since we only look at the projections here function will return bar.x
as an a valid
ancestor of foo.x.y
. It’s the caller’s responsibility to ensure that both projections
list are being applied to the same root variable.