about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/solve/inspect
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-05-07 11:09:21 -0400
committerMichael Goulet <michael@errs.io>2024-05-13 23:58:33 -0400
commitdbd2ca6478dca81dc4ed64f9dec09fb216d34f1a (patch)
tree1e69b1a123de5dddc79edcd512c89956b13f5016 /compiler/rustc_trait_selection/src/solve/inspect
parent9105c57b7f6623310e33f3ee7e48a3114e5190a7 (diff)
downloadrust-dbd2ca6478dca81dc4ed64f9dec09fb216d34f1a.tar.gz
rust-dbd2ca6478dca81dc4ed64f9dec09fb216d34f1a.zip
Use a proper probe for shadowing impl
Diffstat (limited to 'compiler/rustc_trait_selection/src/solve/inspect')
-rw-r--r--compiler/rustc_trait_selection/src/solve/inspect/analyse.rs34
1 files changed, 24 insertions, 10 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs
index fd36b7ffd4e..b71a1b339cb 100644
--- a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs
+++ b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs
@@ -18,8 +18,8 @@ use rustc_middle::traits::query::NoSolution;
 use rustc_middle::traits::solve::{inspect, QueryResult};
 use rustc_middle::traits::solve::{Certainty, Goal};
 use rustc_middle::traits::ObligationCause;
-use rustc_middle::ty;
 use rustc_middle::ty::TypeFoldable;
+use rustc_middle::{bug, ty};
 use rustc_span::{Span, DUMMY_SP};
 
 use crate::solve::eval_ctxt::canonical;
@@ -290,12 +290,25 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
             match *step {
                 inspect::ProbeStep::AddGoal(source, goal) => nested_goals.push((source, goal)),
                 inspect::ProbeStep::NestedProbe(ref probe) => {
-                    // Nested probes have to prove goals added in their parent
-                    // but do not leak them, so we truncate the added goals
-                    // afterwards.
-                    let num_goals = nested_goals.len();
-                    self.candidates_recur(candidates, nested_goals, probe);
-                    nested_goals.truncate(num_goals);
+                    match probe.kind {
+                        // These never assemble candidates for the goal we're trying to solve.
+                        inspect::ProbeKind::UpcastProjectionCompatibility
+                        | inspect::ProbeKind::ShadowedEnvProbing => continue,
+
+                        inspect::ProbeKind::NormalizedSelfTyAssembly
+                        | inspect::ProbeKind::UnsizeAssembly
+                        | inspect::ProbeKind::Root { .. }
+                        | inspect::ProbeKind::TryNormalizeNonRigid { .. }
+                        | inspect::ProbeKind::TraitCandidate { .. }
+                        | inspect::ProbeKind::OpaqueTypeStorageLookup { .. } => {
+                            // Nested probes have to prove goals added in their parent
+                            // but do not leak them, so we truncate the added goals
+                            // afterwards.
+                            let num_goals = nested_goals.len();
+                            self.candidates_recur(candidates, nested_goals, probe);
+                            nested_goals.truncate(num_goals);
+                        }
+                    }
                 }
                 inspect::ProbeStep::MakeCanonicalResponse { shallow_certainty: c } => {
                     assert_eq!(shallow_certainty.replace(c), None);
@@ -308,9 +321,10 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
         }
 
         match probe.kind {
-            inspect::ProbeKind::NormalizedSelfTyAssembly
-            | inspect::ProbeKind::UnsizeAssembly
-            | inspect::ProbeKind::UpcastProjectionCompatibility => (),
+            inspect::ProbeKind::UpcastProjectionCompatibility
+            | inspect::ProbeKind::ShadowedEnvProbing => bug!(),
+
+            inspect::ProbeKind::NormalizedSelfTyAssembly | inspect::ProbeKind::UnsizeAssembly => {}
 
             // We add a candidate even for the root evaluation if there
             // is only one way to prove a given goal, e.g. for `WellFormed`.