Skip to content

Commit a1a8a7b

Browse files
committed
add in a depth-first number for stack entries
1 parent c86f948 commit a1a8a7b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/librustc/traits/select.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ struct TraitObligationStack<'prev, 'tcx: 'prev> {
188188

189189
/// Number of parent frames plus one -- so the topmost frame has depth 1.
190190
depth: usize,
191+
192+
/// Depth-first number of this node in the search graph -- a
193+
/// pre-order index. Basically a freshly incremented counter.
194+
#[allow(dead_code)] // TODO
195+
dfn: usize,
191196
}
192197

193198
#[derive(Clone, Default)]
@@ -3770,12 +3775,14 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
37703775
.to_poly_trait_ref()
37713776
.fold_with(&mut self.freshener);
37723777

3778+
let dfn = previous_stack.cache.next_dfn();
37733779
let depth = previous_stack.depth() + 1;
37743780
TraitObligationStack {
37753781
obligation,
37763782
fresh_trait_ref,
37773783
reached_depth: Cell::new(depth),
37783784
previous: previous_stack,
3785+
dfn,
37793786
depth,
37803787
}
37813788
}
@@ -3999,9 +4006,18 @@ impl<'o, 'tcx> TraitObligationStack<'o, 'tcx> {
39994006

40004007
#[derive(Default)]
40014008
struct ProvisionalEvaluationCache<'tcx> {
4009+
dfn: Cell<usize>,
40024010
_dummy: Vec<&'tcx ()>,
40034011
}
40044012

4013+
impl<'tcx> ProvisionalEvaluationCache<'tcx> {
4014+
fn next_dfn(&self) -> usize {
4015+
let result = self.dfn.get();
4016+
self.dfn.set(result + 1);
4017+
result
4018+
}
4019+
}
4020+
40054021
#[derive(Copy, Clone)]
40064022
struct TraitObligationStackList<'o, 'tcx: 'o> {
40074023
cache: &'o ProvisionalEvaluationCache<'tcx>,

0 commit comments

Comments
 (0)