diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2019-06-10 16:22:10 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2019-06-12 13:56:28 -0400 |
| commit | a1a8a7b9869b4b2627b88f293ad92160ed826688 (patch) | |
| tree | ad1a7c5877837d4a5e79445cad2058974a01a57a | |
| parent | c86f94871459608479373b37fe38e4e522f28114 (diff) | |
| download | rust-a1a8a7b9869b4b2627b88f293ad92160ed826688.tar.gz rust-a1a8a7b9869b4b2627b88f293ad92160ed826688.zip | |
add in a depth-first number for stack entries
| -rw-r--r-- | src/librustc/traits/select.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 1de248378bd..31ef31808c4 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -188,6 +188,11 @@ struct TraitObligationStack<'prev, 'tcx: 'prev> { /// Number of parent frames plus one -- so the topmost frame has depth 1. 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)] @@ -3770,12 +3775,14 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { .to_poly_trait_ref() .fold_with(&mut self.freshener); + let dfn = previous_stack.cache.next_dfn(); let depth = previous_stack.depth() + 1; TraitObligationStack { obligation, fresh_trait_ref, reached_depth: Cell::new(depth), previous: previous_stack, + dfn, depth, } } @@ -3999,9 +4006,18 @@ impl<'o, 'tcx> TraitObligationStack<'o, 'tcx> { #[derive(Default)] struct ProvisionalEvaluationCache<'tcx> { + dfn: Cell<usize>, _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)] struct TraitObligationStackList<'o, 'tcx: 'o> { cache: &'o ProvisionalEvaluationCache<'tcx>, |
