about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-03-05 03:44:53 +0000
committerbors <bors@rust-lang.org>2020-03-05 03:44:53 +0000
commit1e179690f8ad9790eb3a6b1dbb6a0ddf479f2c86 (patch)
treec7dbdd565880b4348b7068336b3440c212cca25c
parent75cf41afb468152611212271bae026948cd3ba46 (diff)
parent8a3272985b2c9bcd764d72ecf78e9c321b710e63 (diff)
downloadrust-1e179690f8ad9790eb3a6b1dbb6a0ddf479f2c86.tar.gz
rust-1e179690f8ad9790eb3a6b1dbb6a0ddf479f2c86.zip
Auto merge of #69717 - estebank:correctly-probe, r=varkor
Correctly reject `TraitCandidate` in all cases

Follow up to #69255, addresses #69629.

When `self.select_trait_candidate(trait_ref)` returned `Err(_)`, `result` wasn't being set to `NoMatch`, causing invalid methods to be selected.
-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));
                                 }