Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few cleanups and minor improvements to mir/dataflow #53966

Merged
merged 1 commit into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/librustc_mir/dataflow/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_mir/dataflow/impls/borrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
9 changes: 4 additions & 5 deletions src/librustc_mir/dataflow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(())
Expand All @@ -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(())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/dataflow/move_paths/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down