about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMikko Rantanen <jubjub@jubjubnest.net>2018-01-12 12:37:48 +0200
committerMikko Rantanen <jubjub@jubjubnest.net>2018-01-12 16:47:58 +0200
commitf7b48778b1472045bd8b7ee6aacdbf1487efe50b (patch)
tree6fa0db22f80d5f23f7f237265cafa02a0d7667c3
parent0b90e4e8cd068910f604f3e1fb5d03cc01f1658f (diff)
downloadrust-f7b48778b1472045bd8b7ee6aacdbf1487efe50b.tar.gz
rust-f7b48778b1472045bd8b7ee6aacdbf1487efe50b.zip
Report errors instead of panic!()
-rw-r--r--src/tools/linkchecker/main.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs
index 6458ec02669..f6eaa09f55d 100644
--- a/src/tools/linkchecker/main.rs
+++ b/src/tools/linkchecker/main.rs
@@ -192,7 +192,17 @@ fn check(cache: &mut Cache,
             for part in Path::new(base).join(url).components() {
                 match part {
                     Component::Prefix(_) |
-                    Component::RootDir => panic!(),
+                    Component::RootDir => {
+                        // Avoid absolute paths as they make the docs not
+                        // relocatable by making assumptions on where the docs
+                        // are hosted relative to the site root.
+                        *errors = true;
+                        println!("{}:{}: absolute path - {}",
+                                 pretty_file.display(),
+                                 i + 1,
+                                 Path::new(base).join(url).display());
+                        return;
+                    }
                     Component::CurDir => {}
                     Component::ParentDir => { path.pop(); }
                     Component::Normal(s) => { path.push(s); }