-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use PlaceRef abstraction more consistently #80647
Comments
This comment has been minimized.
This comment has been minimized.
Use PlaceRef projection abstractions more consistently in rustc_mir PlaceRef contains abstractions for dealing with the `projections` array. This PR uses these abstractions more consistently within the `rustc_mir` crate. See associated issue: rust-lang#80647. r? `@RalfJung`
Use PlaceRef projection abstractions more consistently in rustc_mir PlaceRef contains abstractions for dealing with the `projections` array. This PR uses these abstractions more consistently within the `rustc_mir` crate. See associated issue: rust-lang#80647. r? `@RalfJung`
Another thing I just noticed: |
Working on it in #82091 :) |
@henryboisdequin wrote
If you could leave a summary of the problem here, that'd be good. Note that I was specifically talking about |
@RalfJung, oops sorry, I think I messed up |
Also see this for another opportunity: |
… r=RalfJung use PlaceRef abstractions more consistently Addresses this [comment](https://github.com/rust-lang/rust/pull/80865/files#r558978715) Associated issue: rust-lang#80647 r? `@RalfJung`
… r=RalfJung use PlaceRef abstractions more consistently Addresses this [comment](https://github.com/rust-lang/rust/pull/80865/files#r558978715) Associated issue: rust-lang#80647 r? ``@RalfJung``
… r=RalfJung use PlaceRef abstractions more consistently Addresses this [comment](https://github.com/rust-lang/rust/pull/80865/files#r558978715) Associated issue: rust-lang#80647 r? ```@RalfJung```
Is this available? |
|
@rustbot claim |
…ishearth Use placeref abstraction rust-lang/rust#80647 suggests refactoring certain patterns with MIR places to use higher-level abstractions provided by the [`Place`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_middle/mir/struct.Place.html)/[`PlaceRef`](https://doc.rust-lang.org/stable/nightly-rustc/rustc_middle/mir/struct.PlaceRef.html). While working on that issue, I found a couple candidates for such refactoring in clippy. *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: none
…spastorino Use PlaceRef abstractions more often Associated issue: rust-lang#80647 r? `@spastorino`
Use PlaceRef abstractions more often Associated issue: rust-lang/rust#80647 r? `@spastorino`
Use PlaceRef abstractions more often Associated issue: rust-lang/rust#80647 r? `@spastorino`
Use PlaceRef abstractions more often Associated issue: rust-lang/rust#80647 r? `@spastorino`
We have quite a bit of code that needs to work with the
projections
that make up aPlace
orPlaceRef
. Much of it works with theprojections
array directly, which is rather verbose. We now have better APIs that avoid having to "break the abstraction" ofPlace
/PlaceRef
: we havePlace::iter_projections
andPlaceRef::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 aPlaceRef
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 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.
The text was updated successfully, but these errors were encountered: