diff options
| author | Michael Goulet <michael@errs.io> | 2025-04-05 16:16:50 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-04-05 16:23:25 +0000 |
| commit | 89d0e7c03391efda88f4736f3f04f4c5a8ae71d3 (patch) | |
| tree | 540241b501612844877d630fd08e9b30d366c414 | |
| parent | 0c478fdfe138a8b09744798c85fe2be657768b00 (diff) | |
| download | rust-89d0e7c03391efda88f4736f3f04f4c5a8ae71d3.tar.gz rust-89d0e7c03391efda88f4736f3f04f4c5a8ae71d3.zip | |
Fix ProvenVia for global where clauses
| -rw-r--r-- | compiler/rustc_next_trait_solver/src/solve/trait_goals.rs | 12 | ||||
| -rw-r--r-- | tests/ui/codegen/mono-impossible-drop.rs | 3 |
2 files changed, 13 insertions, 2 deletions
diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs index c46169a26c1..d42c9980f46 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -1301,7 +1301,6 @@ where .filter(|c| matches!(c.source, CandidateSource::ParamEnv(_))) .map(|c| c.result) .collect(); - return if let Some(response) = self.try_merge_responses(&where_bounds) { Ok((response, Some(TraitGoalProvenVia::ParamEnv))) } else { @@ -1322,9 +1321,18 @@ where }; } + // If there are *only* global where bounds, then make sure to return that this + // is still reported as being proven-via the param-env so that rigid projections + // operate correctly. + let proven_via = + if candidates.iter().all(|c| matches!(c.source, CandidateSource::ParamEnv(_))) { + TraitGoalProvenVia::ParamEnv + } else { + TraitGoalProvenVia::Misc + }; let all_candidates: Vec<_> = candidates.into_iter().map(|c| c.result).collect(); if let Some(response) = self.try_merge_responses(&all_candidates) { - Ok((response, Some(TraitGoalProvenVia::Misc))) + Ok((response, Some(proven_via))) } else { self.flounder(&all_candidates).map(|r| (r, None)) } diff --git a/tests/ui/codegen/mono-impossible-drop.rs b/tests/ui/codegen/mono-impossible-drop.rs index dec013cfe54..c8a9554da43 100644 --- a/tests/ui/codegen/mono-impossible-drop.rs +++ b/tests/ui/codegen/mono-impossible-drop.rs @@ -1,3 +1,6 @@ +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver //@ compile-flags: -Clink-dead-code=on --crate-type=lib //@ build-pass |
