Skip to content

Commit 89d0e7c

Browse files
Fix ProvenVia for global where clauses
1 parent 0c478fd commit 89d0e7c

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 {
@@ -1322,9 +1321,18 @@ where
13221321
};
13231322
}
13241323

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