Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit d8bd4e7

Browse files
committed
Projection Changes
1 parent a013ba8 commit d8bd4e7

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

hir-place-target.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
We are going to be refactoring [HIR places] to capture sufficient detail for us to use them to describe the places that a closure captures.
1+
We are going to be refactoring [HIR places] to capture sufficient detail for us to use them to describe the places that a closure captures.
22

33
The expected target structure looks something like this:
44

55
```rust
66
/// A reference to a particular place that appears in the source code
7-
struct PlaceReference<'tcx> {
7+
struct PlaceWithHirId<'tcx> {
88
/// the place being referenced
99
place: Place<'tcx>,
10-
10+
1111
/// hir-id of source expression or pattern
1212
hir_id: HirId,
13-
13+
1414
// Maybe no Span, since they're being removed from the Hir
1515
}
1616

@@ -19,38 +19,44 @@ struct PlaceReference<'tcx> {
1919
struct Place<'tcx> {
2020
/// start of the place expression, typically a local variable
2121
base: PlaceBase,
22-
23-
/// projections select parts of the base expression; e.g.,
22+
23+
/// Type of the Base
24+
base_ty: Ty<'tcx>,
25+
26+
/// projections select parts of the base expression; e.g.,
2427
/// in the place expression `a.b.c`, `b` and `c` are projections
2528
projections: Vec<Projection<'tcx>>,
2629
}
2730

28-
/// *Projections* select parts of the base expression; e.g.,
31+
/// *Projections* select parts of the base expression; e.g.,
2932
/// in the place expression `a.b.c`, `b` and `c` are projections
3033
struct Projection<'tcx> {
31-
/// Type of the projection thus far.
32-
ty: Ty<'tcx>,
33-
34-
///
34+
/// Type before the projection is applied.
35+
before_ty: Ty<'tcx>,
36+
37+
/// type of the projection.
3538
kind: ProjectionKind,
39+
40+
/// Type after the projection is applied.
41+
after_ty: Ty<'tcx>,
3642
}
3743

3844
/// Kinds of projections
3945
enum ProjectionKind {
4046
/// `*B`, where `B` is the base expression
4147
Deref,
42-
48+
4349
/// `B.F` where `B` is the base expression and `F` is
4450
/// the field. The field is identified by which variant
4551
/// it appears in along with a field index. The variant
4652
/// is used for enums.
4753
Field(Field, VariantIdx),
48-
54+
4955
/// Some index like `B[x]`, where `B` is the base
5056
/// expression. We don't preserve the index `x` because
5157
/// we won't need it.
5258
Index,
53-
59+
5460
/// A subslice covering a range of values like `B[x..y]`.
5561
Subslice,
5662
}

0 commit comments

Comments
 (0)