diff --git a/src/librustc_mir/dataflow/graphviz.rs b/src/librustc_mir/dataflow/graphviz.rs index 97d549987712b..1d35bb85a21a1 100644 --- a/src/librustc_mir/dataflow/graphviz.rs +++ b/src/librustc_mir/dataflow/graphviz.rs @@ -265,15 +265,12 @@ impl<'a, 'tcx, MWF, P> dot::GraphWalk<'a> for Graph<'a, 'tcx, MWF, P> fn edges(&self) -> dot::Edges { 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::>() + .into_cow() } fn source(&self, edge: &Edge) -> Node { diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index 8f3595b17848c..cb551df910627 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -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); } } diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index bee7d443c8540..d6874e290d4f6 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -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(()) } } diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 2148363c79712..732aa7904d319 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -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)