diff options
| author | kennytm <kennytm@gmail.com> | 2018-01-18 01:57:14 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-18 01:57:14 +0800 |
| commit | 29c2aa7932ff0cd067f4edbc0bf9731e9dac37b4 (patch) | |
| tree | 7c10d1398cc3ece403f2153fa39d7b85651e44ef /src/tools | |
| parent | 175dd84ed8969fe136a4da1c7e5fe1d9c7693f2d (diff) | |
| parent | f7b48778b1472045bd8b7ee6aacdbf1487efe50b (diff) | |
| download | rust-29c2aa7932ff0cd067f4edbc0bf9731e9dac37b4.tar.gz rust-29c2aa7932ff0cd067f4edbc0bf9731e9dac37b4.zip | |
Rollup merge of #47387 - Rantanen:linkchecker-error-msg, r=steveklabnik
Report errors instead of panic!() when linkcheck encounters absolute paths The RBE contained some absolute links that failed the link check in #46196. Diagnosing these issues was needlessly complicated, thanks to the linkchecker just panicing instead of reporting proper errors. This PR replaces the panic with a proper `*errors = true` + error message handling. The linkchecker itself doesn't have any tests so I intentionally didn't touch anything else than the code that previously did the `panic!()`. A small code quality improvement might be made by binding the `Path::new(base).join(url)` into a variable before the for-loop and using this resolved url in both the for loop and the error message. r? @steveklabnik (If not for any other reason than having r on the #46196.)
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/linkchecker/main.rs | 12 |
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); } |
