We have quite a bit of code that needs to work with the projections that make up a Place or PlaceRef. Much of it works with the projections array directly, which is rather verbose. We now have better APIs that avoid having to "break the abstraction" of Place/PlaceRef: we have Place::iter_projections and PlaceRef::last_projection.
It would be good to clean things up by using these higher-level APIs consistently. To do that, you'll need to find places where the lower-level API is used. One good way to find these places is to grep for Place::ty_from -- this helper function is only useful when a PlaceRef has been broken apart into its constituents, so it is a sign that some higher-level APIs can be used. In almost all cases, the code will either "do something with the last projection (if any)", in which case it should use PlaceRef::last_projection, or it will iterate all the projections, in which case it should use Place::iter_projections (usually iteration starts with the outermost projection, i.e., you should use place.iter_projections().rev()).
You can see #80624 for some examples for the kinds of changes that are needed to perform this cleanup.
We have quite a bit of code that needs to work with the
projectionsthat make up aPlaceorPlaceRef. Much of it works with theprojectionsarray directly, which is rather verbose. We now have better APIs that avoid having to "break the abstraction" ofPlace/PlaceRef: we havePlace::iter_projectionsandPlaceRef::last_projection.It would be good to clean things up by using these higher-level APIs consistently. To do that, you'll need to find places where the lower-level API is used. One good way to find these places is to grep for
Place::ty_from-- this helper function is only useful when aPlaceRefhas been broken apart into its constituents, so it is a sign that some higher-level APIs can be used. In almost all cases, the code will either "do something with the last projection (if any)", in which case it should usePlaceRef::last_projection, or it will iterate all the projections, in which case it should usePlace::iter_projections(usually iteration starts with the outermost projection, i.e., you should useplace.iter_projections().rev()).You can see #80624 for some examples for the kinds of changes that are needed to perform this cleanup.