@@ -58,6 +58,12 @@ impl<'tcx> inspect::ProofTreeVisitor<'tcx> for Select {
58
58
) ) ) ;
59
59
}
60
60
61
+ // Don't winnow until `Certainty::Yes` -- we don't need to winnow until
62
+ // codegen, technically, and all goals should hold in codegen.
63
+ if matches ! ( goal. result( ) . unwrap( ) , Certainty :: Maybe ( ..) ) {
64
+ return ControlFlow :: Break ( Ok ( None ) ) ;
65
+ }
66
+
61
67
// We need to winnow. See comments on `candidate_should_be_dropped_in_favor_of`.
62
68
let mut i = 0 ;
63
69
while i < candidates. len ( ) {
@@ -85,12 +91,6 @@ fn candidate_should_be_dropped_in_favor_of<'tcx>(
85
91
victim : & inspect:: InspectCandidate < ' _ , ' tcx > ,
86
92
other : & inspect:: InspectCandidate < ' _ , ' tcx > ,
87
93
) -> bool {
88
- // Don't winnow until `Certainty::Yes` -- we don't need to winnow until
89
- // codegen, technically.
90
- if matches ! ( other. result( ) . unwrap( ) , Certainty :: Maybe ( ..) ) {
91
- return false ;
92
- }
93
-
94
94
let inspect:: ProbeKind :: TraitCandidate { source : victim_source, result : _ } = victim. kind ( )
95
95
else {
96
96
return false ;
@@ -105,12 +105,14 @@ fn candidate_should_be_dropped_in_favor_of<'tcx>(
105
105
bug ! ( "should not have assembled a CoherenceUnknowable candidate" )
106
106
}
107
107
108
+ // In the old trait solver, we arbitrarily choose lower vtable candidates
109
+ // over higher ones.
110
+ (
111
+ CandidateSource :: BuiltinImpl ( BuiltinImplSource :: Object { vtable_base : a } ) ,
112
+ CandidateSource :: BuiltinImpl ( BuiltinImplSource :: Object { vtable_base : b } ) ,
113
+ ) => a >= b,
108
114
// Prefer dyn candidates over non-dyn candidates. This is necessary to
109
115
// handle the unsoundness between `impl<T: ?Sized> Any for T` and `dyn Any: Any`.
110
- (
111
- CandidateSource :: BuiltinImpl ( BuiltinImplSource :: Object { .. } ) ,
112
- CandidateSource :: BuiltinImpl ( BuiltinImplSource :: Object { .. } ) ,
113
- ) => false ,
114
116
(
115
117
CandidateSource :: Impl ( _) | CandidateSource :: ParamEnv ( _) | CandidateSource :: AliasBound ,
116
118
CandidateSource :: BuiltinImpl ( BuiltinImplSource :: Object { .. } ) ,
0 commit comments