]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/ty/mod.rs
Auto merge of #32780 - soltanmm:consider-the-following, r=nikomatsakis
[rust.git] / src / librustc / ty / mod.rs
index cba3a9e2ebb5ccfadf418572c2a398ae25e9def7..eaba5d2a8602c9d3e79ace7a034a33c3ccdc4ce6 100644 (file)
@@ -832,6 +832,11 @@ pub enum Predicate<'tcx> {
 
     /// trait must be object-safe
     ObjectSafe(DefId),
+
+    /// No direct syntax. May be thought of as `where T : FnFoo<...>` for some 'TypeSpace'
+    /// substitutions `...` and T being a closure type.  Satisfied (or refuted) once we know the
+    /// closure's kind.
+    ClosureKind(DefId, ClosureKind),
 }
 
 impl<'tcx> Predicate<'tcx> {
@@ -921,6 +926,8 @@ pub fn subst_supertrait(&self,
                 Predicate::WellFormed(data.subst(tcx, substs)),
             Predicate::ObjectSafe(trait_def_id) =>
                 Predicate::ObjectSafe(trait_def_id),
+            Predicate::ClosureKind(closure_def_id, kind) =>
+                Predicate::ClosureKind(closure_def_id, kind),
         }
     }
 }
@@ -1108,6 +1115,9 @@ pub fn walk_tys(&self) -> IntoIter<Ty<'tcx>> {
             ty::Predicate::ObjectSafe(_trait_def_id) => {
                 vec![]
             }
+            ty::Predicate::ClosureKind(_closure_def_id, _kind) => {
+                vec![]
+            }
         };
 
         // The only reason to collect into a vector here is that I was
@@ -1128,6 +1138,7 @@ pub fn to_opt_poly_trait_ref(&self) -> Option<PolyTraitRef<'tcx>> {
             Predicate::RegionOutlives(..) |
             Predicate::WellFormed(..) |
             Predicate::ObjectSafe(..) |
+            Predicate::ClosureKind(..) |
             Predicate::TypeOutlives(..) => {
                 None
             }
@@ -1783,7 +1794,7 @@ pub struct ItemSubsts<'tcx> {
     pub substs: Substs<'tcx>,
 }
 
-#[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug, RustcEncodable, RustcDecodable)]
+#[derive(Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
 pub enum ClosureKind {
     // Warning: Ordering is significant here! The ordering is chosen
     // because the trait Fn is a subtrait of FnMut and so in turn, and