@@ -26,11 +26,15 @@ fn render_universe(u: UniverseIndex) -> String {
26
26
format ! ( "/{:?}" , u)
27
27
}
28
28
29
- fn render_region_vid ( rvid : RegionVid , regioncx : & RegionInferenceContext < ' _ > ) -> String {
29
+ fn render_region_vid < ' tcx > (
30
+ tcx : TyCtxt < ' tcx > ,
31
+ rvid : RegionVid ,
32
+ regioncx : & RegionInferenceContext < ' tcx > ,
33
+ ) -> String {
30
34
let universe_str = render_universe ( regioncx. region_definition ( rvid) . universe ) ;
31
35
32
36
let external_name_str = if let Some ( external_name) =
33
- regioncx. region_definition ( rvid) . external_name . and_then ( |e| e. get_name ( ) )
37
+ regioncx. region_definition ( rvid) . external_name . and_then ( |e| e. get_name ( tcx ) )
34
38
{
35
39
format ! ( " ({external_name})" )
36
40
} else {
@@ -42,12 +46,20 @@ fn render_region_vid(rvid: RegionVid, regioncx: &RegionInferenceContext<'_>) ->
42
46
43
47
impl < ' tcx > RegionInferenceContext < ' tcx > {
44
48
/// Write out the region constraint graph.
45
- pub ( crate ) fn dump_graphviz_raw_constraints ( & self , mut w : & mut dyn Write ) -> io:: Result < ( ) > {
46
- dot:: render ( & RawConstraints { regioncx : self } , & mut w)
49
+ pub ( crate ) fn dump_graphviz_raw_constraints (
50
+ & self ,
51
+ tcx : TyCtxt < ' tcx > ,
52
+ mut w : & mut dyn Write ,
53
+ ) -> io:: Result < ( ) > {
54
+ dot:: render ( & RawConstraints { tcx, regioncx : self } , & mut w)
47
55
}
48
56
49
57
/// Write out the region constraint SCC graph.
50
- pub ( crate ) fn dump_graphviz_scc_constraints ( & self , mut w : & mut dyn Write ) -> io:: Result < ( ) > {
58
+ pub ( crate ) fn dump_graphviz_scc_constraints (
59
+ & self ,
60
+ tcx : TyCtxt < ' tcx > ,
61
+ mut w : & mut dyn Write ,
62
+ ) -> io:: Result < ( ) > {
51
63
let mut nodes_per_scc: IndexVec < ConstraintSccIndex , _ > =
52
64
self . constraint_sccs . all_sccs ( ) . map ( |_| Vec :: new ( ) ) . collect ( ) ;
53
65
@@ -56,11 +68,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
56
68
nodes_per_scc[ scc] . push ( region) ;
57
69
}
58
70
59
- dot:: render ( & SccConstraints { regioncx : self , nodes_per_scc } , & mut w)
71
+ dot:: render ( & SccConstraints { tcx , regioncx : self , nodes_per_scc } , & mut w)
60
72
}
61
73
}
62
74
63
75
struct RawConstraints < ' a , ' tcx > {
76
+ tcx : TyCtxt < ' tcx > ,
64
77
regioncx : & ' a RegionInferenceContext < ' tcx > ,
65
78
}
66
79
@@ -78,7 +91,7 @@ impl<'a, 'this, 'tcx> dot::Labeller<'this> for RawConstraints<'a, 'tcx> {
78
91
Some ( dot:: LabelText :: LabelStr ( Cow :: Borrowed ( "box" ) ) )
79
92
}
80
93
fn node_label ( & ' this self , n : & RegionVid ) -> dot:: LabelText < ' this > {
81
- dot:: LabelText :: LabelStr ( render_region_vid ( * n, self . regioncx ) . into ( ) )
94
+ dot:: LabelText :: LabelStr ( render_region_vid ( self . tcx , * n, self . regioncx ) . into ( ) )
82
95
}
83
96
fn edge_label ( & ' this self , e : & OutlivesConstraint < ' tcx > ) -> dot:: LabelText < ' this > {
84
97
dot:: LabelText :: LabelStr ( render_outlives_constraint ( e) . into ( ) )
@@ -110,6 +123,7 @@ impl<'a, 'this, 'tcx> dot::GraphWalk<'this> for RawConstraints<'a, 'tcx> {
110
123
}
111
124
112
125
struct SccConstraints < ' a , ' tcx > {
126
+ tcx : TyCtxt < ' tcx > ,
113
127
regioncx : & ' a RegionInferenceContext < ' tcx > ,
114
128
nodes_per_scc : IndexVec < ConstraintSccIndex , Vec < RegionVid > > ,
115
129
}
@@ -128,8 +142,10 @@ impl<'a, 'this, 'tcx> dot::Labeller<'this> for SccConstraints<'a, 'tcx> {
128
142
Some ( dot:: LabelText :: LabelStr ( Cow :: Borrowed ( "box" ) ) )
129
143
}
130
144
fn node_label ( & ' this self , n : & ConstraintSccIndex ) -> dot:: LabelText < ' this > {
131
- let nodes_str =
132
- self . nodes_per_scc [ * n] . iter ( ) . map ( |n| render_region_vid ( * n, self . regioncx ) ) . join ( ", " ) ;
145
+ let nodes_str = self . nodes_per_scc [ * n]
146
+ . iter ( )
147
+ . map ( |n| render_region_vid ( self . tcx , * n, self . regioncx ) )
148
+ . join ( ", " ) ;
133
149
dot:: LabelText :: LabelStr ( format ! ( "SCC({n}) = {{{nodes_str}}}" , n = n. as_usize( ) ) . into ( ) )
134
150
}
135
151
}
0 commit comments