From d5e77a3c75d1268880c7613c60593748ab6de4c5 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 4 Jul 2018 06:07:17 -0400 Subject: [PATCH] impl graphviz trait for a newtype of regioncx --- src/librustc_mir/borrow_check/nll/mod.rs | 2 +- .../borrow_check/nll/region_infer/graphviz.rs | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/librustc_mir/borrow_check/nll/mod.rs b/src/librustc_mir/borrow_check/nll/mod.rs index 26298a289fc..641d7ed342c 100644 --- a/src/librustc_mir/borrow_check/nll/mod.rs +++ b/src/librustc_mir/borrow_check/nll/mod.rs @@ -296,7 +296,7 @@ fn dump_mir_results<'a, 'gcx, 'tcx>( let _: io::Result<()> = do catch { let mut file = pretty::create_dump_file(infcx.tcx, "regioncx.dot", None, "nll", &0, source)?; - regioncx.dump_graphviz(&mut file)?; + regioncx.dump_graphviz_raw_constraints(&mut file)?; }; } diff --git a/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs b/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs index 8be51257cd6..2e41c8f8dd6 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs @@ -19,15 +19,18 @@ use super::*; use borrow_check::nll::constraints::OutlivesConstraint; - impl<'tcx> RegionInferenceContext<'tcx> { /// Write out the region constraint graph. - pub(crate) fn dump_graphviz(&self, mut w: &mut dyn Write) -> io::Result<()> { - dot::render(self, &mut w) + pub(crate) fn dump_graphviz_raw_constraints(&self, mut w: &mut dyn Write) -> io::Result<()> { + dot::render(&RawConstraints { regioncx: self }, &mut w) } } -impl<'this, 'tcx> dot::Labeller<'this> for RegionInferenceContext<'tcx> { +struct RawConstraints<'a, 'tcx: 'a> { + regioncx: &'a RegionInferenceContext<'tcx> +} + +impl<'a, 'this, 'tcx> dot::Labeller<'this> for RawConstraints<'a, 'tcx> { type Node = RegionVid; type Edge = OutlivesConstraint; @@ -48,16 +51,16 @@ fn edge_label(&'this self, e: &OutlivesConstraint) -> dot::LabelText<'this> { } } -impl<'this, 'tcx> dot::GraphWalk<'this> for RegionInferenceContext<'tcx> { +impl<'a, 'this, 'tcx> dot::GraphWalk<'this> for RawConstraints<'a, 'tcx> { type Node = RegionVid; type Edge = OutlivesConstraint; fn nodes(&'this self) -> dot::Nodes<'this, RegionVid> { - let vids: Vec = self.definitions.indices().collect(); + let vids: Vec = self.regioncx.definitions.indices().collect(); vids.into_cow() } fn edges(&'this self) -> dot::Edges<'this, OutlivesConstraint> { - (&self.constraints.raw[..]).into_cow() + (&self.regioncx.constraints.raw[..]).into_cow() } // Render `a: b` as `a <- b`, indicating the flow -- 2.44.0