@@ -1238,10 +1238,11 @@ where
1238
1238
D : SolverDelegate < Interner = I > ,
1239
1239
I : Interner ,
1240
1240
{
1241
+ #[ instrument( level = "debug" , skip( self , goal) , ret) ]
1241
1242
pub ( super ) fn merge_trait_candidates (
1242
1243
& mut self ,
1243
1244
goal : Goal < I , TraitPredicate < I > > ,
1244
- candidates : Vec < Candidate < I > > ,
1245
+ mut candidates : Vec < Candidate < I > > ,
1245
1246
) -> Result < ( CanonicalResponse < I > , Option < TraitGoalProvenVia > ) , NoSolution > {
1246
1247
if let TypingMode :: Coherence = self . typing_mode ( ) {
1247
1248
let all_candidates: Vec < _ > = candidates. into_iter ( ) . map ( |c| c. result ) . collect ( ) ;
@@ -1323,13 +1324,16 @@ where
1323
1324
1324
1325
// If there are *only* global where bounds, then make sure to return that this
1325
1326
// is still reported as being proven-via the param-env so that rigid projections
1326
- // operate correctly.
1327
+ // operate correctly. Otherwise, drop all global where-bounds before merging the
1328
+ // remaining candidates.
1327
1329
let proven_via =
1328
1330
if candidates. iter ( ) . all ( |c| matches ! ( c. source, CandidateSource :: ParamEnv ( _) ) ) {
1329
1331
TraitGoalProvenVia :: ParamEnv
1330
1332
} else {
1333
+ candidates. retain ( |c| !matches ! ( c. source, CandidateSource :: ParamEnv ( _) ) ) ;
1331
1334
TraitGoalProvenVia :: Misc
1332
1335
} ;
1336
+
1333
1337
let all_candidates: Vec < _ > = candidates. into_iter ( ) . map ( |c| c. result ) . collect ( ) ;
1334
1338
if let Some ( response) = self . try_merge_responses ( & all_candidates) {
1335
1339
Ok ( ( response, Some ( proven_via) ) )
0 commit comments