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
33The 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> {
1919struct 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
3033struct 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
3945enum 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