@@ -605,6 +605,12 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
605
605
}
606
606
607
607
ty:: Generator ( def_id, ref substs, _) => {
608
+ // FIXME(tmandry): For fields that are repeated in multiple
609
+ // variants in the GeneratorLayout, we need code to ensure that
610
+ // the offset of these fields never change. Right now this is
611
+ // not an issue since every variant has every field, but once we
612
+ // optimize this we have to be more careful.
613
+
608
614
let discr_index = substs. prefix_tys ( def_id, tcx) . count ( ) ;
609
615
let prefix_tys = substs. prefix_tys ( def_id, tcx)
610
616
. chain ( iter:: once ( substs. discr_ty ( tcx) ) ) ;
@@ -1691,7 +1697,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
1691
1697
1692
1698
fn field ( this : TyLayout < ' tcx > , cx : & C , i : usize ) -> C :: TyLayout {
1693
1699
let tcx = cx. tcx ( ) ;
1694
- let handle_discriminant = |discr : & Scalar | -> C :: TyLayout {
1700
+ let discr_layout = |discr : & Scalar | -> C :: TyLayout {
1695
1701
let layout = LayoutDetails :: scalar ( cx, discr. clone ( ) ) ;
1696
1702
MaybeResult :: from_ok ( TyLayout {
1697
1703
details : tcx. intern_layout ( layout) ,
@@ -1781,7 +1787,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
1781
1787
}
1782
1788
Variants :: Multiple { ref discr, discr_index, .. } => {
1783
1789
if i == discr_index {
1784
- return handle_discriminant ( discr) ;
1790
+ return discr_layout ( discr) ;
1785
1791
}
1786
1792
substs. prefix_tys ( def_id, tcx) . nth ( i) . unwrap ( )
1787
1793
}
@@ -1805,7 +1811,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
1805
1811
// Discriminant field for enums (where applicable).
1806
1812
Variants :: Multiple { ref discr, .. } => {
1807
1813
assert_eq ! ( i, 0 ) ;
1808
- return handle_discriminant ( discr) ;
1814
+ return discr_layout ( discr) ;
1809
1815
}
1810
1816
}
1811
1817
}
0 commit comments