@@ -18,8 +18,8 @@ use rustc_middle::traits::query::NoSolution;
18
18
use rustc_middle:: traits:: solve:: { inspect, QueryResult } ;
19
19
use rustc_middle:: traits:: solve:: { Certainty , Goal } ;
20
20
use rustc_middle:: traits:: ObligationCause ;
21
- use rustc_middle:: ty;
22
21
use rustc_middle:: ty:: TypeFoldable ;
22
+ use rustc_middle:: { bug, ty} ;
23
23
use rustc_span:: { Span , DUMMY_SP } ;
24
24
25
25
use crate :: solve:: eval_ctxt:: canonical;
@@ -290,12 +290,25 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
290
290
match * step {
291
291
inspect:: ProbeStep :: AddGoal ( source, goal) => nested_goals. push ( ( source, goal) ) ,
292
292
inspect:: ProbeStep :: NestedProbe ( ref probe) => {
293
- // Nested probes have to prove goals added in their parent
294
- // but do not leak them, so we truncate the added goals
295
- // afterwards.
296
- let num_goals = nested_goals. len ( ) ;
297
- self . candidates_recur ( candidates, nested_goals, probe) ;
298
- nested_goals. truncate ( num_goals) ;
293
+ match probe. kind {
294
+ // These never assemble candidates for the goal we're trying to solve.
295
+ inspect:: ProbeKind :: UpcastProjectionCompatibility
296
+ | inspect:: ProbeKind :: ShadowedEnvProbing => continue ,
297
+
298
+ inspect:: ProbeKind :: NormalizedSelfTyAssembly
299
+ | inspect:: ProbeKind :: UnsizeAssembly
300
+ | inspect:: ProbeKind :: Root { .. }
301
+ | inspect:: ProbeKind :: TryNormalizeNonRigid { .. }
302
+ | inspect:: ProbeKind :: TraitCandidate { .. }
303
+ | inspect:: ProbeKind :: OpaqueTypeStorageLookup { .. } => {
304
+ // Nested probes have to prove goals added in their parent
305
+ // but do not leak them, so we truncate the added goals
306
+ // afterwards.
307
+ let num_goals = nested_goals. len ( ) ;
308
+ self . candidates_recur ( candidates, nested_goals, probe) ;
309
+ nested_goals. truncate ( num_goals) ;
310
+ }
311
+ }
299
312
}
300
313
inspect:: ProbeStep :: MakeCanonicalResponse { shallow_certainty : c } => {
301
314
assert_eq ! ( shallow_certainty. replace( c) , None ) ;
@@ -308,9 +321,10 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
308
321
}
309
322
310
323
match probe. kind {
311
- inspect:: ProbeKind :: NormalizedSelfTyAssembly
312
- | inspect:: ProbeKind :: UnsizeAssembly
313
- | inspect:: ProbeKind :: UpcastProjectionCompatibility => ( ) ,
324
+ inspect:: ProbeKind :: UpcastProjectionCompatibility
325
+ | inspect:: ProbeKind :: ShadowedEnvProbing => bug ! ( ) ,
326
+
327
+ inspect:: ProbeKind :: NormalizedSelfTyAssembly | inspect:: ProbeKind :: UnsizeAssembly => { }
314
328
315
329
// We add a candidate even for the root evaluation if there
316
330
// is only one way to prove a given goal, e.g. for `WellFormed`.
0 commit comments