@@ -398,22 +398,23 @@ pub enum Operand {
398398pub struct Place {
399399 pub local : Local ,
400400 /// projection out of a place (access a field, deref a pointer, etc)
401- pub projection : Vec < ProjectionElem < Local , Ty > > ,
401+ pub projection : Vec < ProjectionElem > ,
402402}
403403
404- // TODO(klinvill): in MIR ProjectionElem is parameterized on the second Field argument and the Index
405- // argument. This is so it can be used for both the rust provided Places (for which the projection
406- // elements are of type ProjectionElem<Local, Ty>) and user-provided type annotations (for which the
407- // projection elements are of type ProjectionElem<(), ()>). Should we do the same thing in Stable MIR?
404+ // In MIR ProjectionElem is parameterized on the second Field argument and the Index argument. This
405+ // is so it can be used for both Places (for which the projection elements are of type
406+ // ProjectionElem<Local, Ty>) and user-provided type annotations (for which the projection elements
407+ // are of type ProjectionElem<(), ()>). In SMIR we don't need this generality, so we just use
408+ // ProjectionElem for Places.
408409#[ derive( Clone , Debug ) ]
409- pub enum ProjectionElem < V , T > {
410+ pub enum ProjectionElem {
410411 /// Dereference projections (e.g. `*_1`) project to the address referenced by the base place.
411412 Deref ,
412413
413414 /// A field projection (e.g., `f` in `_1.f`) project to a field in the base place. The field is
414415 /// referenced by source-order index rather than the name of the field. The fields type is also
415416 /// given.
416- Field ( FieldIdx , T ) ,
417+ Field ( FieldIdx , Ty ) ,
417418
418419 /// Index into a slice/array. The value of the index is computed at runtime using the `V`
419420 /// argument.
@@ -429,7 +430,7 @@ pub enum ProjectionElem<V, T> {
429430 ///
430431 /// The `x[i]` is turned into a `Deref` followed by an `Index`, not just an `Index`. The same
431432 /// thing is true of the `ConstantIndex` and `Subslice` projections below.
432- Index ( V ) ,
433+ Index ( Local ) ,
433434
434435 /// Index into a slice/array given by offsets.
435436 ///
@@ -472,24 +473,22 @@ pub enum ProjectionElem<V, T> {
472473
473474 /// Like an explicit cast from an opaque type to a concrete type, but without
474475 /// requiring an intermediate variable.
475- OpaqueCast ( T ) ,
476+ OpaqueCast ( Ty ) ,
476477
477478 /// A `Subtype(T)` projection is applied to any `StatementKind::Assign` where
478479 /// type of lvalue doesn't match the type of rvalue, the primary goal is making subtyping
479480 /// explicit during optimizations and codegen.
480481 ///
481482 /// This projection doesn't impact the runtime behavior of the program except for potentially changing
482483 /// some type metadata of the interpreter or codegen backend.
483- Subtype ( T ) ,
484+ Subtype ( Ty ) ,
484485}
485486
486487#[ derive( Clone , Debug , Eq , PartialEq ) ]
487488pub struct UserTypeProjection {
488489 pub base : UserTypeAnnotationIndex ,
489490
490- /// `UserTypeProjection` projections need neither the `V` parameter for `Index` nor the `T` for
491- /// `Field`.
492- pub projection : Vec < ProjectionElem < ( ) , ( ) > > ,
491+ pub projection : String ,
493492}
494493
495494pub type Local = usize ;
0 commit comments