about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2023-08-15 14:29:49 +0200
committerGitHub <noreply@github.com>2023-08-15 14:29:49 +0200
commit47bdda2b459cbbc8526beeed1aa97ee5f99422c1 (patch)
tree3290e52fecb193fe9d88d92572d7d803bbfac3be /compiler/rustc_trait_selection/src
parente4b9e72e58a8a5987bd391aa8c7bf7008c2c9e2e (diff)
parentab126c2a4e6b6835073949da4ab913d85989db09 (diff)
downloadrust-47bdda2b459cbbc8526beeed1aa97ee5f99422c1.tar.gz
rust-47bdda2b459cbbc8526beeed1aa97ee5f99422c1.zip
Rollup merge of #114828 - compiler-errors:next-solver-probe-upcasting, r=lcnr
Probe when assembling upcast candidates so they don't step on eachother's toes in new solver

Lack of a probe causes one candidate to disqualify the other due to inference side-effects.

r? lcnr
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/solve/trait_goals.rs22
1 files changed, 12 insertions, 10 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals.rs b/compiler/rustc_trait_selection/src/solve/trait_goals.rs
index ee6f1686b82..8bab20e1942 100644
--- a/compiler/rustc_trait_selection/src/solve/trait_goals.rs
+++ b/compiler/rustc_trait_selection/src/solve/trait_goals.rs
@@ -552,16 +552,18 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
             self.walk_vtable(
                 a_principal.with_self_ty(tcx, a_ty),
                 |ecx, new_a_principal, _, vtable_vptr_slot| {
-                    if let Ok(resp) = ecx.consider_builtin_upcast_to_principal(
-                        goal,
-                        a_data,
-                        a_region,
-                        b_data,
-                        b_region,
-                        Some(new_a_principal.map_bound(|trait_ref| {
-                            ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)
-                        })),
-                    ) {
+                    if let Ok(resp) = ecx.probe_candidate("dyn upcast").enter(|ecx| {
+                        ecx.consider_builtin_upcast_to_principal(
+                            goal,
+                            a_data,
+                            a_region,
+                            b_data,
+                            b_region,
+                            Some(new_a_principal.map_bound(|trait_ref| {
+                                ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)
+                            })),
+                        )
+                    }) {
                         responses
                             .push((resp, BuiltinImplSource::TraitUpcasting { vtable_vptr_slot }));
                     }