This repository was archived by the owner on Apr 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Make hir::Place projections more precise #1
Copy link
Copy link
Closed
rust-lang/rust
#74140Description
The current HIR Place data structure includes only two kinds of projections:
- Deref
- Other
If you compare that to the MIR Place, you can see that the MIR version has a lot more kinds of projections. I'm making a list of them below. We may not need to add them all to HIR Place, but we probably want most of them. For each one, there is a check-box, and in some cases I may link to additional issues that give more details about how to make a change.
- Deref -- already exists
- Field (Refactoring HIR Place: Fields #2)
- Index
- ConstantIndex
- Subslice
- Downcast
Within the HIR we don't need to be as precise as the MIR.
- Downcast is use for enum variants and in Hir we can combine it with field
Field(u32, VariantIdx)
where theu32
is for the field within a struct. - Since we are capturing the complete array even if a single element is captured we don't need to preserve index information and store that information as just
Index
. ConstIndex
is used for some special cases where we know the index is a fixed constant -- mostly pattern matching likelet [a, b, _] = some_array
. The compiler is (sometimes) smart enough to see that these moves are distinct from (say)let [_, _, c] = some_array
, but to be that smart, it needs to know the indices as constants. We are just going to capture the entire array for now, so we don't care for now.