Skip to content

Commit 2752dad

Browse files
Fix ProvenVia for global where clauses
1 parent 0c478fd commit 2752dad

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,6 @@ where
13011301
.filter(|c| matches!(c.source, CandidateSource::ParamEnv(_)))
13021302
.map(|c| c.result)
13031303
.collect();
1304-
13051304
return if let Some(response) = self.try_merge_responses(&where_bounds) {
13061305
Ok((response, Some(TraitGoalProvenVia::ParamEnv)))
13071306
} else {
@@ -1324,7 +1323,16 @@ where
13241323

13251324
let all_candidates: Vec<_> = candidates.into_iter().map(|c| c.result).collect();
13261325
if let Some(response) = self.try_merge_responses(&all_candidates) {
1327-
Ok((response, Some(TraitGoalProvenVia::Misc)))
1326+
// If there are *only* global where bounds, then make sure to return that this
1327+
// is still reported as being proven-via the param-env so that rigid projections
1328+
// operate correctly.
1329+
let proven_via =
1330+
if candidates.iter().all(|c| matches!(c.source, CandidateSource::ParamEnv(_))) {
1331+
TraitGoalProvenVia::ParamEnv
1332+
} else {
1333+
TraitGoalProvenVia::Misc
1334+
};
1335+
Ok((response, Some(proven_via)))
13281336
} else {
13291337
self.flounder(&all_candidates).map(|r| (r, None))
13301338
}

tests/ui/codegen/mono-impossible-drop.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//@ revisions: current next
2+
//@ ignore-compare-mode-next-solver (explicit revisions)
3+
//@[next] compile-flags: -Znext-solver
14
//@ compile-flags: -Clink-dead-code=on --crate-type=lib
25
//@ build-pass
36

0 commit comments

Comments
 (0)