Skip to content

Commit 66b4f00

Browse files
committed
Auto merge of #127127 - notriddle:notriddle/pulldown-cmark-0.11, r=GuillaumeGomez
rustdoc: update to pulldown-cmark 0.11 r? rustdoc This pull request updates rustdoc to the latest version of pulldown-cmark. Along with adding new markdown extensions (which this PR doesn't enable), the new pulldown-cmark version also fixes a large number of bugs. Because all text files successfully parse as markdown, these bugfixes change the output, which can break people's existing docs. A crater run, #121659, has already been run for this change. The first commit upgrades and fixes rustdoc. The second commit adds a lint for the footnote and block quote parser changes, which break the largest numbers of docs in the Crater run. The strikethrough change was mitigated in pulldown-cmark itself. Unblocks rust-lang/rust-clippy#12876
2 parents b454012 + c8592da commit 66b4f00

File tree

16 files changed

+385
-94
lines changed

16 files changed

+385
-94
lines changed

Diff for: Cargo.lock

+21-2
Original file line numberDiff line numberDiff line change
@@ -3141,7 +3141,19 @@ dependencies = [
31413141
"bitflags 2.5.0",
31423142
"getopts",
31433143
"memchr",
3144-
"pulldown-cmark-escape",
3144+
"pulldown-cmark-escape 0.10.1",
3145+
"unicase",
3146+
]
3147+
3148+
[[package]]
3149+
name = "pulldown-cmark"
3150+
version = "0.11.0"
3151+
source = "registry+https://github.com./rust-lang/crates.io-index"
3152+
checksum = "8746739f11d39ce5ad5c2520a9b75285310dbfe78c541ccf832d38615765aec0"
3153+
dependencies = [
3154+
"bitflags 2.5.0",
3155+
"memchr",
3156+
"pulldown-cmark-escape 0.11.0",
31453157
"unicase",
31463158
]
31473159

@@ -3151,6 +3163,12 @@ version = "0.10.1"
31513163
source = "registry+https://github.com./rust-lang/crates.io-index"
31523164
checksum = "bd348ff538bc9caeda7ee8cad2d1d48236a1f443c1fa3913c6a02fe0043b1dd3"
31533165

3166+
[[package]]
3167+
name = "pulldown-cmark-escape"
3168+
version = "0.11.0"
3169+
source = "registry+https://github.com./rust-lang/crates.io-index"
3170+
checksum = "007d8adb5ddab6f8e3f491ac63566a7d5002cc7ed73901f72057943fa71ae1ae"
3171+
31543172
[[package]]
31553173
name = "pulldown-cmark-to-cmark"
31563174
version = "13.0.0"
@@ -4604,7 +4622,7 @@ name = "rustc_resolve"
46044622
version = "0.0.0"
46054623
dependencies = [
46064624
"bitflags 2.5.0",
4607-
"pulldown-cmark 0.9.6",
4625+
"pulldown-cmark 0.11.0",
46084626
"rustc_arena",
46094627
"rustc_ast",
46104628
"rustc_ast_pretty",
@@ -4883,6 +4901,7 @@ dependencies = [
48834901
"indexmap",
48844902
"itertools",
48854903
"minifier",
4904+
"pulldown-cmark 0.9.6",
48864905
"regex",
48874906
"rustdoc-json-types",
48884907
"serde",

Diff for: compiler/rustc_data_structures/src/sync.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
//! | | | |
3636
//! | `ParallelIterator` | `Iterator` | `rayon::iter::ParallelIterator` |
3737
//!
38-
//! [^1] `MTLock` is similar to `Lock`, but the serial version avoids the cost
38+
//! [^1]: `MTLock` is similar to `Lock`, but the serial version avoids the cost
3939
//! of a `RefCell`. This is appropriate when interior mutability is not
4040
//! required.
4141
//!
42-
//! [^2] `MTRef`, `MTLockRef` are type aliases.
42+
//! [^2]: `MTRef`, `MTLockRef` are type aliases.
4343
4444
pub use crate::marker::*;
4545
use std::collections::HashMap;

Diff for: compiler/rustc_resolve/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
[dependencies]
77
# tidy-alphabetical-start
88
bitflags = "2.4.1"
9-
pulldown-cmark = { version = "0.9.6", default-features = false }
9+
pulldown-cmark = { version = "0.11", features = ["html"], default-features = false }
1010
rustc_arena = { path = "../rustc_arena" }
1111
rustc_ast = { path = "../rustc_ast" }
1212
rustc_ast_pretty = { path = "../rustc_ast_pretty" }

Diff for: compiler/rustc_resolve/src/rustdoc.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use pulldown_cmark::{BrokenLink, CowStr, Event, LinkType, Options, Parser, Tag};
1+
use pulldown_cmark::{
2+
BrokenLink, BrokenLinkCallback, CowStr, Event, LinkType, Options, Parser, Tag,
3+
};
24
use rustc_ast as ast;
35
use rustc_ast::util::comments::beautify_doc_string;
46
use rustc_data_structures::fx::FxHashMap;
@@ -427,7 +429,9 @@ fn parse_links<'md>(doc: &'md str) -> Vec<Box<str>> {
427429

428430
while let Some(event) = event_iter.next() {
429431
match event {
430-
Event::Start(Tag::Link(link_type, dest, _)) if may_be_doc_link(link_type) => {
432+
Event::Start(Tag::Link { link_type, dest_url, title: _, id: _ })
433+
if may_be_doc_link(link_type) =>
434+
{
431435
if matches!(
432436
link_type,
433437
LinkType::Inline
@@ -441,7 +445,7 @@ fn parse_links<'md>(doc: &'md str) -> Vec<Box<str>> {
441445
}
442446
}
443447

444-
links.push(preprocess_link(&dest));
448+
links.push(preprocess_link(&dest_url));
445449
}
446450
_ => {}
447451
}
@@ -451,8 +455,8 @@ fn parse_links<'md>(doc: &'md str) -> Vec<Box<str>> {
451455
}
452456

453457
/// Collects additional data of link.
454-
fn collect_link_data<'input, 'callback>(
455-
event_iter: &mut Parser<'input, 'callback>,
458+
fn collect_link_data<'input, F: BrokenLinkCallback<'input>>(
459+
event_iter: &mut Parser<'input, F>,
456460
) -> Option<Box<str>> {
457461
let mut display_text: Option<String> = None;
458462
let mut append_text = |text: CowStr<'_>| {

Diff for: src/librustdoc/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ base64 = "0.21.7"
1313
itertools = "0.12"
1414
indexmap = "2"
1515
minifier = "0.3.0"
16+
pulldown-cmark-old = { version = "0.9.6", package = "pulldown-cmark", default-features = false }
1617
regex = "1"
1718
rustdoc-json-types = { path = "../rustdoc-json-types" }
1819
serde_json = "1.0"

0 commit comments

Comments
 (0)