Use iter::zip in compiler/
This commit is contained in:
@@ -121,6 +121,7 @@ use rustc_middle::mir::coverage::*;
|
||||
use rustc_middle::mir::{self, BasicBlock, TerminatorKind};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
|
||||
use std::iter;
|
||||
use std::lazy::SyncOnceCell;
|
||||
|
||||
pub const NESTED_INDENT: &str = " ";
|
||||
@@ -703,9 +704,7 @@ pub(super) fn dump_coverage_graphviz(
|
||||
let edge_counters = from_terminator
|
||||
.successors()
|
||||
.map(|&successor_bb| graphviz_data.get_edge_counter(from_bcb, successor_bb));
|
||||
edge_labels
|
||||
.iter()
|
||||
.zip(edge_counters)
|
||||
iter::zip(&edge_labels, edge_counters)
|
||||
.map(|(label, some_counter)| {
|
||||
if let Some(counter) = some_counter {
|
||||
format!("{}\n{}", label, debug_counters.format_counter(counter))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! This pass finds basic blocks that are completely equal,
|
||||
//! and replaces all uses with just one of them.
|
||||
|
||||
use std::{collections::hash_map::Entry, hash::Hash, hash::Hasher};
|
||||
use std::{collections::hash_map::Entry, hash::Hash, hash::Hasher, iter};
|
||||
|
||||
use crate::transform::MirPass;
|
||||
|
||||
@@ -115,11 +115,7 @@ impl<'tcx, 'a> PartialEq for BasicBlockHashable<'tcx, 'a> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.basic_block_data.statements.len() == other.basic_block_data.statements.len()
|
||||
&& &self.basic_block_data.terminator().kind == &other.basic_block_data.terminator().kind
|
||||
&& self
|
||||
.basic_block_data
|
||||
.statements
|
||||
.iter()
|
||||
.zip(&other.basic_block_data.statements)
|
||||
&& iter::zip(&self.basic_block_data.statements, &other.basic_block_data.statements)
|
||||
.all(|(x, y)| statement_eq(&x.kind, &y.kind))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::transform::MirPass;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use std::iter;
|
||||
|
||||
use super::simplify::simplify_cfg;
|
||||
|
||||
@@ -83,7 +84,7 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
|
||||
if first_stmts.len() != scnd_stmts.len() {
|
||||
continue;
|
||||
}
|
||||
for (f, s) in first_stmts.iter().zip(scnd_stmts.iter()) {
|
||||
for (f, s) in iter::zip(first_stmts, scnd_stmts) {
|
||||
match (&f.kind, &s.kind) {
|
||||
// If two statements are exactly the same, we can optimize.
|
||||
(f_s, s_s) if f_s == s_s => {}
|
||||
@@ -113,7 +114,7 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
|
||||
// and bb_idx has a different terminator from both of them.
|
||||
let (from, first, second) = bbs.pick3_mut(bb_idx, first, second);
|
||||
|
||||
let new_stmts = first.statements.iter().zip(second.statements.iter()).map(|(f, s)| {
|
||||
let new_stmts = iter::zip(&first.statements, &second.statements).map(|(f, s)| {
|
||||
match (&f.kind, &s.kind) {
|
||||
(f_s, s_s) if f_s == s_s => (*f).clone(),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user