@@ -24,8 +24,7 @@ use crate::solve::assembly::{
2424use crate :: solve:: inspect:: ProbeKind ;
2525use crate :: solve:: {
2626 BuiltinImplSource , CandidateSource , Certainty , EvalCtxt , Goal , GoalSource , MaybeCause ,
27- MergeCandidateInfo , NoSolution , ParamEnvSource , StalledOnCoroutines ,
28- has_only_region_constraints,
27+ NoSolution , ParamEnvSource , StalledOnCoroutines , has_only_region_constraints,
2928} ;
3029
3130impl < D , I > assembly:: GoalKind < D > for TraitClause < I >
@@ -1578,7 +1577,7 @@ where
15781577 . all ( |candidate| matches ! ( candidate. source, CandidateSource :: BuiltinImpl ( _) ) ) ;
15791578
15801579 if is_marker || all_builtin {
1581- self . try_merge_candidates ( candidates) . map ( | ( response , _ ) | response )
1580+ self . try_merge_candidates ( candidates)
15821581 } else if candidates. len ( ) > 1 {
15831582 None
15841583 } else {
@@ -1591,7 +1590,7 @@ where
15911590 candidates : & [ Candidate < I > ] ,
15921591 proven_via : TraitGoalProvenVia ,
15931592 ) -> ( CanonicalResponse < I > , Option < TraitGoalProvenVia > ) {
1594- if let Some ( ( response, _ ) ) = self . try_merge_candidates ( candidates) {
1593+ if let Some ( response) = self . try_merge_candidates ( candidates) {
15951594 ( response, Some ( proven_via) )
15961595 } else {
15971596 ( self . bail_with_ambiguity ( candidates) , None )
@@ -1656,6 +1655,7 @@ where
16561655 let alias_bounds: Vec < _ > = candidates
16571656 . extract_if ( .., |c| matches ! ( c. source, CandidateSource :: AliasBound ( ..) ) )
16581657 . collect ( ) ;
1658+ candidates. into_iter ( ) . for_each ( |c| self . ignore_candidate_head_usages ( c. head_usages ) ) ;
16591659 return Ok ( self . merge_candidates_or_bail_with_ambiguity (
16601660 & alias_bounds,
16611661 TraitGoalProvenVia :: AliasBound ,
@@ -1671,38 +1671,10 @@ where
16711671 let where_bounds: Vec < _ > = candidates
16721672 . extract_if ( .., |c| matches ! ( c. source, CandidateSource :: ParamEnv ( _) ) )
16731673 . collect ( ) ;
1674- let Some ( ( response, info) ) = self . try_merge_candidates ( & where_bounds) else {
1674+ candidates. into_iter ( ) . for_each ( |c| self . ignore_candidate_head_usages ( c. head_usages ) ) ;
1675+ let Some ( response) = self . try_merge_candidates ( & where_bounds) else {
16751676 return Ok ( ( self . bail_with_ambiguity ( & where_bounds) , None ) ) ;
16761677 } ;
1677- match info {
1678- // If there's an always applicable candidate, the result of all
1679- // other candidates does not matter. This means we can ignore
1680- // them when checking whether we've reached a fixpoint.
1681- //
1682- // We always prefer the first always applicable candidate, even if a
1683- // later candidate is also always applicable and would result in fewer
1684- // reruns. We could slightly improve this by e.g. searching for another
1685- // always applicable candidate which doesn't depend on any cycle heads.
1686- //
1687- // NOTE: This is optimization is observable in case there is an always
1688- // applicable global candidate and another non-global candidate which only
1689- // applies because of a provisional result. I can't even think of a test
1690- // case where this would occur and even then, this would not be unsound.
1691- // Supporting this makes the code more involved, so I am just going to
1692- // ignore this for now.
1693- MergeCandidateInfo :: AlwaysApplicable ( i) => {
1694- for ( j, c) in where_bounds. into_iter ( ) . enumerate ( ) {
1695- if i != j {
1696- self . ignore_candidate_head_usages ( c. head_usages )
1697- }
1698- }
1699- // If a where-bound does not apply, we don't actually get a
1700- // candidate for it. We manually track the head usages
1701- // of all failed `ParamEnv` candidates instead.
1702- self . ignore_candidate_head_usages ( failed_candidate_info. param_env_head_usages ) ;
1703- }
1704- MergeCandidateInfo :: EqualResponse => { }
1705- }
17061678 return Ok ( ( response, Some ( TraitGoalProvenVia :: ParamEnv ) ) ) ;
17071679 }
17081680
@@ -1711,6 +1683,7 @@ where
17111683 let alias_bounds: Vec < _ > = candidates
17121684 . extract_if ( .., |c| matches ! ( c. source, CandidateSource :: AliasBound ( _) ) )
17131685 . collect ( ) ;
1686+ candidates. into_iter ( ) . for_each ( |c| self . ignore_candidate_head_usages ( c. head_usages ) ) ;
17141687 return Ok ( self . merge_candidates_or_bail_with_ambiguity (
17151688 & alias_bounds,
17161689 TraitGoalProvenVia :: AliasBound ,
0 commit comments