diff options
| author | lcnr <rust@lcnr.de> | 2023-09-21 08:40:36 +0200 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2023-09-21 08:40:36 +0200 |
| commit | 8e139eefaf276108c56fda1ec0c7fb972ce8df0c (patch) | |
| tree | b0df65ca1e03ca6cc0d0584c027d3e206a37f430 /compiler | |
| parent | 8024c69c2985274f8caf8bccdeec92a5632bd8c3 (diff) | |
| download | rust-8e139eefaf276108c56fda1ec0c7fb972ce8df0c.tar.gz rust-8e139eefaf276108c56fda1ec0c7fb972ce8df0c.zip | |
slight refactor, add comment
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/inspect/analyse.rs | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs index ece0e801fe8..e4fc8803e0f 100644 --- a/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs +++ b/compiler/rustc_trait_selection/src/solve/inspect/analyse.rs @@ -123,6 +123,9 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> { &inspect::ProbeStep::AddGoal(goal) => nested_goals.push(goal), inspect::ProbeStep::EvaluateGoals(_) => (), 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); @@ -131,10 +134,25 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> { } match probe.kind { - inspect::ProbeKind::Root { result: _ } - | inspect::ProbeKind::NormalizedSelfTyAssembly + inspect::ProbeKind::NormalizedSelfTyAssembly | inspect::ProbeKind::UnsizeAssembly | inspect::ProbeKind::UpcastProjectionCompatibility => (), + // We add a candidate for the root evaluation if there + // is only one way to prove a given goal, e.g. for `WellFormed`. + // + // FIXME: This is currently wrong if we don't even try any + // candidates, e.g. for a trait goal, as in this case `candidates` is + // actually supposed to be empty. + inspect::ProbeKind::Root { result: _ } => { + if candidates.is_empty() { + candidates.push(InspectCandidate { + goal: self, + kind: probe.kind, + nested_goals: nested_goals.clone(), + result, + }); + } + } inspect::ProbeKind::MiscCandidate { name: _, result } | inspect::ProbeKind::TraitCandidate { source: _, result } => { candidates.push(InspectCandidate { @@ -167,15 +185,6 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> { let mut nested_goals = vec![]; self.candidates_recur(&mut candidates, &mut nested_goals, &last_eval_step.evaluation); - if candidates.is_empty() { - candidates.push(InspectCandidate { - goal: self, - kind: last_eval_step.evaluation.kind, - nested_goals, - result: self.evaluation.evaluation.result, - }); - } - candidates } |
