@@ -398,22 +398,23 @@ pub enum Operand {
398
398
pub struct Place {
399
399
pub local : Local ,
400
400
/// projection out of a place (access a field, deref a pointer, etc)
401
- pub projection : Vec < ProjectionElem < Local , Ty > > ,
401
+ pub projection : Vec < ProjectionElem > ,
402
402
}
403
403
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.
408
409
#[ derive( Clone , Debug ) ]
409
- pub enum ProjectionElem < V , T > {
410
+ pub enum ProjectionElem {
410
411
/// Dereference projections (e.g. `*_1`) project to the address referenced by the base place.
411
412
Deref ,
412
413
413
414
/// A field projection (e.g., `f` in `_1.f`) project to a field in the base place. The field is
414
415
/// referenced by source-order index rather than the name of the field. The fields type is also
415
416
/// given.
416
- Field ( FieldIdx , T ) ,
417
+ Field ( FieldIdx , Ty ) ,
417
418
418
419
/// Index into a slice/array. The value of the index is computed at runtime using the `V`
419
420
/// argument.
@@ -429,7 +430,7 @@ pub enum ProjectionElem<V, T> {
429
430
///
430
431
/// The `x[i]` is turned into a `Deref` followed by an `Index`, not just an `Index`. The same
431
432
/// thing is true of the `ConstantIndex` and `Subslice` projections below.
432
- Index ( V ) ,
433
+ Index ( Local ) ,
433
434
434
435
/// Index into a slice/array given by offsets.
435
436
///
@@ -472,24 +473,22 @@ pub enum ProjectionElem<V, T> {
472
473
473
474
/// Like an explicit cast from an opaque type to a concrete type, but without
474
475
/// requiring an intermediate variable.
475
- OpaqueCast ( T ) ,
476
+ OpaqueCast ( Ty ) ,
476
477
477
478
/// A `Subtype(T)` projection is applied to any `StatementKind::Assign` where
478
479
/// type of lvalue doesn't match the type of rvalue, the primary goal is making subtyping
479
480
/// explicit during optimizations and codegen.
480
481
///
481
482
/// This projection doesn't impact the runtime behavior of the program except for potentially changing
482
483
/// some type metadata of the interpreter or codegen backend.
483
- Subtype ( T ) ,
484
+ Subtype ( Ty ) ,
484
485
}
485
486
486
487
#[ derive( Clone , Debug , Eq , PartialEq ) ]
487
488
pub struct UserTypeProjection {
488
489
pub base : UserTypeAnnotationIndex ,
489
490
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 ,
493
492
}
494
493
495
494
pub type Local = usize ;
0 commit comments