提交 d5e77a3c 编写于 作者: N Niko Matsakis

impl graphviz trait for a newtype of regioncx

上级 ed366980
......@@ -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)?;
};
}
......
......@@ -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<RegionVid> = self.definitions.indices().collect();
let vids: Vec<RegionVid> = 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册