Skip to content

Commit

Permalink
Pick candidate with fewer bound vars
Browse files Browse the repository at this point in the history
  • Loading branch information
jackh726 authored May 6, 2021
1 parent 9f06939 commit c1ef0f3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1366,11 +1366,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
&& !other.value.skip_binder().has_escaping_bound_vars();
if value_same_except_bound_vars {
// See issue #84398. In short, we can generate multiple ParamCandidates which are
// the same except for unused bound vars. Just pick the current one (the should
// both evaluate to the same answer). This is probably best characterized as a
// "hack", since we might prefer to just do our best to *not* create essentially
// duplicate candidates in the first place.
true
// the same except for unused bound vars. Just pick the one with the fewest bound vars
// or the current one if tied (they should both evaluate to the same answer). This is
// probably best characterized as a "hack", since we might prefer to just do our
// best to *not* create essentially duplicate candidates in the first place.
other.value.bound_vars().len() <= victim.value.bound_vars().len()
} else if other.value == victim.value && victim.constness == Constness::NotConst {
// Drop otherwise equivalent non-const candidates in favor of const candidates.
true
Expand Down

0 comments on commit c1ef0f3

Please sign in to comment.