]> git.lizzy.rs Git - rust.git/commitdiff
Address niko's nits
authorscalexm <martin.alex32@hotmail.fr>
Wed, 14 Mar 2018 12:38:03 +0000 (13:38 +0100)
committerscalexm <martin.alex32@hotmail.fr>
Wed, 14 Mar 2018 13:14:33 +0000 (14:14 +0100)
src/librustc/ich/impls_ty.rs
src/librustc/traits/lowering.rs
src/librustc/traits/mod.rs
src/librustc/traits/structural_impls.rs
src/librustc/ty/maps/mod.rs
src/librustc/ty/mod.rs
src/librustc_driver/driver.rs
src/test/ui/chalkify/lower_impl.stderr

index 868ce831d13e07bcbe733d7b01856c2e5e193cc1..78407e33d98b884b0d0ecc4c546f243a046efbfc 100644 (file)
@@ -1294,9 +1294,9 @@ fn hash_stable<W: StableHasherResult>(&self,
         use traits::WhereClauseAtom::*;
 
         mem::discriminant(self).hash_stable(hcx, hasher);
-        match *self {
-            Implemented(ref trait_ref) => trait_ref.hash_stable(hcx, hasher),
-            ProjectionEq(ref projection) => projection.hash_stable(hcx, hasher),
+        match self {
+            Implemented(trait_ref) => trait_ref.hash_stable(hcx, hasher),
+            ProjectionEq(projection) => projection.hash_stable(hcx, hasher),
         }
     }
 }
@@ -1308,54 +1308,59 @@ fn hash_stable<W: StableHasherResult>(&self,
         use traits::DomainGoal::*;
 
         mem::discriminant(self).hash_stable(hcx, hasher);
-        match *self {
-            Holds(ref where_clause) |
-            WellFormed(ref where_clause) |
-            FromEnv(ref where_clause) => where_clause.hash_stable(hcx, hasher),
-
-            WellFormedTy(ref ty) => ty.hash_stable(hcx, hasher),
-            FromEnvTy(ref ty) => ty.hash_stable(hcx, hasher),
-            RegionOutlives(ref predicate) => predicate.hash_stable(hcx, hasher),
-            TypeOutlives(ref predicate) => predicate.hash_stable(hcx, hasher),
+        match self {
+            Holds(where_clause) |
+            WellFormed(where_clause) |
+            FromEnv(where_clause) => where_clause.hash_stable(hcx, hasher),
+
+            WellFormedTy(ty) => ty.hash_stable(hcx, hasher),
+            FromEnvTy(ty) => ty.hash_stable(hcx, hasher),
+            RegionOutlives(predicate) => predicate.hash_stable(hcx, hasher),
+            TypeOutlives(predicate) => predicate.hash_stable(hcx, hasher),
         }
     }
 }
 
-impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for traits::LeafGoal<'tcx> {
+impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for traits::Goal<'tcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a>,
                                           hasher: &mut StableHasher<W>) {
-        use traits::LeafGoal::*;
+        use traits::Goal::*;
 
         mem::discriminant(self).hash_stable(hcx, hasher);
-        match *self {
-            DomainGoal(ref domain_goal) => domain_goal.hash_stable(hcx, hasher),
+        match self {
+            Implies(hypotheses, goal) => {
+                hypotheses.hash_stable(hcx, hasher);
+                goal.hash_stable(hcx, hasher);
+            },
+            And(goal1, goal2) => {
+                goal1.hash_stable(hcx, hasher);
+                goal2.hash_stable(hcx, hasher);
+            }
+            Not(goal) => goal.hash_stable(hcx, hasher),
+            DomainGoal(domain_goal) => domain_goal.hash_stable(hcx, hasher),
+            Quantified(quantifier, goal) => {
+                quantifier.hash_stable(hcx, hasher);
+                goal.hash_stable(hcx, hasher);
+            },
         }
     }
 }
 
-impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for traits::Goal<'tcx> {
+impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for traits::Clause<'tcx> {
     fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a>,
                                           hasher: &mut StableHasher<W>) {
-        use traits::Goal::*;
+        use traits::Clause::*;
 
         mem::discriminant(self).hash_stable(hcx, hasher);
-        match *self {
-            Implies(ref hypotheses, ref goal) => {
+        match self {
+            Implies(hypotheses, goal) => {
                 hypotheses.hash_stable(hcx, hasher);
                 goal.hash_stable(hcx, hasher);
-            },
-            And(ref goal1, ref goal2) => {
-                goal1.hash_stable(hcx, hasher);
-                goal2.hash_stable(hcx, hasher);
             }
-            Not(ref goal) => goal.hash_stable(hcx, hasher),
-            Leaf(ref leaf_goal) => leaf_goal.hash_stable(hcx, hasher),
-            Quantified(quantifier, ref goal) => {
-                quantifier.hash_stable(hcx, hasher);
-                goal.hash_stable(hcx, hasher);
-            },
+            DomainGoal(domain_goal) => domain_goal.hash_stable(hcx, hasher),
+            ForAll(clause) => clause.hash_stable(hcx, hasher),
         }
     }
 }
@@ -1364,8 +1369,3 @@ fn hash_stable<W: StableHasherResult>(&self,
     Universal,
     Existential
 });
-
-impl_stable_hash_for!(struct traits::ProgramClause<'tcx> {
-    consequence,
-    conditions
-});
index 4f7e66628d4845c171731bff15233e6de0c37864..f31e474963ee2dabee82b5003c18fe16db43bbb2 100644 (file)
@@ -11,8 +11,8 @@
 use hir::{self, ImplPolarity};
 use hir::def_id::DefId;
 use hir::intravisit::{self, NestedVisitorMap, Visitor};
-use ty::{self, PolyTraitPredicate, TraitPredicate, PolyProjectionPredicate, TyCtxt, Predicate};
-use super::{DomainGoal, ProgramClause, WhereClauseAtom};
+use ty::{self, TyCtxt};
+use super::{QuantifierKind, Goal, DomainGoal, Clause, WhereClauseAtom};
 use rustc_data_structures::sync::Lrc;
 use syntax::ast;
 
@@ -26,13 +26,13 @@ fn lower(&self) -> Vec<U> {
     }
 }
 
-impl<'tcx> Lower<WhereClauseAtom<'tcx>> for PolyTraitPredicate<'tcx> {
+impl<'tcx> Lower<WhereClauseAtom<'tcx>> for ty::TraitPredicate<'tcx> {
     fn lower(&self) -> WhereClauseAtom<'tcx> {
         WhereClauseAtom::Implemented(*self)
     }
 }
 
-impl<'tcx> Lower<WhereClauseAtom<'tcx>> for PolyProjectionPredicate<'tcx> {
+impl<'tcx> Lower<WhereClauseAtom<'tcx>> for ty::ProjectionPredicate<'tcx> {
     fn lower(&self) -> WhereClauseAtom<'tcx> {
         WhereClauseAtom::ProjectionEq(*self)
     }
@@ -44,27 +44,52 @@ fn lower(&self) -> DomainGoal<'tcx> {
     }
 }
 
-impl<'tcx> Lower<DomainGoal<'tcx>> for Predicate<'tcx> {
+impl<'tcx> Lower<DomainGoal<'tcx>> for ty::RegionOutlivesPredicate<'tcx> {
     fn lower(&self) -> DomainGoal<'tcx> {
-        use self::Predicate::*;
+        DomainGoal::RegionOutlives(*self)
+    }
+}
+
+impl<'tcx> Lower<DomainGoal<'tcx>> for ty::TypeOutlivesPredicate<'tcx> {
+    fn lower(&self) -> DomainGoal<'tcx> {
+        DomainGoal::TypeOutlives(*self)
+    }
+}
+
+impl<'tcx, T> Lower<Goal<'tcx>> for ty::Binder<T>
+    where T: Lower<DomainGoal<'tcx>> + ty::fold::TypeFoldable<'tcx> + Copy
+{
+    fn lower(&self) -> Goal<'tcx> {
+        match self.no_late_bound_regions() {
+            Some(p) => p.lower().into(),
+            None => Goal::Quantified(
+                QuantifierKind::Universal,
+                Box::new(self.map_bound(|p| p.lower().into()))
+            ),
+        }
+    }
+}
 
