From bd5f3d76789028e0cdb432ff20f744b6fb24efc2 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 29 Jun 2025 12:26:06 +0200 Subject: Improve code --- src/librustdoc/html/highlight.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 40530f67d6e..583c178fa11 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -233,12 +233,10 @@ impl TokenHandler<'_, '_, F> { } else { None }; - let mut last_pending = None; // To prevent opening a macro expansion span being closed right away because // the currently open item is replaced by a new class. - if let Some((_, Some(Class::Expansion))) = self.pending_elems.last() { - last_pending = self.pending_elems.pop(); - } + let last_pending = + self.pending_elems.pop_if(|(_, class)| *class == Some(Class::Expansion)); for (text, class) in self.pending_elems.iter() { string( self.out, -- cgit 1.4.1-3-g733a5