@@ -61,16 +61,18 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
61
61
return ;
62
62
}
63
63
64
- let requested_node : Option < ast:: NodeId > =
65
- env:: var ( "RUST_REGION_GRAPH_NODE" ) . ok ( ) . and_then ( |s| s. parse ( ) . ok ( ) ) ;
64
+ let requested_node: Option < ast:: NodeId > = env:: var ( "RUST_REGION_GRAPH_NODE" )
65
+ . ok ( )
66
+ . and_then ( |s| s. parse ( ) . ok ( ) ) ;
66
67
67
68
if requested_node. is_some ( ) && requested_node != Some ( subject_node) {
68
69
return ;
69
70
}
70
71
71
72
let requested_output = env:: var ( "RUST_REGION_GRAPH" ) ;
72
73
debug ! ( "requested_output: {:?} requested_node: {:?}" ,
73
- requested_output, requested_node) ;
74
+ requested_output,
75
+ requested_node) ;
74
76
75
77
let output_path = {
76
78
let output_template = match requested_output {
@@ -139,7 +141,8 @@ enum Edge {
139
141
impl < ' a , ' tcx > ConstraintGraph < ' a , ' tcx > {
140
142
fn new ( tcx : & ' a ty:: ctxt < ' tcx > ,
141
143
name : String ,
142
- map : & ' a ConstraintMap < ' tcx > ) -> ConstraintGraph < ' a , ' tcx > {
144
+ map : & ' a ConstraintMap < ' tcx > )
145
+ -> ConstraintGraph < ' a , ' tcx > {
143
146
let mut i = 0 ;
144
147
let mut node_ids = FnvHashMap ( ) ;
145
148
{
@@ -150,7 +153,7 @@ impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> {
150
153
}
151
154
} ;
152
155
153
- for ( n1, n2) in map. keys ( ) . map ( |c|constraint_to_nodes ( c) ) {
156
+ for ( n1, n2) in map. keys ( ) . map ( |c| constraint_to_nodes ( c) ) {
154
157
add_node ( n1) ;
155
158
add_node ( n2) ;
156
159
}
@@ -161,10 +164,12 @@ impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> {
161
164
} ) ;
162
165
}
163
166
164
- ConstraintGraph { tcx : tcx,
165
- graph_name : name,
166
- map : map,
167
- node_ids : node_ids }
167
+ ConstraintGraph {
168
+ tcx : tcx,
169
+ graph_name : name,
170
+ map : map,
171
+ node_ids : node_ids,
172
+ }
168
173
}
169
174
}
170
175
@@ -187,38 +192,34 @@ impl<'a, 'tcx> dot::Labeller<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> {
187
192
}
188
193
fn node_label ( & self , n : & Node ) -> dot:: LabelText {
189
194
match * n {
190
- Node :: RegionVid ( n_vid) =>
191
- dot:: LabelText :: label ( format ! ( "{:?}" , n_vid) ) ,
192
- Node :: Region ( n_rgn) =>
193
- dot:: LabelText :: label ( format ! ( "{:?}" , n_rgn) ) ,
195
+ Node :: RegionVid ( n_vid) => dot:: LabelText :: label ( format ! ( "{:?}" , n_vid) ) ,
196
+ Node :: Region ( n_rgn) => dot:: LabelText :: label ( format ! ( "{:?}" , n_rgn) ) ,
194
197
}
195
198
}
196
199
fn edge_label ( & self , e : & Edge ) -> dot:: LabelText {
197
200
match * e {
198
201
Edge :: Constraint ( ref c) =>
199
202
dot:: LabelText :: label ( format ! ( "{:?}" , self . map. get( c) . unwrap( ) ) ) ,
200
- Edge :: EnclScope ( ..) =>
201
- dot:: LabelText :: label ( format ! ( "(enclosed)" ) ) ,
203
+ Edge :: EnclScope ( ..) => dot:: LabelText :: label ( format ! ( "(enclosed)" ) ) ,
202
204
}
203
205
}
204
206
}
205
207
206
208
fn constraint_to_nodes ( c : & Constraint ) -> ( Node , Node ) {
207
209
match * c {
208
- Constraint :: ConstrainVarSubVar ( rv_1, rv_2) => ( Node :: RegionVid ( rv_1) ,
209
- Node :: RegionVid ( rv_2) ) ,
210
- Constraint :: ConstrainRegSubVar ( r_1, rv_2) => ( Node :: Region ( r_1) ,
211
- Node :: RegionVid ( rv_2) ) ,
212
- Constraint :: ConstrainVarSubReg ( rv_1, r_2) => ( Node :: RegionVid ( rv_1) ,
213
- Node :: Region ( r_2) ) ,
210
+ Constraint :: ConstrainVarSubVar ( rv_1, rv_2) =>
211
+ ( Node :: RegionVid ( rv_1) , Node :: RegionVid ( rv_2) ) ,
212
+ Constraint :: ConstrainRegSubVar ( r_1, rv_2) => ( Node :: Region ( r_1) , Node :: RegionVid ( rv_2) ) ,
213
+ Constraint :: ConstrainVarSubReg ( rv_1, r_2) => ( Node :: RegionVid ( rv_1) , Node :: Region ( r_2) ) ,
214
214
}
215
215
}
216
216
217
217
fn edge_to_nodes ( e : & Edge ) -> ( Node , Node ) {
218
218
match * e {
219
219
Edge :: Constraint ( ref c) => constraint_to_nodes ( c) ,
220
220
Edge :: EnclScope ( sub, sup) => {
221
- ( Node :: Region ( ty:: ReScope ( sub) ) , Node :: Region ( ty:: ReScope ( sup) ) )
221
+ ( Node :: Region ( ty:: ReScope ( sub) ) ,
222
+ Node :: Region ( ty:: ReScope ( sup) ) )
222
223
}
223
224
}
224
225
}
@@ -234,10 +235,8 @@ impl<'a, 'tcx> dot::GraphWalk<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> {
234
235
}
235
236
fn edges ( & self ) -> dot:: Edges < Edge > {
236
237
debug ! ( "constraint graph has {} edges" , self . map. len( ) ) ;
237
- let mut v : Vec < _ > = self . map . keys ( ) . map ( |e| Edge :: Constraint ( * e) ) . collect ( ) ;
238
- self . tcx . region_maps . each_encl_scope ( |sub, sup| {
239
- v. push ( Edge :: EnclScope ( * sub, * sup) )
240
- } ) ;
238
+ let mut v: Vec < _ > = self . map . keys ( ) . map ( |e| Edge :: Constraint ( * e) ) . collect ( ) ;
239
+ self . tcx . region_maps . each_encl_scope ( |sub, sup| v. push ( Edge :: EnclScope ( * sub, * sup) ) ) ;
241
240
debug ! ( "region graph has {} edges" , v. len( ) ) ;
242
241
Cow :: Owned ( v)
243
242
}
@@ -255,10 +254,13 @@ impl<'a, 'tcx> dot::GraphWalk<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> {
255
254
256
255
pub type ConstraintMap < ' tcx > = FnvHashMap < Constraint , SubregionOrigin < ' tcx > > ;
257
256
258
- fn dump_region_constraints_to < ' a , ' tcx : ' a > ( tcx : & ' a ty:: ctxt < ' tcx > ,
257
+ fn dump_region_constraints_to < ' a , ' tcx : ' a > ( tcx : & ' a ty:: ctxt < ' tcx > ,
259
258
map : & ConstraintMap < ' tcx > ,
260
- path : & str ) -> io:: Result < ( ) > {
261
- debug ! ( "dump_region_constraints map (len: {}) path: {}" , map. len( ) , path) ;
259
+ path : & str )
260
+ -> io:: Result < ( ) > {
261
+ debug ! ( "dump_region_constraints map (len: {}) path: {}" ,
262
+ map. len( ) ,
263
+ path) ;
262
264
let g = ConstraintGraph :: new ( tcx, format ! ( "region_constraints" ) , map) ;
263
265
debug ! ( "dump_region_constraints calling render" ) ;
264
266
let mut v = Vec :: new ( ) ;
0 commit comments