]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/ty/mod.rs
Merge remote-tracking branch 'origin/master' into gen
[rust.git] / src / librustc / ty / mod.rs
index 28a73f4a4d387dcbe36170619619c236cd78baa0..0a3c4d5d8fa5a4114fc345e3204545dfcf1d6494 100644 (file)
@@ -25,6 +25,7 @@
 use middle::resolve_lifetime::ObjectLifetimeDefault;
 use middle::region::CodeExtent;
 use mir::Mir;
+use mir::GeneratorLayout;
 use traits;
 use ty;
 use ty::subst::{Subst, Substs};
@@ -59,9 +60,9 @@
 use hir;
 
 pub use self::sty::{Binder, DebruijnIndex};
-pub use self::sty::{FnSig, PolyFnSig};
+pub use self::sty::{FnSig, GenSig, PolyFnSig, PolyGenSig};
 pub use self::sty::{InferTy, ParamTy, ProjectionTy, ExistentialPredicate};
-pub use self::sty::{ClosureSubsts, TypeAndMut};
+pub use self::sty::{ClosureSubsts, GeneratorInterior, TypeAndMut};
 pub use self::sty::{TraitRef, TypeVariants, PolyTraitRef};
 pub use self::sty::{ExistentialTraitRef, PolyExistentialTraitRef};
 pub use self::sty::{ExistentialProjection, PolyExistentialProjection};
@@ -408,6 +409,8 @@ pub struct CReaderCacheKey {
         const HAS_FREE_REGIONS   = 1 << 6,
         const HAS_TY_ERR         = 1 << 7,
         const HAS_PROJECTION     = 1 << 8,
+
+        // FIXME: Rename this to the actual property since it's used for generators too
         const HAS_TY_CLOSURE     = 1 << 9,
 
         // true if there are "names" of types and regions and so forth
@@ -1702,7 +1705,7 @@ fn sized_constraint_for_ty(&self,
         let result = match ty.sty {
             TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) |
             TyRawPtr(..) | TyRef(..) | TyFnDef(..) | TyFnPtr(_) |
-            TyArray(..) | TyClosure(..) | TyNever => {
+            TyArray(..) | TyClosure(..) | TyGenerator(..) | TyNever => {
                 vec![]
             }
 
@@ -2030,6 +2033,7 @@ pub fn expr_is_lval(self, expr: &hir::Expr) -> bool {
             hir::ExprBox(..) |
             hir::ExprAddrOf(..) |
             hir::ExprBinary(..) |
+            hir::ExprYield(..) |
             hir::ExprCast(..) => {
                 false
             }
@@ -2261,6 +2265,10 @@ pub fn trait_has_default_impl(self, trait_def_id: DefId) -> bool {
         self.trait_def(trait_def_id).has_default_impl
     }
 
+    pub fn generator_layout(self, def_id: DefId) -> &'tcx GeneratorLayout<'tcx> {
+        self.optimized_mir(def_id).generator_layout.as_ref().unwrap()
+    }
+
     /// Given the def_id of an impl, return the def_id of the trait it implements.
     /// If it implements no trait, return `None`.
     pub fn trait_id_of_impl(self, def_id: DefId) -> Option<DefId> {