From b5898a11378a565128406e177769efd785bbaacc Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 24 Dec 2021 12:21:04 +0100 Subject: [PATCH 1/2] Update pulldown-cmark version to 0.9 --- Cargo.lock | 15 +++++++++++++-- src/librustdoc/Cargo.toml | 2 +- src/librustdoc/html/markdown.rs | 17 +++++++++-------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 961a3ba9f19..cfba7d3fd40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2154,7 +2154,7 @@ dependencies = [ "log", "memchr", "opener", - "pulldown-cmark", + "pulldown-cmark 0.8.0", "regex", "serde", "serde_derive", @@ -2813,6 +2813,17 @@ dependencies = [ "unicase", ] +[[package]] +name = "pulldown-cmark" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acd16514d1af5f7a71f909a44ef253cdb712a376d7ebc8ae4a471a9be9743548" +dependencies = [ + "bitflags", + "memchr", + "unicase", +] + [[package]] name = "punycode" version = "0.4.1" @@ -4615,7 +4626,7 @@ dependencies = [ "expect-test", "itertools 0.9.0", "minifier", - "pulldown-cmark", + "pulldown-cmark 0.9.0", "rayon", "regex", "rustdoc-json-types", diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index 268905bcb53..578cf70d491 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -8,7 +8,7 @@ path = "lib.rs" [dependencies] arrayvec = { version = "0.7", default-features = false } -pulldown-cmark = { version = "0.8", default-features = false } +pulldown-cmark = { version = "0.9", default-features = false } minifier = "0.0.41" rayon = "1.3.1" serde = { version = "1.0", features = ["derive"] } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 545b409175e..3fd9c0a1944 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -538,7 +538,7 @@ fn next(&mut self) -> Option { } let event = self.inner.next(); - if let Some((Event::Start(Tag::Heading(level)), _)) = event { + if let Some((Event::Start(Tag::Heading(level, _, _)), _)) = event { let mut id = String::new(); for event in &mut self.inner { match &event.0 { @@ -560,7 +560,8 @@ fn next(&mut self) -> Option { self.buf.push_front((Event::Html(format!("{} ", sec).into()), 0..0)); } - let level = std::cmp::min(level + (self.heading_offset as u32), MAX_HEADER_LEVEL); + let level = + std::cmp::min(level as u32 + (self.heading_offset as u32), MAX_HEADER_LEVEL); self.buf.push_back((Event::Html(format!("", level).into()), 0..0)); let start_tags = format!( @@ -773,7 +774,7 @@ fn next(&mut self) -> Option { tests.add_test(text, block_info, line); prev_offset = offset.start; } - Event::Start(Tag::Heading(level)) => { + Event::Start(Tag::Heading(level, _, _)) => { register_header = Some(level as u32); } Event::Text(ref s) if register_header.is_some() => { @@ -1053,7 +1054,7 @@ pub fn into_string(self) -> String { let mut replacer = |broken_link: BrokenLink<'_>| { links .iter() - .find(|link| &*link.original_text == broken_link.reference) + .find(|link| link.original_text.as_str() == &*broken_link.reference) .map(|link| (link.href.as_str().into(), link.new_text.as_str().into())) }; @@ -1134,7 +1135,7 @@ impl MarkdownSummaryLine<'_> { let mut replacer = |broken_link: BrokenLink<'_>| { links .iter() - .find(|link| &*link.original_text == broken_link.reference) + .find(|link| link.original_text.as_str() == &*broken_link.reference) .map(|link| (link.href.as_str().into(), link.new_text.as_str().into())) }; @@ -1168,7 +1169,7 @@ fn markdown_summary_with_limit( let mut replacer = |broken_link: BrokenLink<'_>| { link_names .iter() - .find(|link| &*link.original_text == broken_link.reference) + .find(|link| link.original_text.as_str() == &*broken_link.reference) .map(|link| (link.href.as_str().into(), link.new_text.as_str().into())) }; @@ -1311,10 +1312,10 @@ fn markdown_summary_with_limit( }; let mut push = |link: BrokenLink<'_>| { - let span = span_for_link(&CowStr::Borrowed(link.reference), link.span); + let span = span_for_link(&link.reference, link.span); links.borrow_mut().push(MarkdownLink { kind: LinkType::ShortcutUnknown, - link: link.reference.to_owned(), + link: link.reference.to_string(), range: span, }); None From 4e2024c55d059453d42fa20fec99db0ef85ad9c7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 28 Dec 2021 16:19:23 +0100 Subject: [PATCH 2/2] Update pulldown-cmark version in clippy --- Cargo.lock | 2 +- src/tools/clippy/clippy_lints/Cargo.toml | 2 +- src/tools/clippy/clippy_lints/src/doc.rs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cfba7d3fd40..32b46f6c119 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -619,7 +619,7 @@ dependencies = [ "clippy_utils", "if_chain", "itertools 0.10.1", - "pulldown-cmark", + "pulldown-cmark 0.9.0", "quine-mc_cluskey", "regex-syntax", "rustc-semver", diff --git a/src/tools/clippy/clippy_lints/Cargo.toml b/src/tools/clippy/clippy_lints/Cargo.toml index 0661c280386..7d2a3e4f639 100644 --- a/src/tools/clippy/clippy_lints/Cargo.toml +++ b/src/tools/clippy/clippy_lints/Cargo.toml @@ -13,7 +13,7 @@ cargo_metadata = "0.14" clippy_utils = { path = "../clippy_utils" } if_chain = "1.0" itertools = "0.10" -pulldown-cmark = { version = "0.8", default-features = false } +pulldown-cmark = { version = "0.9", default-features = false } quine-mc_cluskey = "0.2" regex-syntax = "0.6" serde = { version = "1.0", features = ["derive"] } diff --git a/src/tools/clippy/clippy_lints/src/doc.rs b/src/tools/clippy/clippy_lints/src/doc.rs index 3650e4f91a0..7c271773357 100644 --- a/src/tools/clippy/clippy_lints/src/doc.rs +++ b/src/tools/clippy/clippy_lints/src/doc.rs @@ -542,16 +542,16 @@ fn check_doc<'a, Events: Iterator, Range in_link = Some(url), End(Link(..)) => in_link = None, - Start(Heading(_) | Paragraph | Item) => { - if let Start(Heading(_)) = event { + Start(Heading(_, _, _) | Paragraph | Item) => { + if let Start(Heading(_, _, _)) = event { in_heading = true; } ticks_unbalanced = false; let (_, span) = get_current_span(spans, range.start); paragraph_span = first_line_of_span(cx, span); }, - End(Heading(_) | Paragraph | Item) => { - if let End(Heading(_)) = event { + End(Heading(_, _, _) | Paragraph | Item) => { + if let End(Heading(_, _, _)) = event { in_heading = false; } if ticks_unbalanced {