-        match *self {
+impl<'tcx> Lower<Goal<'tcx>> for ty::Predicate<'tcx> {
+    fn lower(&self) -> Goal<'tcx> {
+        use ty::Predicate::*;
+
+        match self {
             Trait(predicate) => predicate.lower(),
-            RegionOutlives(predicate) => DomainGoal::RegionOutlives(predicate),
-            TypeOutlives(predicate) => DomainGoal::TypeOutlives(predicate),
+            RegionOutlives(predicate) => predicate.lower(),
+            TypeOutlives(predicate) => predicate.lower(),
             Projection(predicate) => predicate.lower(),
-            WellFormed(ty) => DomainGoal::WellFormedTy(ty),
+            WellFormed(ty) => DomainGoal::WellFormedTy(*ty).into(),
             ObjectSafe(..) |
             ClosureKind(..) |
             Subtype(..) |
             ConstEvaluatable(..) => unimplemented!(),
-
         }
     }
 }
 
 pub fn program_clauses_for<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
-    -> Lrc<Vec<ProgramClause<'tcx>>>
+    -> Lrc<Vec<Clause<'tcx>>>
 {
     let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
     let item = tcx.hir.expect_item(node_id);
@@ -75,21 +100,17 @@ pub fn program_clauses_for<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
 }
 
 fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
-    -> Lrc<Vec<ProgramClause<'tcx>>>
+    -> Lrc<Vec<Clause<'tcx>>>
 {
     if let ImplPolarity::Negative = tcx.impl_polarity(def_id) {
         return Lrc::new(vec![]);
     }
 
     let trait_ref = tcx.impl_trait_ref(def_id).unwrap();
-    let trait_ref = ty::Binder(TraitPredicate { trait_ref }).lower();
+    let trait_ref = ty::TraitPredicate { trait_ref }.lower();
     let where_clauses = tcx.predicates_of(def_id).predicates.lower();
 
-    let clause = ProgramClause {
-        consequence: trait_ref,
-        conditions: where_clauses.into_iter().map(|wc| wc.into()).collect(),
-    };
-
+    let clause = Clause::Implies(where_clauses, trait_ref);
     Lrc::new(vec![clause])
 }
 
index 8b2f96ce87557f90e157669142200441f1fbf49b..ea3db0c6e92609c4ea0ddf631f57af8fcc9cf40c 100644 (file)
@@ -248,8 +248,8 @@ pub struct DerivedObligationCause<'tcx> {
 
 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
 pub enum WhereClauseAtom<'tcx> {
