A few cleanups and minor improvements to mir/dataflow
This commit is contained in:
parent
0be2c30369
commit
b7c0d32c5f
@ -265,15 +265,12 @@ impl<'a, 'tcx, MWF, P> dot::GraphWalk<'a> for Graph<'a, 'tcx, MWF, P>
|
||||
|
||||
fn edges(&self) -> dot::Edges<Edge> {
|
||||
let mir = self.mbcx.mir();
|
||||
// base initial capacity on assumption every block has at
|
||||
// least one outgoing edge (Which should be true for all
|
||||
// blocks but one, the exit-block).
|
||||
let mut edges = Vec::with_capacity(mir.basic_blocks().len());
|
||||
for bb in mir.basic_blocks().indices() {
|
||||
let outgoing = outgoing(mir, bb);
|
||||
edges.extend(outgoing.into_iter());
|
||||
}
|
||||
edges.into_cow()
|
||||
|
||||
mir.basic_blocks()
|
||||
.indices()
|
||||
.flat_map(|bb| outgoing(mir, bb))
|
||||
.collect::<Vec<_>>()
|
||||
.into_cow()
|
||||
}
|
||||
|
||||
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
|
||||
// potential kill introduced here.
|
||||
if let Some(indices) = self.borrows_out_of_scope_at_location.get(&location) {
|
||||
for index in indices {
|
||||
sets.kill(&index);
|
||||
}
|
||||
sets.kill_all(indices);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
format!("{}_{}", context, prepost);
|
||||
fn dataflow_path(context: &str, path: &str) -> PathBuf {
|
||||
let mut path = PathBuf::from(path);
|
||||
let new_file_name = {
|
||||
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
|
||||
{
|
||||
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)
|
||||
} else {
|
||||
Ok(())
|
||||
@ -278,9 +277,9 @@ impl<'a, 'tcx: 'a, BD> DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation
|
||||
where P: Fn(&BD, BD::Idx) -> DebugFormatted
|
||||
{
|
||||
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)
|
||||
} else{
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ impl<'a, 'gcx, 'tcx> MoveDataBuilder<'a, 'gcx, 'tcx> {
|
||||
"done dumping moves"
|
||||
});
|
||||
|
||||
if self.errors.len() > 0 {
|
||||
if !self.errors.is_empty() {
|
||||
Err((self.data, self.errors))
|
||||
} else {
|
||||
Ok(self.data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user