Skip to content

Commit 3472813

Browse files
committed
impl graphviz trait for a newtype of regioncx
1 parent 4f4350d commit 3472813

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

Diff for: src/librustc_mir/borrow_check/nll/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
296296
let _: io::Result<()> = do catch {
297297
let mut file =
298298
pretty::create_dump_file(infcx.tcx, "regioncx.dot", None, "nll", &0, source)?;
299-
regioncx.dump_graphviz(&mut file)?;
299+
regioncx.dump_graphviz_raw_constraints(&mut file)?;
300300
};
301301
}
302302

Diff for: src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ use std::io::{self, Write};
1919
use super::*;
2020
use borrow_check::nll::constraints::OutlivesConstraint;
2121

22-
2322
impl<'tcx> RegionInferenceContext<'tcx> {
2423
/// Write out the region constraint graph.
25-
pub(crate) fn dump_graphviz(&self, mut w: &mut dyn Write) -> io::Result<()> {
26-
dot::render(self, &mut w)
24+
pub(crate) fn dump_graphviz_raw_constraints(&self, mut w: &mut dyn Write) -> io::Result<()> {
25+
dot::render(&RawConstraints { regioncx: self }, &mut w)
2726
}
2827
}
2928

30-
impl<'this, 'tcx> dot::Labeller<'this> for RegionInferenceContext<'tcx> {
29+
struct RawConstraints<'a, 'tcx: 'a> {
30+
regioncx: &'a RegionInferenceContext<'tcx>
31+
}
32+
33+
impl<'a, 'this, 'tcx> dot::Labeller<'this> for RawConstraints<'a, 'tcx> {
3134
type Node = RegionVid;
3235
type Edge = OutlivesConstraint;
3336

@@ -48,16 +51,16 @@ impl<'this, 'tcx> dot::Labeller<'this> for RegionInferenceContext<'tcx> {
4851
}
4952
}
5053

51-
impl<'this, 'tcx> dot::GraphWalk<'this> for RegionInferenceContext<'tcx> {
54+
impl<'a, 'this, 'tcx> dot::GraphWalk<'this> for RawConstraints<'a, 'tcx> {
5255
type Node = RegionVid;
5356
type Edge = OutlivesConstraint;
5457

5558
fn nodes(&'this self) -> dot::Nodes<'this, RegionVid> {
56-
let vids: Vec<RegionVid> = self.definitions.indices().collect();
59+
let vids: Vec<RegionVid> = self.regioncx.definitions.indices().collect();
5760
vids.into_cow()
5861
}
5962
fn edges(&'this self) -> dot::Edges<'this, OutlivesConstraint> {
60-
(&self.constraints.raw[..]).into_cow()
63+
(&self.regioncx.constraints.raw[..]).into_cow()
6164
}
6265

6366
// Render `a: b` as `a <- b`, indicating the flow

0 commit comments

Comments
 (0)