-    Implemented(ty::PolyTraitPredicate<'tcx>),
-    ProjectionEq(ty::PolyProjectionPredicate<'tcx>),
+    Implemented(ty::TraitPredicate<'tcx>),
+    ProjectionEq(ty::ProjectionPredicate<'tcx>),
 }
 
 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
@@ -259,13 +259,8 @@ pub enum DomainGoal<'tcx> {
     FromEnv(WhereClauseAtom<'tcx>),
     WellFormedTy(Ty<'tcx>),
     FromEnvTy(Ty<'tcx>),
-    RegionOutlives(ty::PolyRegionOutlivesPredicate<'tcx>),
-    TypeOutlives(ty::PolyTypeOutlivesPredicate<'tcx>),
-}
-
-#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
-pub enum LeafGoal<'tcx> {
-    DomainGoal(DomainGoal<'tcx>),
+    RegionOutlives(ty::RegionOutlivesPredicate<'tcx>),
+    TypeOutlives(ty::TypeOutlivesPredicate<'tcx>),
 }
 
 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
@@ -276,23 +271,30 @@ pub enum QuantifierKind {
 
 #[derive(Clone, PartialEq, Eq, Hash, Debug)]
 pub enum Goal<'tcx> {
-    Implies(Vec<DomainGoal<'tcx>>, Box<Goal<'tcx>>),
+    Implies(Vec<Clause<'tcx>>, Box<Goal<'tcx>>),
     And(Box<Goal<'tcx>>, Box<Goal<'tcx>>),
     Not(Box<Goal<'tcx>>),
-    Leaf(LeafGoal<'tcx>),
+    DomainGoal(DomainGoal<'tcx>),
     Quantified(QuantifierKind, Box<ty::Binder<Goal<'tcx>>>)
 }
 
 impl<'tcx> From<DomainGoal<'tcx>> for Goal<'tcx> {
     fn from(domain_goal: DomainGoal<'tcx>) -> Self {
-        Goal::Leaf(LeafGoal::DomainGoal(domain_goal))
+        Goal::DomainGoal(domain_goal)
+    }
+}
+
+impl<'tcx> From<DomainGoal<'tcx>> for Clause<'tcx> {
+    fn from(domain_goal: DomainGoal<'tcx>) -> Self {
+        Clause::DomainGoal(domain_goal)
     }
 }
 
 #[derive(Clone, PartialEq, Eq, Hash, Debug)]
-pub struct ProgramClause<'tcx> {
-    pub consequence: DomainGoal<'tcx>,
-    pub conditions: Vec<Goal<'tcx>>,
+pub enum Clause<'tcx> {
+    Implies(Vec<Goal<'tcx>>, DomainGoal<'tcx>),
+    DomainGoal(DomainGoal<'tcx>),
+    ForAll(Box<ty::Binder<Clause<'tcx>>>),
 }
 
 pub fn dump_program_clauses<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
index 62881013c4c5e444e3f1995627cb63cfe15bcfa3..d6e6f0e98adc48afb18f4f61efdae5ac64dec78d 100644 (file)
@@ -429,9 +429,10 @@ impl<'tcx, T> TypeFoldable<'tcx> for Normalized<'tcx, T> {
 impl<'tcx> fmt::Display for traits::WhereClauseAtom<'tcx> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         use traits::WhereClauseAtom::*;
-        match *self {
-            Implemented(ref trait_ref) => write!(fmt, "Implemented({})", trait_ref),
-            ProjectionEq(ref projection) => write!(fmt, "ProjectionEq({})", projection),
+
+        match self {
+            Implemented(trait_ref) => write!(fmt, "Implemented({})", trait_ref),
+            ProjectionEq(projection) => write!(fmt, "ProjectionEq({})", projection),
         }
     }
 }
@@ -440,16 +441,17 @@ impl<'tcx> fmt::Display for traits::DomainGoal<'tcx> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         use traits::DomainGoal::*;
         use traits::WhereClauseAtom::*;
-        match *self {
+
+        match self {
             Holds(wc) => write!(fmt, "{}", wc),
-            WellFormed(Implemented(ref trait_ref)) => write!(fmt, "WellFormed({})", trait_ref),
-            WellFormed(ProjectionEq(ref projection)) => write!(fmt, "WellFormed({})", projection),
-            FromEnv(Implemented(ref trait_ref)) => write!(fmt, "FromEnv({})", trait_ref),
-            FromEnv(ProjectionEq(ref projection)) => write!(fmt, "FromEnv({})", projection),
-            WellFormedTy(ref ty) => write!(fmt, "WellFormed({})", ty),
-            FromEnvTy(ref ty) => write!(fmt, "FromEnv({})", ty),
-            RegionOutlives(ref predicate) => write!(fmt, "RegionOutlives({})", predicate),
-            TypeOutlives(ref predicate) => write!(fmt, "TypeOutlives({})", predicate),
+            WellFormed(Implemented(trait_ref)) => write!(fmt, "WellFormed({})", trait_ref),
+            WellFormed(ProjectionEq(projection)) => write!(fmt, "WellFormed({})", projection),
+            FromEnv(Implemented(trait_ref)) => write!(fmt, "FromEnv({})", trait_ref),
+            FromEnv(ProjectionEq(projection)) => write!(fmt, "FromEnv({})", projection),
+            WellFormedTy(ty) => write!(fmt, "WellFormed({})", ty),
+            FromEnvTy(ty) => write!(fmt, "FromEnv({})", ty),
+            RegionOutlives(predicate) => write!(fmt, "RegionOutlives({})", predicate),
+            TypeOutlives(predicate) => write!(fmt, "TypeOutlives({})", predicate),
         }
     }
 }
@@ -457,27 +459,20 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
 impl fmt::Display for traits::QuantifierKind {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         use traits::QuantifierKind::*;
-        match *self {
+
+        match self {
             Universal => write!(fmt, "forall"),
             Existential => write!(fmt, "exists"),
         }
     }
 }
 
-impl<'tcx> fmt::Display for traits::LeafGoal<'tcx> {
-    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-        use traits::LeafGoal::*;
-        match *self {
-            DomainGoal(ref domain_goal) => write!(fmt, "{}", domain_goal),
-        }
-    }
-}
-
 impl<'tcx> fmt::Display for traits::Goal<'tcx> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         use traits::Goal::*;
-        match *self {
-            Implies(ref hypotheses, ref goal) => {
+
+        match self {
+            Implies(hypotheses, goal) => {
                 write!(fmt, "if (")?;
                 for (index, hyp) in hypotheses.iter().enumerate() {
                     if index > 0 {
@@ -487,10 +482,10 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
                 }
                 write!(fmt, ") {{ {} }}", goal)
             }
-            And(ref goal1, ref goal2) => write!(fmt, "({}, {})", goal1, goal2),
-            Not(ref goal) => write!(fmt, "not {{ {} }}", goal),
-            Leaf(ref goal) => write!(fmt, "{}", goal),
-            Quantified(qkind, ref goal) => {
+            And(goal1, goal2) => write!(fmt, "({} && {})", goal1, goal2),
+            Not(goal) => write!(fmt, "not {{ {} }}", goal),
+            DomainGoal(goal) => write!(fmt, "{}", goal),
+            Quantified(qkind, goal) => {
                 // FIXME: appropriate binder names
                 write!(fmt, "{}<> {{ {} }}", qkind, goal.skip_binder())
             }
@@ -498,113 +493,70 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-impl<'tcx> fmt::Display for traits::ProgramClause<'tcx> {
+impl<'tcx> fmt::Display for traits::Clause<'tcx> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-        write!(fmt, "{}", self.consequence)?;
-        if self.conditions.is_empty() {
-            write!(fmt, ".")?;
-        } else {
-            write!(fmt, " :- ")?;
-            for (index, condition) in self.conditions.iter().enumerate() {
-                if index > 0 {
-                    write!(fmt, ", ")?;
+        use traits::Clause::*;
+
+        match self {
+            Implies(hypotheses, goal) => {
+                write!(fmt, "{}", goal)?;
+                if !hypotheses.is_empty() {
+                    write!(fmt, " :- ")?;
+                    for (index, condition) in hypotheses.iter().enumerate() {
+                        if index > 0 {
+                            write!(fmt, ", ")?;
+                        }
+                        write!(fmt, "{}", condition)?;
+                    }
                 }
-                write!(fmt, "{}", condition)?;
+                write!(fmt, ".")
+            }
+            DomainGoal(domain_goal) => write!(fmt, "{}.", domain_goal),
+            ForAll(clause) => {
+                // FIXME: appropriate binder names
+                write!(fmt, "forall<> {{ {} }}", clause.skip_binder())
             }
         }
-        Ok(())
     }
 }
 
-impl<'tcx> TypeFoldable<'tcx> for traits::WhereClauseAtom<'tcx> {
-    fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
-        use traits::WhereClauseAtom::*;
-        match *self {
-            Implemented(ref trait_ref) => Implemented(trait_ref.fold_with(folder)),
-            ProjectionEq(ref projection) => ProjectionEq(projection.fold_with(folder)),
-        }
-    }
-
-    fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
-        use traits::WhereClauseAtom::*;
-        match *self {
-            Implemented(ref trait_ref) => trait_ref.visit_with(visitor),
-            ProjectionEq(ref projection) => projection.visit_with(visitor),
-        }
+EnumTypeFoldableImpl! {
+    impl<'tcx> TypeFoldable<'tcx> for traits::WhereClauseAtom<'tcx> {
+        (traits::WhereClauseAtom::Implemented)(trait_ref),
+        (traits::WhereClauseAtom::ProjectionEq)(projection),
     }
 }
 
-impl<'tcx> TypeFoldable<'tcx> for traits::DomainGoal<'tcx> {
-    fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
-        use traits::DomainGoal::*;
-        match *self {
-            Holds(ref wc) => Holds(wc.fold_with(folder)),
-            WellFormed(ref wc) => WellFormed(wc.fold_with(folder)),
-            FromEnv(ref wc) => FromEnv(wc.fold_with(folder)),
-            WellFormedTy(ref ty) => WellFormedTy(ty.fold_with(folder)),
-            FromEnvTy(ref ty) => FromEnvTy(ty.fold_with(folder)),
-            RegionOutlives(ref predicate) => RegionOutlives(predicate.fold_with(folder)),
-            TypeOutlives(ref predicate) => TypeOutlives(predicate.fold_with(folder)),
-        }
-    }
-
-    fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
-        use traits::DomainGoal::*;
-        match *self {
-            Holds(ref wc) |
-            WellFormed(ref wc) |
-            FromEnv(ref wc) => wc.visit_with(visitor),
-            WellFormedTy(ref ty) |
-            FromEnvTy(ref ty) => ty.visit_with(visitor),
-            RegionOutlives(ref predicate) => predicate.visit_with(visitor),
-            TypeOutlives(ref predicate) => predicate.visit_with(visitor),
-        }
+EnumTypeFoldableImpl! {
+    impl<'tcx> TypeFoldable<'tcx> for traits::DomainGoal<'tcx> {
+        (traits::DomainGoal::Holds)(wc),
+        (traits::DomainGoal::WellFormed)(wc),
+        (traits::DomainGoal::FromEnv)(wc),
+        (traits::DomainGoal::WellFormedTy)(ty),
+        (traits::DomainGoal::FromEnvTy)(ty),
+        (traits::DomainGoal::RegionOutlives)(predicate),
+        (traits::DomainGoal::TypeOutlives)(predicate),
     }
 }
 
-impl<'tcx> TypeFoldable<'tcx> for traits::LeafGoal<'tcx> {
-    fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
-        use traits::LeafGoal::*;
-        match *self {
-            DomainGoal(ref domain_goal) => DomainGoal(domain_goal.fold_with(folder)),
-        }
-    }
-
-    fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
-        use traits::LeafGoal::*;
-        match *self {
-            DomainGoal(ref domain_goal) => domain_goal.visit_with(visitor),
-        }
-    }
+CloneTypeFoldableImpls! {
+    traits::QuantifierKind,
 }
 
-impl<'tcx> TypeFoldable<'tcx> for traits::Goal<'tcx> {
-    fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
-        use traits::Goal::*;
-        match *self {
-            Implies(ref hypotheses, ref goal) => {
-                Implies(
-                    hypotheses.iter().map(|hyp| hyp.fold_with(folder)).collect(),
-                    goal.fold_with(folder)
-                )
-            },
-            And(ref goal1, ref goal2) => And(goal1.fold_with(folder), goal2.fold_with(folder)),
-            Not(ref goal) => Not(goal.fold_with(folder)),
-            Leaf(ref leaf_goal) => Leaf(leaf_goal.fold_with(folder)),
-            Quantified(qkind, ref goal) => Quantified(qkind, goal.fold_with(folder)),
-        }
+EnumTypeFoldableImpl! {
+    impl<'tcx> TypeFoldable<'tcx> for traits::Goal<'tcx> {
+        (traits::Goal::Implies)(hypotheses, goal),
+        (traits::Goal::And)(goal1, goal2),
+        (traits::Goal::Not)(goal),
+        (traits::Goal::DomainGoal)(domain_goal),
+        (traits::Goal::Quantified)(qkind, goal),
     }
+}
 
-    fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
-        use traits::Goal::*;
-        match *self {
-            Implies(ref hypotheses, ref goal) => {
-                hypotheses.iter().any(|hyp| hyp.visit_with(visitor)) || goal.visit_with(visitor)
-            }
-            And(ref goal1, ref goal2) => goal1.visit_with(visitor) || goal2.visit_with(visitor),
-            Not(ref goal) => goal.visit_with(visitor),
-            Leaf(ref leaf_goal) => leaf_goal.visit_with(visitor),
-            Quantified(_, ref goal) => goal.visit_with(visitor),
-        }
+EnumTypeFoldableImpl! {
+    impl<'tcx> TypeFoldable<'tcx> for traits::Clause<'tcx> {
+        (traits::Clause::Implies)(hypotheses, goal),
+        (traits::Clause::DomainGoal)(domain_goal),
+        (traits::Clause::ForAll)(clause),
     }
 }
index 087c7d6d44df6e5737d1df52e87c728fc34d94c0..50dfbeb9724ca443dd1f65f2ab3c4b0795603bf4 100644 (file)
@@ -38,7 +38,7 @@
 use traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResult};
 use traits::query::normalize::NormalizationResult;
 use traits::specialization_graph;
-use traits::ProgramClause;
+use traits::Clause;
 use ty::{self, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt};
 use ty::steal::Steal;
 use ty::subst::Substs;
 
     [] fn features_query: features_node(CrateNum) -> Lrc<feature_gate::Features>,
 
-    [] fn program_clauses_for: ProgramClausesFor(DefId) -> Lrc<Vec<ProgramClause<'tcx>>>,
+    [] fn program_clauses_for: ProgramClausesFor(DefId) -> Lrc<Vec<Clause<'tcx>>>,
 }
 
 //////////////////////////////////////////////////////////////////////
index fc1d26b0e09100e665d14406012f27b8e1fbb9f5..ea116b4cd0a41067e930b0876ba57068cdb1608e 100644 (file)
@@ -1073,9 +1073,12 @@ pub fn def_id(&self) -> DefId {
 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
 pub struct OutlivesPredicate<A,B>(pub A, pub B); // `A : B`
 pub type PolyOutlivesPredicate<A,B> = ty::Binder<OutlivesPredicate<A,B>>;
-pub type PolyRegionOutlivesPredicate<'tcx> = PolyOutlivesPredicate<ty::Region<'tcx>,
-                                                                   ty::Region<'tcx>>;
-pub type PolyTypeOutlivesPredicate<'tcx> = PolyOutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>;
+pub type RegionOutlivesPredicate<'tcx> = OutlivesPredicate<ty::Region<'tcx>,
+                                                           ty::Region<'tcx>>;
+pub type TypeOutlivesPredicate<'tcx> = OutlivesPredicate<Ty<'tcx>,
+                                                         ty::Region<'tcx>>;
+pub type PolyRegionOutlivesPredicate<'tcx> = ty::Binder<RegionOutlivesPredicate<'tcx>>;
+pub type PolyTypeOutlivesPredicate<'tcx> = ty::Binder<TypeOutlivesPredicate<'tcx>>;
 
 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
 pub struct SubtypePredicate<'tcx> {
index 69257e3e1139274b1502fd1899a53b3c42de46d8..68c9c946215d1b015741cb0eef29a2cbab0e54e1 100644 (file)
@@ -1089,7 +1089,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(trans: &TransCrate,
 
         time(sess, "lint checking", || lint::check_crate(tcx));
 
-        time(time_passes, "dumping chalk-like clauses", || traits::dump_program_clauses(tcx));
+        time(sess, "dumping chalk-like clauses", || traits::dump_program_clauses(tcx));
 
         return Ok(f(tcx, analysis, rx, tcx.sess.compile_status()));
     })
index 8645e4506efa89c4c57fa59eef96f9894718fc01..b5d791d640ada9dcd79a4c07aff37b2e845f90fa 100644 (file)
@@ -1,4 +1,4 @@
-error: Implemented(T: Foo) :- ProjectionEq(<T as std::iter::Iterator>::Item == i32), TypeOutlives(T : 'static), Implemented(T: std::iter::Iterator), Implemented(T: std::marker::Sized)
+error: Implemented(T: Foo) :- ProjectionEq(<T as std::iter::Iterator>::Item == i32), TypeOutlives(T : 'static), Implemented(T: std::iter::Iterator), Implemented(T: std::marker::Sized).
   --> $DIR/lower_impl.rs:15:1
    |
 LL | #[rustc_dump_program_clauses] //~ ERROR Implemented(T: Foo) :-