Skip to content

Commit 71d350e

Browse files
winnow: drop non-const cand. in favor of const
1 parent ee6f42b commit 71d350e

File tree

1 file changed

+9
-1
lines changed
  • compiler/rustc_trait_selection/src/traits/select

1 file changed

+9
-1
lines changed

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

+9-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use rustc_data_structures::stack::ensure_sufficient_stack;
3131
use rustc_errors::ErrorReported;
3232
use rustc_hir as hir;
3333
use rustc_hir::def_id::DefId;
34+
use rustc_hir::Constness;
3435
use rustc_middle::dep_graph::{DepKind, DepNodeIndex};
3536
use rustc_middle::mir::interpret::ErrorHandled;
3637
use rustc_middle::ty::fast_reject;
@@ -1335,7 +1336,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
13351336
(BuiltinCandidate { has_nested: false } | DiscriminantKindCandidate, _) => true,
13361337
(_, BuiltinCandidate { has_nested: false } | DiscriminantKindCandidate) => false,
13371338

1338-
(ParamCandidate(..), ParamCandidate(..)) => false,
1339+
(ParamCandidate(other), ParamCandidate(victim)) => {
1340+
if other.value == victim.value && victim.constness == Constness::NotConst {
1341+
// Drop otherwise equivalent non-const candidates in favor of const candidates.
1342+
true
1343+
} else {
1344+
false
1345+
}
1346+
}
13391347

13401348
// Global bounds from the where clause should be ignored
13411349
// here (see issue #50825). Otherwise, we have a where

0 commit comments

Comments
 (0)