]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_trait_selection/src/traits/fulfill.rs
Cleanup
[rust.git] / compiler / rustc_trait_selection / src / traits / fulfill.rs
index 538c14c6b720e99cbd5cdb2cca17075e07721be0..86c5209354c8577e1a3c6bed0dca0e7d2a1d82de 100644 (file)
@@ -202,7 +202,7 @@ fn register_predicate_obligation(
     ) {
         // this helps to reduce duplicate errors, as well as making
         // debug output much nicer to read and so on.
-        let obligation = infcx.resolve_vars_if_possible(&obligation);
+        let obligation = infcx.resolve_vars_if_possible(obligation);
 
         debug!(?obligation, "register_predicate_obligation");
 
@@ -298,7 +298,7 @@ fn process_obligation(
         if !change {
             debug!(
                 "process_predicate: pending obligation {:?} still stalled on {:?}",
-                self.selcx.infcx().resolve_vars_if_possible(&pending_obligation.obligation),
+                self.selcx.infcx().resolve_vars_if_possible(pending_obligation.obligation.clone()),
                 pending_obligation.stalled_on
             );
             return ProcessResult::Unchanged;
@@ -338,15 +338,16 @@ fn progress_changed_obligations(
 
         if obligation.predicate.has_infer_types_or_consts() {
             obligation.predicate =
-                self.selcx.infcx().resolve_vars_if_possible(&obligation.predicate);
+                self.selcx.infcx().resolve_vars_if_possible(obligation.predicate);
         }
 
         debug!(?obligation, ?obligation.cause, "process_obligation");
 
         let infcx = self.selcx.infcx();
 
-        match obligation.predicate.kind() {
-            ty::PredicateKind::ForAll(binder) => match binder.skip_binder() {
+        let binder = obligation.predicate.bound_atom();
+        if binder.skip_binder().has_escaping_bound_vars() {
+            match binder.skip_binder() {
                 // Evaluation will discard candidates using the leak check.
                 // This means we need to pass it the bound version of our
                 // predicate.
@@ -383,10 +384,11 @@ fn progress_changed_obligations(
                 ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
                     bug!("TypeWellFormedFromEnv is only used for Chalk")
                 }
-            },
-            &ty::PredicateKind::Atom(atom) => match atom {
-                ty::PredicateAtom::Trait(ref data, _) => {
-                    let trait_obligation = obligation.with(Binder::dummy(*data));
+            }
+        } else {
+            match binder.skip_binder() {
+                ty::PredicateAtom::Trait(data, _) => {
+                    let trait_obligation = obligation.with(Binder::dummy(data));
 
                     self.process_trait_obligation(
                         obligation,
@@ -596,7 +598,7 @@ fn progress_changed_obligations(
                 ty::PredicateAtom::TypeWellFormedFromEnv(..) => {
                     bug!("TypeWellFormedFromEnv is only used for Chalk")
                 }
-            },
+            }
         }
     }
 
@@ -639,7 +641,7 @@ fn process_trait_obligation(
 
                 debug!(
                     "process_predicate: pending obligation {:?} now stalled on {:?}",
-                    infcx.resolve_vars_if_possible(obligation),
+                    infcx.resolve_vars_if_possible(obligation.clone()),
                     stalled_on
                 );
 
@@ -684,7 +686,7 @@ fn trait_ref_infer_vars<'a, 'tcx>(
 ) -> Vec<TyOrConstInferVar<'tcx>> {
     selcx
         .infcx()
-        .resolve_vars_if_possible(&trait_ref)
+        .resolve_vars_if_possible(trait_ref)
         .skip_binder()
         .substs
         .iter()