about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-06-29 12:26:06 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-08-23 00:57:29 +0200
commitbd5f3d76789028e0cdb432ff20f744b6fb24efc2 (patch)
tree2030702a4939c32f45a93e57a4d4cffde725203d
parentb968ef8d198046bce1c77381a8069d2f837a2455 (diff)
downloadrust-bd5f3d76789028e0cdb432ff20f744b6fb24efc2.tar.gz
rust-bd5f3d76789028e0cdb432ff20f744b6fb24efc2.zip
Improve code
-rw-r--r--src/librustdoc/html/highlight.rs6
1 files 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<F: Write> 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,