Skip to content

Commit 3a242c2

Browse files
committed
check rustdoc links
1 parent ff7922d commit 3a242c2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/librustdoc/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ tempfile = "3"
2222
thin-vec = "0.2.9"
2323
tracing = "0.1"
2424
tracing-tree = "0.2.0"
25+
rayon = "1.5.1"
2526

2627
[dependencies.tracing-subscriber]
2728
version = "0.3.3"
2829
default-features = false
2930
features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"]
3031

31-
[target.'cfg(windows)'.dependencies]
32-
rayon = "1.5.1"
33-
3432
[dependencies.cargo-deadlinks]
3533
git = "https://github.com/jyn514/cargo-deadlinks/"
3634
branch = "http-feature"

src/librustdoc/html/render/context.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,17 @@ impl<'tcx> Context<'tcx> {
168168
"../".repeat(self.current.len())
169169
}
170170

171+
fn check_dead_links(&mut self) {
172+
use cargo_deadlinks::*;
173+
use rayon::iter::ParallelIterator;
174+
175+
let path = self.dst.canonicalize().unwrap();
176+
let errors: Vec<_> = unavailable_urls(&path, &CheckContext::default()).collect();
177+
for err in errors {
178+
self.sess().struct_warn(&err.to_string().replace('\t', " ")).emit();
179+
}
180+
}
181+
171182
fn render_item(&mut self, it: &clean::Item, is_module: bool) -> String {
172183
let mut title = String::new();
173184
if !is_module {
@@ -708,6 +719,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
708719
// No need for it anymore.
709720
drop(shared);
710721

722+
self.check_dead_links();
723+
711724
// Flush pending errors.
712725
Rc::get_mut(&mut self.shared).unwrap().fs.close();
713726
let nb_errors =

0 commit comments

Comments
 (0)