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

Commit

Permalink
Merge pull request #13 from rust-lang/projection_changes
Browse files Browse the repository at this point in the history
Projection Changes
  • Loading branch information
arora-aman committed Jul 2, 2020
2 parents fd06c83 + a1a400b commit f3ef8e6
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions hir-place-target.md
Original file line number Diff line number Diff line change
@@ -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
}

Expand All @@ -19,38 +19,41 @@ 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<Projection<'tcx>>,
}

/// *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 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,
}
Expand Down

0 comments on commit f3ef8e6

Please sign in to comment.