]> git.lizzy.rs Git - rust.git/commitdiff
Report errors instead of panic!()
authorMikko Rantanen <jubjub@jubjubnest.net>
Fri, 12 Jan 2018 10:37:48 +0000 (12:37 +0200)
committerMikko Rantanen <jubjub@jubjubnest.net>
Fri, 12 Jan 2018 14:47:58 +0000 (16:47 +0200)
src/tools/linkchecker/main.rs

index 6458ec02669aab24a6263690daab0d6ace254ced..f6eaa09f55d9937a24ac414906e49cfc52fb1d30 100644 (file)
@@ -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); }