Skip to content

Commit 995cb2f

Browse files
Fix ProvenVia for global where clauses
1 parent 87e60a7 commit 995cb2f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

compiler/rustc_next_trait_solver/src/solve/trait_goals.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1288,13 +1288,20 @@ where
12881288
}
12891289
_ => false,
12901290
});
1291-
if has_non_global_where_bounds {
1291+
1292+
// As mentioned above, if there are non-global where bounds, then prefer all where bounds
1293+
// (including global ones) over anything else. If there are *only* where bounds, then
1294+
// make sure to return that this is proven-via the param-env so that rigid projections
1295+
// operate correctly.
1296+
if has_non_global_where_bounds
1297+
|| (candidates.len() > 0
1298+
&& candidates.iter().all(|c| matches!(c.source, CandidateSource::ParamEnv(_))))
1299+
{
12921300
let where_bounds: Vec<_> = candidates
12931301
.iter()
12941302
.filter(|c| matches!(c.source, CandidateSource::ParamEnv(_)))
12951303
.map(|c| c.result)
12961304
.collect();
1297-
12981305
return if let Some(response) = self.try_merge_responses(&where_bounds) {
12991306
Ok((response, Some(TraitGoalProvenVia::ParamEnv)))
13001307
} else {

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)