diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-01-15 16:20:37 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-02-01 19:18:45 +1100 |
| commit | 3434466a7f3d82103beb32e1b53ec26231cbe6c7 (patch) | |
| tree | 8647c5d2523b676cc4220ac70ac97bd0c3b04069 /compiler/rustc_errors/src | |
| parent | 11f32b73e0dc9287e305b5b9980d24aecdc8c17f (diff) | |
| download | rust-3434466a7f3d82103beb32e1b53ec26231cbe6c7.tar.gz rust-3434466a7f3d82103beb32e1b53ec26231cbe6c7.zip | |
Tweak `emit_stashed_diagnostics`.
`take` + `into_iter` + pattern matching is nicer than `drain` + `map` + `collect`.
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 960b68196ff..901fe3fb799 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1224,9 +1224,8 @@ impl DiagCtxtInner { /// Emit all stashed diagnostics. fn emit_stashed_diagnostics(&mut self) -> Option<ErrorGuaranteed> { let has_errors = self.has_errors(); - let diags = self.stashed_diagnostics.drain(..).map(|x| x.1).collect::<Vec<_>>(); let mut reported = None; - for diag in diags { + for (_, diag) in std::mem::take(&mut self.stashed_diagnostics).into_iter() { // Decrement the count tracking the stash; emitting will increment it. if diag.is_error() { if diag.is_lint.is_some() { |
