Deduplicate ParamCandidates with the same value except for bound vars
This commit is contained in:
parent
58bdb08947
commit
9f0693969a
2 changed files with 31 additions and 1 deletions
|
@ -1361,7 +1361,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
) => false,
|
||||
|
||||
(ParamCandidate(other), ParamCandidate(victim)) => {
|
||||
if other.value == victim.value && victim.constness == Constness::NotConst {
|
||||
let value_same_except_bound_vars = other.value.skip_binder()
|
||||
== victim.value.skip_binder()
|
||||
&& !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
|
||||
} else if other.value == victim.value && victim.constness == Constness::NotConst {
|
||||
// Drop otherwise equivalent non-const candidates in favor of const candidates.
|
||||
true
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue