From d8bd4e7b388915dbfe532c003bee3171e96e5538 Mon Sep 17 00:00:00 2001 From: Aman Arora Date: Wed, 24 Jun 2020 23:18:37 -0400 Subject: [PATCH 1/2] Projection Changes --- hir-place-target.md | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/hir-place-target.md b/hir-place-target.md index 493fa3b..5977f76 100644 --- a/hir-place-target.md +++ b/hir-place-target.md @@ -1,16 +1,16 @@ -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. +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. The expected target structure looks something like this: ```rust /// A reference to a particular place that appears in the source code -struct PlaceReference<'tcx> { +struct PlaceWithHirId<'tcx> { /// the place being referenced place: Place<'tcx>, - + /// hir-id of source expression or pattern hir_id: HirId, - + // Maybe no Span, since they're being removed from the Hir } @@ -19,38 +19,44 @@ struct PlaceReference<'tcx> { struct Place<'tcx> { /// start of the place expression, typically a local variable base: PlaceBase, - - /// projections select parts of the base expression; e.g., + + /// Type of the Base + base_ty: Ty<'tcx>, + + /// projections select parts of the base expression; e.g., /// in the place expression `a.b.c`, `b` and `c` are projections projections: Vec>, } -/// *Projections* select parts of the base expression; e.g., +/// *Projections* select parts of the base expression; e.g., /// in the place expression `a.b.c`, `b` and `c` are projections struct Projection<'tcx> { - /// Type of the projection thus far. - ty: Ty<'tcx>, - - /// + /// Type before the projection is applied. + before_ty: Ty<'tcx>, + + /// type of the projection. kind: ProjectionKind, + + /// Type after the projection is applied. + after_ty: Ty<'tcx>, } /// Kinds of projections enum ProjectionKind { /// `*B`, where `B` is the base expression Deref, - + /// `B.F` where `B` is the base expression and `F` is /// the field. The field is identified by which variant /// it appears in along with a field index. The variant /// is used for enums. Field(Field, VariantIdx), - + /// Some index like `B[x]`, where `B` is the base /// expression. We don't preserve the index `x` because /// we won't need it. Index, - + /// A subslice covering a range of values like `B[x..y]`. Subslice, } From a1a400b47066126bdbce2266d76c08f59eb5acf3 Mon Sep 17 00:00:00 2001 From: Aman Arora Date: Mon, 29 Jun 2020 15:54:38 -0400 Subject: [PATCH 2/2] Update hir-place-target.md Add a method in `Place` to support `before_ty` in projections. --- hir-place-target.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/hir-place-target.md b/hir-place-target.md index 5977f76..bdad96a 100644 --- a/hir-place-target.md +++ b/hir-place-target.md @@ -31,9 +31,6 @@ struct Place<'tcx> { /// *Projections* select parts of the base expression; e.g., /// in the place expression `a.b.c`, `b` and `c` are projections struct Projection<'tcx> { - /// Type before the projection is applied. - before_ty: Ty<'tcx>, - /// type of the projection. kind: ProjectionKind,