Skip to content

Commit 57a0df6

Browse files
committed
Auto merge of #29489 - Ms2ger:fmt-ri, r=Manishearth
CC @nrc
2 parents fa7a3c2 + eb5c0a6 commit 57a0df6

File tree

2 files changed

+326
-357
lines changed

2 files changed

+326
-357
lines changed

src/librustc/middle/infer/region_inference/graphviz.rs

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,18 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
6161
return;
6262
}
6363

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());
6667

6768
if requested_node.is_some() && requested_node != Some(subject_node) {
6869
return;
6970
}
7071

7172
let requested_output = env::var("RUST_REGION_GRAPH");
7273
debug!("requested_output: {:?} requested_node: {:?}",
73-
requested_output, requested_node);
74+
requested_output,
75+
requested_node);
7476

7577
let output_path = {
7678
let output_template = match requested_output {
@@ -139,7 +141,8 @@ enum Edge {
139141
impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> {
140142
fn new(tcx: &'a ty::ctxt<'tcx>,
141143
name: String,
142-
map: &'a ConstraintMap<'tcx>) -> ConstraintGraph<'a, 'tcx> {
144+
map: &'a ConstraintMap<'tcx>)
145+
-> ConstraintGraph<'a, 'tcx> {
143146
let mut i = 0;
144147
let mut node_ids = FnvHashMap();
145148
{
@@ -150,7 +153,7 @@ impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> {
150153
}
151154
};
152155

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)) {
154157
add_node(n1);
155158
add_node(n2);
156159
}
@@ -161,10 +164,12 @@ impl<'a, 'tcx> ConstraintGraph<'a, 'tcx> {
161164
});
162165
}
163166

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+
}
168173
}
169174
}
170175

@@ -187,38 +192,34 @@ impl<'a, 'tcx> dot::Labeller<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> {
187192
}
188193
fn node_label(&self, n: &Node) -> dot::LabelText {
189194
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)),
194197
}
195198
}
196199
fn edge_label(&self, e: &Edge) -> dot::LabelText {
197200
match *e {
198201
Edge::Constraint(ref c) =>
199202
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)")),
202204
}
203205
}
204206
}
205207

206208
fn constraint_to_nodes(c: &Constraint) -> (Node, Node) {
207209
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)),
214214
}
215215
}
216216

217217
fn edge_to_nodes(e: &Edge) -> (Node, Node) {
218218
match *e {
219219
Edge::Constraint(ref c) => constraint_to_nodes(c),
220220
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)))
222223
}
223224
}
224225
}
@@ -234,10 +235,8 @@ impl<'a, 'tcx> dot::GraphWalk<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> {
234235
}
235236
fn edges(&self) -> dot::Edges<Edge> {
236237
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)));
241240
debug!("region graph has {} edges", v.len());
242241
Cow::Owned(v)
243242
}
@@ -255,10 +254,13 @@ impl<'a, 'tcx> dot::GraphWalk<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> {
255254

256255
pub type ConstraintMap<'tcx> = FnvHashMap<Constraint, SubregionOrigin<'tcx>>;
257256

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>,
259258
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);
262264
let g = ConstraintGraph::new(tcx, format!("region_constraints"), map);
263265
debug!("dump_region_constraints calling render");
264266
let mut v = Vec::new();

0 commit comments

Comments
 (0)