add in a depth-first number for stack entries
This commit is contained in:
parent
c86f948714
commit
a1a8a7b986
1 changed files with 16 additions and 0 deletions
|
@ -188,6 +188,11 @@ struct TraitObligationStack<'prev, 'tcx: 'prev> {
|
||||||
|
|
||||||
/// Number of parent frames plus one -- so the topmost frame has depth 1.
|
/// Number of parent frames plus one -- so the topmost frame has depth 1.
|
||||||
depth: usize,
|
depth: usize,
|
||||||
|
|
||||||
|
/// Depth-first number of this node in the search graph -- a
|
||||||
|
/// pre-order index. Basically a freshly incremented counter.
|
||||||
|
#[allow(dead_code)] // TODO
|
||||||
|
dfn: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
|
@ -3770,12 +3775,14 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||||
.to_poly_trait_ref()
|
.to_poly_trait_ref()
|
||||||
.fold_with(&mut self.freshener);
|
.fold_with(&mut self.freshener);
|
||||||
|
|
||||||
|
let dfn = previous_stack.cache.next_dfn();
|
||||||
let depth = previous_stack.depth() + 1;
|
let depth = previous_stack.depth() + 1;
|
||||||
TraitObligationStack {
|
TraitObligationStack {
|
||||||
obligation,
|
obligation,
|
||||||
fresh_trait_ref,
|
fresh_trait_ref,
|
||||||
reached_depth: Cell::new(depth),
|
reached_depth: Cell::new(depth),
|
||||||
previous: previous_stack,
|
previous: previous_stack,
|
||||||
|
dfn,
|
||||||
depth,
|
depth,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3999,9 +4006,18 @@ impl<'o, 'tcx> TraitObligationStack<'o, 'tcx> {
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct ProvisionalEvaluationCache<'tcx> {
|
struct ProvisionalEvaluationCache<'tcx> {
|
||||||
|
dfn: Cell<usize>,
|
||||||
_dummy: Vec<&'tcx ()>,
|
_dummy: Vec<&'tcx ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'tcx> ProvisionalEvaluationCache<'tcx> {
|
||||||
|
fn next_dfn(&self) -> usize {
|
||||||
|
let result = self.dfn.get();
|
||||||
|
self.dfn.set(result + 1);
|
||||||
|
result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
struct TraitObligationStackList<'o, 'tcx: 'o> {
|
struct TraitObligationStackList<'o, 'tcx: 'o> {
|
||||||
cache: &'o ProvisionalEvaluationCache<'tcx>,
|
cache: &'o ProvisionalEvaluationCache<'tcx>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue