Skip to content

Commit 1d262cd

Browse files
authored
Rollup merge of rust-lang#103952 - ehuss:dont-intra-linkcheck-reference, r=Mark-Simulacrum
Don't intra linkcheck reference This removes the reference from the intra-doc link checks. This causes problems if any of the reference content needs to change, it causes the linkchecker to break. The reference has its own broken link check (https://github.com/rust-lang/reference/tree/master/style-check) which uses pulldown-cmark on the source to find actual broken links (instead of false-positives like this regex does). I think the intra-doc link check could potentially be removed completely, since I think rustdoc is now checking for them well enough. However, it may serve as a decent regression check.
2 parents 2313d32 + 57b2290 commit 1d262cd

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

src/tools/linkchecker/main.rs

+27-30
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,6 @@ const LINKCHECK_EXCEPTIONS: &[(&str, &[&str])] = &[
5555

5656
#[rustfmt::skip]
5757
const INTRA_DOC_LINK_EXCEPTIONS: &[(&str, &[&str])] = &[
58-
// This will never have links that are not in other pages.
59-
// To avoid repeating the exceptions twice, an empty list means all broken links are allowed.
60-
("reference/print.html", &[]),
61-
// All the reference 'links' are actually ENBF highlighted as code
62-
("reference/comments.html", &[
63-
"/</code> <code>!",
64-
"*</code> <code>!",
65-
]),
66-
("reference/identifiers.html", &[
67-
"a</code>-<code>z</code> <code>A</code>-<code>Z",
68-
"a</code>-<code>z</code> <code>A</code>-<code>Z</code> <code>0</code>-<code>9</code> <code>_",
69-
"a</code>-<code>z</code> <code>A</code>-<code>Z</code>] [<code>a</code>-<code>z</code> <code>A</code>-<code>Z</code> <code>0</code>-<code>9</code> <code>_",
70-
]),
71-
("reference/tokens.html", &[
72-
"0</code>-<code>1",
73-
"0</code>-<code>7",
74-
"0</code>-<code>9",
75-
"0</code>-<code>9",
76-
"0</code>-<code>9</code> <code>a</code>-<code>f</code> <code>A</code>-<code>F",
77-
]),
78-
("reference/notation.html", &[
79-
"b</code> <code>B",
80-
"a</code>-<code>z",
81-
]),
8258
// This is being used in the sense of 'inclusive range', not a markdown link
8359
("core/ops/struct.RangeInclusive.html", &["begin</code>, <code>end"]),
8460
("std/ops/struct.RangeInclusive.html", &["begin</code>, <code>end"]),
@@ -365,6 +341,33 @@ impl Checker {
365341
}
366342
});
367343

344+
self.check_intra_doc_links(file, &pretty_path, &source, report);
345+
346+
// we don't need the source anymore,
347+
// so drop to reduce memory-usage
348+
match self.cache.get_mut(&pretty_path).unwrap() {
349+
FileEntry::HtmlFile { source, .. } => *source = Rc::new(String::new()),
350+
_ => unreachable!("must be html file"),
351+
}
352+
}
353+
354+
fn check_intra_doc_links(
355+
&mut self,
356+
file: &Path,
357+
pretty_path: &str,
358+
source: &str,
359+
report: &mut Report,
360+
) {
361+
let relative = file.strip_prefix(&self.root).expect("should always be relative to root");
362+
// Don't check the reference. It has several legitimate things that
363+
// look like [<code>…</code>]. The reference has its own broken link
364+
// checker in its CI which handles this using pulldown_cmark.
365+
//
366+
// This checks both the end of the root (when checking just the
367+
// reference directory) or the beginning (when checking all docs).
368+
if self.root.ends_with("reference") || relative.starts_with("reference") {
369+
return;
370+
}
368371
// Search for intra-doc links that rustdoc didn't warn about
369372
// FIXME(#77199, 77200) Rustdoc should just warn about these directly.
370373
// NOTE: only looks at one line at a time; in practice this should find most links
@@ -379,12 +382,6 @@ impl Checker {
379382
}
380383
}
381384
}
382-
// we don't need the source anymore,
383-
// so drop to reduce memory-usage
384-
match self.cache.get_mut(&pretty_path).unwrap() {
385-
FileEntry::HtmlFile { source, .. } => *source = Rc::new(String::new()),
386-
_ => unreachable!("must be html file"),
387-
}
388385
}
389386

390387
/// Load a file from disk, or from the cache if available.

0 commit comments

Comments
 (0)