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.
2
2
3
3
The expected target structure looks something like this:
4
4
5
5
``` rust
6
6
/// A reference to a particular place that appears in the source code
7
- struct PlaceReference <'tcx > {
7
+ struct PlaceWithHirId <'tcx > {
8
8
/// the place being referenced
9
9
place : Place <'tcx >,
10
-
10
+
11
11
/// hir-id of source expression or pattern
12
12
hir_id : HirId ,
13
-
13
+
14
14
// Maybe no Span, since they're being removed from the Hir
15
15
}
16
16
@@ -19,38 +19,44 @@ struct PlaceReference<'tcx> {
19
19
struct Place <'tcx > {
20
20
/// start of the place expression, typically a local variable
21
21
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.,
24
27
/// in the place expression `a.b.c`, `b` and `c` are projections
25
28
projections : Vec <Projection <'tcx >>,
26
29
}
27
30
28
- /// *Projections* select parts of the base expression; e.g.,
31
+ /// *Projections* select parts of the base expression; e.g.,
29
32
/// in the place expression `a.b.c`, `b` and `c` are projections
30
33
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.
35
38
kind : ProjectionKind ,
39
+
40
+ /// Type after the projection is applied.
41
+ after_ty : Ty <'tcx >,
36
42
}
37
43
38
44
/// Kinds of projections
39
45
enum ProjectionKind {
40
46
/// `*B`, where `B` is the base expression
41
47
Deref ,
42
-
48
+
43
49
/// `B.F` where `B` is the base expression and `F` is
44
50
/// the field. The field is identified by which variant
45
51
/// it appears in along with a field index. The variant
46
52
/// is used for enums.
47
53
Field (Field , VariantIdx ),
48
-
54
+
49
55
/// Some index like `B[x]`, where `B` is the base
50
56
/// expression. We don't preserve the index `x` because
51
57
/// we won't need it.
52
58
Index ,
53
-
59
+
54
60
/// A subslice covering a range of values like `B[x..y]`.
55
61
Subslice ,
56
62
}
0 commit comments