]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_trait_selection/src/traits/select/mod.rs
Rollup merge of #88851 - fee1-dead:dup-bound, r=oli-obk
[rust.git] / compiler / rustc_trait_selection / src / traits / select / mod.rs
index f5be8bf0949e6ff12caff47d9269a7ca6c2519da..8adf9015933c3f6121a2e1cd9ea726b16163c548 100644 (file)
@@ -1487,10 +1487,11 @@ fn candidate_should_be_dropped_in_favor_of(
             ) => false,
 
             (ParamCandidate(other), ParamCandidate(victim)) => {
-                let value_same_except_bound_vars = other.value.skip_binder()
+                let same_except_bound_vars = other.value.skip_binder()
                     == victim.value.skip_binder()
+                    && other.constness == victim.constness
                     && !other.value.skip_binder().has_escaping_bound_vars();
-                if value_same_except_bound_vars {
+                if 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 one with the fewest bound vars
                     // or the current one if tied (they should both evaluate to the same answer). This is