Skip to content

Commit 40e2c34

Browse files
jackh726Mark-Simulacrum
authored andcommitted
Pick candidate with fewer bound vars
1 parent fb327ab commit 40e2c34

File tree

1 file changed

+5
-5
lines changed
  • compiler/rustc_trait_selection/src/traits/select

1 file changed

+5
-5
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1366,11 +1366,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
13661366
&& !other.value.skip_binder().has_escaping_bound_vars();
13671367
if value_same_except_bound_vars {
13681368
// See issue #84398. In short, we can generate multiple ParamCandidates which are
1369-
// the same except for unused bound vars. Just pick the current one (the should
1370-
// both evaluate to the same answer). This is probably best characterized as a
1371-
// "hack", since we might prefer to just do our best to *not* create essentially
1372-
// duplicate candidates in the first place.
1373-
true
1369+
// the same except for unused bound vars. Just pick the one with the fewest bound vars
1370+
// or the current one if tied (they should both evaluate to the same answer). This is
1371+
// probably best characterized as a "hack", since we might prefer to just do our
1372+
// best to *not* create essentially duplicate candidates in the first place.
1373+
other.value.bound_vars().len() <= victim.value.bound_vars().len()
13741374
} else if other.value == victim.value && victim.constness == Constness::NotConst {
13751375
// Drop otherwise equivalent non-const candidates in favor of const candidates.
13761376
true

0 commit comments

Comments
 (0)