about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2016-08-07 06:41:17 -0400
committerNiko Matsakis <niko@alum.mit.edu>2016-08-31 15:23:50 -0400
commitb44d94a5162ee4b2e20f4ae82328f3e7f6a152b8 (patch)
tree1318651813b7bc1ca0ea87182f42de419573c742
parent52c2d87aa989eb83bfe61884e3c5f24cb5e923d5 (diff)
downloadrust-b44d94a5162ee4b2e20f4ae82328f3e7f6a152b8.tar.gz
rust-b44d94a5162ee4b2e20f4ae82328f3e7f6a152b8.zip
remove unneccessary uses of `drain_fulfillment_cx`
There were various places that we are invoking `drain_fulfillment_cx`
with a "result" of `()`. This is kind of pointless, since it amounts to
just a call to `select_all_or_error` along with some extra overhead.
-rw-r--r--src/librustc/traits/specialize/mod.rs35
-rw-r--r--src/librustc_trans/common.rs2
2 files changed, 20 insertions, 17 deletions
diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs
index 9acfe275482..0604136ec60 100644
--- a/src/librustc/traits/specialize/mod.rs
+++ b/src/librustc/traits/specialize/mod.rs
@@ -207,24 +207,27 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
     for oblig in obligations.into_iter() {
         fulfill_cx.register_predicate_obligation(&infcx, oblig);
     }
+    match fulfill_cx.select_all_or_error(infcx) {
+        Err(errors) => {
+            // no dice!
+            debug!("fulfill_implication: for impls on {:?} and {:?}, could not fulfill: {:?} given \
+                    {:?}",
+                   source_trait_ref,
+                   target_trait_ref,
+                   errors,
+                   infcx.parameter_environment.caller_bounds);
+            Err(())
+        }
 
-    if let Err(errors) = infcx.drain_fulfillment_cx(&mut fulfill_cx, &()) {
-        // no dice!
-        debug!("fulfill_implication: for impls on {:?} and {:?}, could not fulfill: {:?} given \
-                {:?}",
-               source_trait_ref,
-               target_trait_ref,
-               errors,
-               infcx.parameter_environment.caller_bounds);
-        Err(())
-    } else {
-        debug!("fulfill_implication: an impl for {:?} specializes {:?}",
-               source_trait_ref,
-               target_trait_ref);
+        Ok(()) => {
+            debug!("fulfill_implication: an impl for {:?} specializes {:?}",
+                   source_trait_ref,
+                   target_trait_ref);
 
-        // Now resolve the *substitution* we built for the target earlier, replacing
-        // the inference variables inside with whatever we got from fulfillment.
-        Ok(infcx.resolve_type_vars_if_possible(&target_substs))
+            // Now resolve the *substitution* we built for the target earlier, replacing
+            // the inference variables inside with whatever we got from fulfillment.
+            Ok(infcx.resolve_type_vars_if_possible(&target_substs))
+        }
     }
 }
 
diff --git a/src/librustc_trans/common.rs b/src/librustc_trans/common.rs
index d5dcae5f6b0..95a38cd21d9 100644
--- a/src/librustc_trans/common.rs
+++ b/src/librustc_trans/common.rs
@@ -1028,7 +1028,7 @@ pub fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             fulfill_cx.register_predicate_obligation(&infcx, obligation);
         }
 
-        infcx.drain_fulfillment_cx(&mut fulfill_cx, &()).is_ok()
+        fulfill_cx.select_all_or_error(infcx).is_ok()
     })
 }