From 60d55671602fcff089a7b9199608a1b397877836 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 20 Dec 2020 15:57:43 -0500 Subject: [PATCH] Fix incorrect logic when merging matches --- src/librustdoc/html/markdown.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index e4a0d80674f..0e87dd72ef1 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -474,12 +474,13 @@ impl<'a, 'b, 'ids, I: Iterator, Range)>> Iterator if let Some((Event::Start(Tag::Heading(level)), _)) = event { let mut id = String::new(); for event in &mut self.inner { - match event.0 { + match &event.0 { Event::End(Tag::Heading(..)) => break, + Event::Start(Tag::Link(_, _, _)) | Event::End(Tag::Link(..)) => {} Event::Text(text) | Event::Code(text) => { id.extend(text.chars().filter_map(slugify)); + self.buf.push_back(event); } - Event::Start(Tag::Link(_, _, _)) | Event::End(Tag::Link(..)) => {} _ => self.buf.push_back(event), } }