A few cleanups and minor improvements to mir/dataflow
This commit is contained in:
parent
0be2c30369
commit
b7c0d32c5f
4 changed files with 12 additions and 18 deletions
|
@ -265,15 +265,12 @@ impl<'a, 'tcx, MWF, P> dot::GraphWalk<'a> for Graph<'a, 'tcx, MWF, P>
|
||||||
|
|
||||||
fn edges(&self) -> dot::Edges<Edge> {
|
fn edges(&self) -> dot::Edges<Edge> {
|
||||||
let mir = self.mbcx.mir();
|
let mir = self.mbcx.mir();
|
||||||
// base initial capacity on assumption every block has at
|
|
||||||
// least one outgoing edge (Which should be true for all
|
mir.basic_blocks()
|
||||||
// blocks but one, the exit-block).
|
.indices()
|
||||||
let mut edges = Vec::with_capacity(mir.basic_blocks().len());
|
.flat_map(|bb| outgoing(mir, bb))
|
||||||
for bb in mir.basic_blocks().indices() {
|
.collect::<Vec<_>>()
|
||||||
let outgoing = outgoing(mir, bb);
|
.into_cow()
|
||||||
edges.extend(outgoing.into_iter());
|
|
||||||
}
|
|
||||||
edges.into_cow()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn source(&self, edge: &Edge) -> Node {
|
fn source(&self, edge: &Edge) -> Node {
|
||||||
|
|
|
@ -168,9 +168,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
|
||||||
// region, then setting that gen-bit will override any
|
// region, then setting that gen-bit will override any
|
||||||
// potential kill introduced here.
|
// potential kill introduced here.
|
||||||
if let Some(indices) = self.borrows_out_of_scope_at_location.get(&location) {
|
if let Some(indices) = self.borrows_out_of_scope_at_location.get(&location) {
|
||||||
for index in indices {
|
sets.kill_all(indices);
|
||||||
sets.kill(&index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,8 +250,7 @@ impl<'b, 'a: 'b, 'tcx: 'a, BD> PropagationContext<'b, 'a, 'tcx, BD> where BD: Bi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dataflow_path(context: &str, prepost: &str, path: &str) -> PathBuf {
|
fn dataflow_path(context: &str, path: &str) -> PathBuf {
|
||||||
format!("{}_{}", context, prepost);
|
|
||||||
let mut path = PathBuf::from(path);
|
let mut path = PathBuf::from(path);
|
||||||
let new_file_name = {
|
let new_file_name = {
|
||||||
let orig_file_name = path.file_name().unwrap().to_str().unwrap();
|
let orig_file_name = path.file_name().unwrap().to_str().unwrap();
|
||||||
|
@ -267,7 +266,7 @@ impl<'a, 'tcx: 'a, BD> DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation
|
||||||
where P: Fn(&BD, BD::Idx) -> DebugFormatted
|
where P: Fn(&BD, BD::Idx) -> DebugFormatted
|
||||||
{
|
{
|
||||||
if let Some(ref path_str) = self.print_preflow_to {
|
if let Some(ref path_str) = self.print_preflow_to {
|
||||||
let path = dataflow_path(BD::name(), "preflow", path_str);
|
let path = dataflow_path(BD::name(), path_str);
|
||||||
graphviz::print_borrowck_graph_to(self, &path, p)
|
graphviz::print_borrowck_graph_to(self, &path, p)
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -278,9 +277,9 @@ impl<'a, 'tcx: 'a, BD> DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation
|
||||||
where P: Fn(&BD, BD::Idx) -> DebugFormatted
|
where P: Fn(&BD, BD::Idx) -> DebugFormatted
|
||||||
{
|
{
|
||||||
if let Some(ref path_str) = self.print_postflow_to {
|
if let Some(ref path_str) = self.print_postflow_to {
|
||||||
let path = dataflow_path(BD::name(), "postflow", path_str);
|
let path = dataflow_path(BD::name(), path_str);
|
||||||
graphviz::print_borrowck_graph_to(self, &path, p)
|
graphviz::print_borrowck_graph_to(self, &path, p)
|
||||||
} else{
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> {
|
||||||
"done dumping moves"
|
"done dumping moves"
|
||||||
});
|
});
|
||||||
|
|
||||||
if self.errors.len() > 0 {
|
if !self.errors.is_empty() {
|
||||||
Err((self.data, self.errors))
|
Err((self.data, self.errors))
|
||||||
} else {
|
} else {
|
||||||
Ok(self.data)
|
Ok(self.data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue