Skip to content

Commit 3434466

Browse files
committed
Tweak emit_stashed_diagnostics.
`take` + `into_iter` + pattern matching is nicer than `drain` + `map` + `collect`.
1 parent 11f32b7 commit 3434466

File tree

1 file changed

+1
-2
lines changed
  • compiler/rustc_errors/src

1 file changed

+1
-2
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,9 +1224,8 @@ impl DiagCtxtInner {
12241224
/// Emit all stashed diagnostics.
12251225
fn emit_stashed_diagnostics(&mut self) -> Option<ErrorGuaranteed> {
12261226
let has_errors = self.has_errors();
1227-
let diags = self.stashed_diagnostics.drain(..).map(|x| x.1).collect::<Vec<_>>();
12281227
let mut reported = None;
1229-
for diag in diags {
1228+
for (_, diag) in std::mem::take(&mut self.stashed_diagnostics).into_iter() {
12301229
// Decrement the count tracking the stash; emitting will increment it.
12311230
if diag.is_error() {
12321231
if diag.is_lint.is_some() {

0 commit comments

Comments
 (0)