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,41 @@ 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 of the projection.
3535 kind : ProjectionKind ,
36+
37+ /// Type after the projection is applied.
38+ after_ty : Ty <'tcx >,
3639}
3740
3841/// Kinds of projections
3942enum ProjectionKind {
4043 /// `*B`, where `B` is the base expression
4144 Deref ,
42-
45+
4346 /// `B.F` where `B` is the base expression and `F` is
4447 /// the field. The field is identified by which variant
4548 /// it appears in along with a field index. The variant
4649 /// is used for enums.
4750 Field (Field , VariantIdx ),
48-
51+
4952 /// Some index like `B[x]`, where `B` is the base
5053 /// expression. We don't preserve the index `x` because
5154 /// we won't need it.
5255 Index ,
53-
56+
5457 /// A subslice covering a range of values like `B[x..y]`.
5558 Subslice ,
5659}
0 commit comments