]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/ty/util.rs
Merge remote-tracking branch 'origin/master' into gen
[rust.git] / src / librustc / ty / util.rs
index 9cd6aa2111873a69f9becbb6b011e205b25f2978..82810b7aae1bb1a70b93af6f6c5399ed8c6929be 100644 (file)
@@ -27,6 +27,7 @@
                                            HashStable};
 use rustc_data_structures::fx::FxHashMap;
 use std::cmp;
+use std::iter;
 use std::hash::Hash;
 use std::intrinsics;
 use syntax::ast::{self, Name};
@@ -573,6 +574,12 @@ pub fn dtorck_constraint_for_ty(self,
                 }).collect()
             }
 
+            ty::TyGenerator(def_id, substs, interior) => {
+                substs.upvar_tys(def_id, self).chain(iter::once(interior.witness)).map(|ty| {
+                    self.dtorck_constraint_for_ty(span, for_ty, depth+1, ty)
+                }).collect()
+            }
+
             ty::TyAdt(def, substs) => {
                 let ty::DtorckConstraint {
                     dtorck_types, outlives
@@ -694,6 +701,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
             TyRawPtr(m) |
             TyRef(_, m) => self.hash(m.mutbl),
             TyClosure(def_id, _) |
+            TyGenerator(def_id, _, _) |
             TyAnon(def_id, _) |
             TyFnDef(def_id, _) => self.def_id(def_id),
             TyAdt(d, _) => self.def_id(d.did),
@@ -1116,6 +1124,8 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
         ty::TyClosure(def_id, ref substs) => substs.upvar_tys(def_id, tcx).any(needs_drop),
 
+        ty::TyGenerator(..) => true,
+
         ty::TyTuple(ref tys, _) => tys.iter().cloned().any(needs_drop),
 
         // unions don't have destructors regardless of the child types