@@ -91,7 +91,8 @@ impl<'tcx> ProjectionCandidateSet<'tcx> {
9191 // Returns true if the push was successful, or false if the candidate
9292 // was discarded -- this could be because of ambiguity, or because
9393 // 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 {
9596 use self :: ProjectionCandidate :: * ;
9697 use self :: ProjectionCandidateSet :: * ;
9798
@@ -126,6 +127,15 @@ impl<'tcx> ProjectionCandidateSet<'tcx> {
126127 // clauses are the safer choice. See the comment on
127128 // `select::SelectionCandidate` and #21974 for more details.
128129 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+ }
129139 ( ParamEnv ( ..) , ParamEnv ( ..) ) => convert_to_ambiguous = ( ) ,
130140 ( ParamEnv ( ..) , _) => return false ,
131141 ( _, ParamEnv ( ..) ) => unreachable ! ( ) ,
@@ -1365,7 +1375,7 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
13651375
13661376 match is_match {
13671377 ProjectionMatchesProjection :: Yes => {
1368- candidate_set. push_candidate ( ctor ( data) ) ;
1378+ candidate_set. push_candidate ( infcx . tcx , ctor ( data) ) ;
13691379
13701380 if potentially_unnormalized_candidates
13711381 && !obligation. predicate . has_infer_types_or_consts ( )
@@ -1635,7 +1645,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
16351645 } ;
16361646
16371647 if eligible {
1638- if candidate_set. push_candidate ( ProjectionCandidate :: Select ( impl_source) ) {
1648+ if candidate_set. push_candidate ( selcx . tcx ( ) , ProjectionCandidate :: Select ( impl_source) ) {
16391649 Ok ( ( ) )
16401650 } else {
16411651 Err ( ( ) )
0 commit comments