@@ -91,7 +91,8 @@ impl<'tcx> ProjectionCandidateSet<'tcx> {
91
91
// Returns true if the push was successful, or false if the candidate
92
92
// was discarded -- this could be because of ambiguity, or because
93
93
// a higher-priority candidate is already there.
94
- fn push_candidate ( & mut self , candidate : ProjectionCandidate < ' tcx > ) -> bool {
94
+ #[ tracing:: instrument( level = "debug" , skip( self , tcx) ) ]
95
+ fn push_candidate ( & mut self , tcx : TyCtxt < ' tcx > , candidate : ProjectionCandidate < ' tcx > ) -> bool {
95
96
use self :: ProjectionCandidate :: * ;
96
97
use self :: ProjectionCandidateSet :: * ;
97
98
@@ -126,6 +127,15 @@ impl<'tcx> ProjectionCandidateSet<'tcx> {
126
127
// clauses are the safer choice. See the comment on
127
128
// `select::SelectionCandidate` and #21974 for more details.
128
129
match ( current, candidate) {
130
+ // HACK(fee1-dead)
131
+ // If both candidates are the same, except for the constness argument, it is not an ambiguity
132
+ ( ParamEnv ( a) , ParamEnv ( b) )
133
+ if a. required_poly_trait_ref ( tcx)
134
+ . eq_modulo_constness ( & b. required_poly_trait_ref ( tcx) )
135
+ && a. term ( ) == b. term ( ) =>
136
+ {
137
+ return false ;
138
+ }
129
139
( ParamEnv ( ..) , ParamEnv ( ..) ) => convert_to_ambiguous = ( ) ,
130
140
( ParamEnv ( ..) , _) => return false ,
131
141
( _, ParamEnv ( ..) ) => unreachable ! ( ) ,
@@ -1365,7 +1375,7 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
1365
1375
1366
1376
match is_match {
1367
1377
ProjectionMatchesProjection :: Yes => {
1368
- candidate_set. push_candidate ( ctor ( data) ) ;
1378
+ candidate_set. push_candidate ( infcx . tcx , ctor ( data) ) ;
1369
1379
1370
1380
if potentially_unnormalized_candidates
1371
1381
&& !obligation. predicate . has_infer_types_or_consts ( )
@@ -1635,7 +1645,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
1635
1645
} ;
1636
1646
1637
1647
if eligible {
1638
- if candidate_set. push_candidate ( ProjectionCandidate :: Select ( impl_source) ) {
1648
+ if candidate_set. push_candidate ( selcx . tcx ( ) , ProjectionCandidate :: Select ( impl_source) ) {
1639
1649
Ok ( ( ) )
1640
1650
} else {
1641
1651
Err ( ( ) )
0 commit comments