diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-04-05 19:40:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-05 19:40:24 +0200 |
| commit | 6d88291d3cf18893eb7ba650674783e6ec63e63e (patch) | |
| tree | 3936b450148f0db3d6bb3a4e2930baaa124dc64e | |
| parent | 0b342873e3d8271d89ac1b959482526f8a441858 (diff) | |
| parent | 89d0e7c03391efda88f4736f3f04f4c5a8ae71d3 (diff) | |
| download | rust-6d88291d3cf18893eb7ba650674783e6ec63e63e.tar.gz rust-6d88291d3cf18893eb7ba650674783e6ec63e63e.zip | |
Rollup merge of #138797 - compiler-errors:global-proven-via, r=lcnr
Fix `ProvenVia` for global where clauses When we're merging one (or more) global where clauses in the presence of no other candidates, ensure that we return `TraitGoalProvenVia::ParamEnv` so that rigid projections work correctly. This fixes some tests with `feature(trivial_bounds)`. Fixes #139408
| -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 |
