about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-03-04 13:59:51 -0800
committerEsteban Küber <esteban@kuber.com.ar>2020-03-04 13:59:51 -0800
commit8a3272985b2c9bcd764d72ecf78e9c321b710e63 (patch)
tree2116f20ef0abf4a3287e07f663320c33efa51be8
parent2b0cfa5b4c5099f45ca540ee1c7d8c1ecd5267d2 (diff)
downloadrust-8a3272985b2c9bcd764d72ecf78e9c321b710e63.tar.gz
rust-8a3272985b2c9bcd764d72ecf78e9c321b710e63.zip
Correctly reject `TraitCandidate` in all cases
Follow up to #69255, fix #69629.
-rw-r--r--src/librustc_typeck/check/method/probe.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs
index a52cabd8894..4f65b0e87a1 100644
--- a/src/librustc_typeck/check/method/probe.rs
+++ b/src/librustc_typeck/check/method/probe.rs
@@ -1403,6 +1403,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
                     let predicate = trait_ref.without_const().to_predicate();
                     let obligation = traits::Obligation::new(cause, self.param_env, predicate);
                     if !self.predicate_may_hold(&obligation) {
+                        result = ProbeResult::NoMatch;
                         if self.probe(|_| {
                             match self.select_trait_candidate(trait_ref) {
                                 Err(_) => return true,
@@ -1413,7 +1414,6 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
                                         // Determine exactly which obligation wasn't met, so
                                         // that we can give more context in the error.
                                         if !self.predicate_may_hold(&obligation) {
-                                            result = ProbeResult::NoMatch;
                                             let o = self.resolve_vars_if_possible(obligation);
                                             let predicate =
                                                 self.resolve_vars_if_possible(&predicate);
@@ -1431,7 +1431,6 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
                                 _ => {
                                     // Some nested subobligation of this predicate
                                     // failed.
-                                    result = ProbeResult::NoMatch;
                                     let predicate = self.resolve_vars_if_possible(&predicate);
                                     possibly_unsatisfied_predicates.push((predicate, None));
                                 }