Skip to content

Commit edc5658

Browse files
Collect *all* added goals, not just those from our probe
1 parent a2e61d3 commit edc5658

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

compiler/rustc_trait_selection/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@
1212
1313
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1414
#![doc(rust_logo)]
15-
#![feature(rustdoc_internals)]
1615
#![allow(internal_features)]
1716
#![allow(rustc::diagnostic_outside_of_impl)]
1817
#![allow(rustc::untranslatable_diagnostic)]
1918
#![feature(assert_matches)]
2019
#![feature(associated_type_defaults)]
2120
#![feature(box_patterns)]
2221
#![feature(control_flow_enum)]
22+
#![feature(coroutines)]
2323
#![feature(extract_if)]
2424
#![feature(if_let_guard)]
25+
#![feature(iter_from_coroutine)]
2526
#![feature(let_chains)]
26-
#![feature(option_take_if)]
2727
#![feature(never_type)]
28+
#![feature(option_take_if)]
29+
#![feature(rustdoc_internals)]
2830
#![feature(type_alias_impl_trait)]
2931
#![recursion_limit = "512"] // For rustdoc
3032

compiler/rustc_trait_selection/src/solve/inspect/build.rs

+29-6
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,34 @@ impl<'tcx> WipGoalEvaluationStep<'tcx> {
216216
}
217217
inspect::GoalEvaluationStep { instantiated_goal: self.instantiated_goal, evaluation }
218218
}
219+
220+
// Returns all added goals from this scope and all containing scopes.
221+
fn all_added_goals(
222+
&self,
223+
) -> impl Iterator<Item = (GoalSource, Goal<'tcx, ty::Predicate<'tcx>>)> + '_ {
224+
std::iter::from_coroutine(
225+
#[coroutine]
226+
|| {
227+
let mut current = &self.evaluation;
228+
for i in 0.. {
229+
for step in &current.steps {
230+
if let WipProbeStep::AddGoal(source, goal) = *step {
231+
yield (source, goal);
232+
}
233+
}
234+
235+
if i < self.probe_depth {
236+
let Some(WipProbeStep::NestedProbe(p)) = current.steps.last() else {
237+
bug!();
238+
};
239+
current = p;
240+
} else {
241+
break;
242+
}
243+
}
244+
},
245+
)
246+
}
219247
}
220248

221249
#[derive(Eq, PartialEq, Debug)]
@@ -530,12 +558,7 @@ impl<'tcx> ProofTreeBuilder<'tcx> {
530558
) {
531559
match self.as_mut() {
532560
Some(DebugSolver::GoalEvaluationStep(state)) => {
533-
let added_goals = infcx.tcx.mk_nested_goals_from_iter(
534-
state.current_evaluation_scope().steps.iter().filter_map(|step| match *step {
535-
WipProbeStep::AddGoal(source, goal) => Some((source, goal)),
536-
_ => None,
537-
}),
538-
);
561+
let added_goals = infcx.tcx.mk_nested_goals_from_iter(state.all_added_goals());
539562
let added_goals = canonical::make_canonical_state(
540563
infcx,
541564
&state.var_values,

0 commit comments

Comments
 (0)