Skip to content

Commit bc8cef1

Browse files
committed
rustc_mir_itertools: Avoid needless collect with itertools
1 parent ecf7299 commit bc8cef1

File tree

5 files changed

+8
-22
lines changed

5 files changed

+8
-22
lines changed

compiler/rustc_mir_transform/src/coverage/debug.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
use super::graph::{BasicCoverageBlock, BasicCoverageBlockData, CoverageGraph};
112112
use super::spans::CoverageSpan;
113113

114+
use itertools::Itertools;
114115
use rustc_middle::mir::create_dump_file;
115116
use rustc_middle::mir::generic_graphviz::GraphvizWriter;
116117
use rustc_middle::mir::spanview::{self, SpanViewable};
@@ -739,7 +740,6 @@ pub(super) fn dump_coverage_graphviz<'tcx>(
739740
)
740741
}
741742
})
742-
.collect::<Vec<_>>()
743743
.join("\n ")
744744
));
745745
}
@@ -768,7 +768,6 @@ fn bcb_to_string_sections<'tcx>(
768768
.map(|expression| {
769769
format!("Intermediate {}", debug_counters.format_counter(expression))
770770
})
771-
.collect::<Vec<_>>()
772771
.join("\n"),
773772
);
774773
}
@@ -783,7 +782,6 @@ fn bcb_to_string_sections<'tcx>(
783782
covspan.format(tcx, mir_body)
784783
)
785784
})
786-
.collect::<Vec<_>>()
787785
.join("\n"),
788786
);
789787
}
@@ -793,7 +791,6 @@ fn bcb_to_string_sections<'tcx>(
793791
dependency_counters
794792
.iter()
795793
.map(|counter| debug_counters.format_counter(counter))
796-
.collect::<Vec<_>>()
797794
.join(" \n"),
798795
));
799796
}

compiler/rustc_mir_transform/src/coverage/graph.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::Error;
22

3+
use itertools::Itertools;
34
use rustc_data_structures::fx::FxHashMap;
45
use rustc_data_structures::graph::dominators::{self, Dominators};
56
use rustc_data_structures::graph::{self, GraphSuccessors, WithNumNodes, WithStartNode};
@@ -422,14 +423,7 @@ impl BasicCoverageBlockData {
422423
}
423424

424425
pub fn id(&self) -> String {
425-
format!(
426-
"@{}",
427-
self.basic_blocks
428-
.iter()
429-
.map(|bb| bb.index().to_string())
430-
.collect::<Vec<_>>()
431-
.join(ID_SEPARATOR)
432-
)
426+
format!("@{}", self.basic_blocks.iter().map(|bb| bb.index().to_string()).join(ID_SEPARATOR))
433427
}
434428
}
435429

compiler/rustc_mir_transform/src/coverage/spans.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::debug::term_type;
22
use super::graph::{BasicCoverageBlock, BasicCoverageBlockData, CoverageGraph, START_BCB};
33

4+
use itertools::Itertools;
45
use rustc_data_structures::graph::WithNumNodes;
56
use rustc_middle::mir::spanview::source_range_no_file;
67
use rustc_middle::mir::{
@@ -169,11 +170,7 @@ impl CoverageSpan {
169170
CoverageStatement::Statement(bb, _, index) => (bb, index),
170171
CoverageStatement::Terminator(bb, _) => (bb, usize::MAX),
171172
});
172-
sorted_coverage_statements
173-
.iter()
174-
.map(|covstmt| covstmt.format(tcx, mir_body))
175-
.collect::<Vec<_>>()
176-
.join("\n")
173+
sorted_coverage_statements.iter().map(|covstmt| covstmt.format(tcx, mir_body)).join("\n")
177174
}
178175

179176
/// If the span is part of a macro, returns the macro name symbol.

compiler/rustc_mir_transform/src/coverage/tests.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use super::spans;
3131

3232
use coverage_test_macros::let_bcb;
3333

34+
use itertools::Itertools;
3435
use rustc_data_structures::graph::WithNumNodes;
3536
use rustc_data_structures::graph::WithSuccessors;
3637
use rustc_index::vec::{Idx, IndexVec};
@@ -232,11 +233,9 @@ fn print_mir_graphviz(name: &str, mir_body: &Body<'_>) {
232233
mir_body
233234
.successors(bb)
234235
.map(|successor| { format!(" {:?} -> {:?};", bb, successor) })
235-
.collect::<Vec<_>>()
236236
.join("\n")
237237
)
238238
})
239-
.collect::<Vec<_>>()
240239
.join("\n")
241240
);
242241
}
@@ -262,11 +261,9 @@ fn print_coverage_graphviz(
262261
basic_coverage_blocks
263262
.successors(bcb)
264263
.map(|successor| { format!(" {:?} -> {:?};", bcb, successor) })
265-
.collect::<Vec<_>>()
266264
.join("\n")
267265
)
268266
})
269-
.collect::<Vec<_>>()
270267
.join("\n")
271268
);
272269
}

compiler/rustc_mir_transform/src/function_item_references.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use itertools::Itertools;
12
use rustc_errors::Applicability;
23
use rustc_hir::def_id::DefId;
34
use rustc_middle::mir::visit::Visitor;
@@ -197,7 +198,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
197198
let ident = self.tcx.item_name(fn_id).to_ident_string();
198199
let ty_params = fn_substs.types().map(|ty| format!("{}", ty));
199200
let const_params = fn_substs.consts().map(|c| format!("{}", c));
200-
let params = ty_params.chain(const_params).collect::<Vec<String>>().join(", ");
201+
let params = ty_params.chain(const_params).join(", ");
201202
let num_args = fn_sig.inputs().map_bound(|inputs| inputs.len()).skip_binder();
202203
let variadic = if fn_sig.c_variadic() { ", ..." } else { "" };
203204
let ret = if fn_sig.output().skip_binder().is_unit() { "" } else { " -> _" };

0 commit comments

Comments
 (0)