@@ -1256,10 +1256,11 @@ where
1256
1256
D : SolverDelegate < Interner = I > ,
1257
1257
I : Interner ,
1258
1258
{
1259
+ #[ instrument( level = "debug" , skip( self , goal) , ret) ]
1259
1260
pub ( super ) fn merge_trait_candidates (
1260
1261
& mut self ,
1261
1262
goal : Goal < I , TraitPredicate < I > > ,
1262
- candidates : Vec < Candidate < I > > ,
1263
+ mut candidates : Vec < Candidate < I > > ,
1263
1264
) -> Result < ( CanonicalResponse < I > , Option < TraitGoalProvenVia > ) , NoSolution > {
1264
1265
if let TypingMode :: Coherence = self . typing_mode ( ) {
1265
1266
let all_candidates: Vec < _ > = candidates. into_iter ( ) . map ( |c| c. result ) . collect ( ) ;
@@ -1341,13 +1342,16 @@ where
1341
1342
1342
1343
// If there are *only* global where bounds, then make sure to return that this
1343
1344
// is still reported as being proven-via the param-env so that rigid projections
1344
- // operate correctly.
1345
+ // operate correctly. Otherwise, drop all global where-bounds before merging the
1346
+ // remaining candidates.
1345
1347
let proven_via =
1346
1348
if candidates. iter ( ) . all ( |c| matches ! ( c. source, CandidateSource :: ParamEnv ( _) ) ) {
1347
1349
TraitGoalProvenVia :: ParamEnv
1348
1350
} else {
1351
+ candidates. retain ( |c| !matches ! ( c. source, CandidateSource :: ParamEnv ( _) ) ) ;
1349
1352
TraitGoalProvenVia :: Misc
1350
1353
} ;
1354
+
1351
1355
let all_candidates: Vec < _ > = candidates. into_iter ( ) . map ( |c| c. result ) . collect ( ) ;
1352
1356
if let Some ( response) = self . try_merge_responses ( & all_candidates) {
1353
1357
Ok ( ( response, Some ( proven_via) ) )
0 commit comments