Skip to content

Commit 1e17969

Browse files
committed
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.
2 parents 75cf41a + 8a32729 commit 1e17969

File tree

1 file changed

+1
-2
lines changed
  • src/librustc_typeck/check/method

1 file changed

+1
-2
lines changed

src/librustc_typeck/check/method/probe.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14031403
let predicate = trait_ref.without_const().to_predicate();
14041404
let obligation = traits::Obligation::new(cause, self.param_env, predicate);
14051405
if !self.predicate_may_hold(&obligation) {
1406+
result = ProbeResult::NoMatch;
14061407
if self.probe(|_| {
14071408
match self.select_trait_candidate(trait_ref) {
14081409
Err(_) => return true,
@@ -1413,7 +1414,6 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14131414
// Determine exactly which obligation wasn't met, so
14141415
// that we can give more context in the error.
14151416
if !self.predicate_may_hold(&obligation) {
1416-
result = ProbeResult::NoMatch;
14171417
let o = self.resolve_vars_if_possible(obligation);
14181418
let predicate =
14191419
self.resolve_vars_if_possible(&predicate);
@@ -1431,7 +1431,6 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
14311431
_ => {
14321432
// Some nested subobligation of this predicate
14331433
// failed.
1434-
result = ProbeResult::NoMatch;
14351434
let predicate = self.resolve_vars_if_possible(&predicate);
14361435
possibly_unsatisfied_predicates.push((predicate, None));
14371436
}

0 commit comments

Comments
 (0)