]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/ty/layout.rs
Merge remote-tracking branch 'origin/master' into gen
[rust.git] / src / librustc / ty / layout.rs
index 4ee9b2e65a782ac79c88ad3062caaeb6e7cb8df3..cf21a66d51538f9d66147b9185783030d17e7cfe 100644 (file)
@@ -1226,7 +1226,17 @@ pub fn compute_uncached(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                 Univariant { variant: unit, non_zero: false }
             }
 
-            // Tuples and closures.
+            // Tuples, generators and closures.
+            ty::TyGenerator(def_id, ref substs, _) => {
+                let tys = substs.field_tys(def_id, tcx);
+                let st = Struct::new(dl,
+                    &tys.map(|ty| ty.layout(tcx, param_env))
+                      .collect::<Result<Vec<_>, _>>()?,
+                    &ReprOptions::default(),
+                    StructKind::AlwaysSizedUnivariant, ty)?;
+                Univariant { variant: st, non_zero: false }
+            }
+
             ty::TyClosure(def_id, ref substs) => {
                 let tys = substs.upvar_tys(def_id, tcx);
                 let st = Struct::new(dl,
@@ -2240,11 +2250,15 @@ pub fn field_type<C: LayoutTyper<'tcx>>(&self, cx: C, i: usize) -> Ty<'tcx> {
             ty::TySlice(element) => element,
             ty::TyStr => tcx.types.u8,
 
-            // Tuples and closures.
+            // Tuples, generators and closures.
             ty::TyClosure(def_id, ref substs) => {
                 substs.upvar_tys(def_id, tcx).nth(i).unwrap()
             }
 
+            ty::TyGenerator(def_id, ref substs, _) => {
+                substs.field_tys(def_id, tcx).nth(i).unwrap()
+            }
+
             ty::TyTuple(tys, _) => tys[i],
 
             // SIMD vector types.