diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index 60e4e7492240c..d47b095317980 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -563,7 +563,7 @@ function loadCss(cssUrl) {
onEachLazy(code.getElementsByTagName("a"), elem => {
const href = elem.getAttribute("href");
- if (href && href.indexOf("http") !== 0) {
+ if (href && !/^(?:[a-z+]+:)?\/\//.test(href)) {
elem.setAttribute("href", window.rootPath + href);
}
});
diff --git a/src/test/rustdoc-gui/implementors.goml b/src/test/rustdoc-gui/implementors.goml
index 4999283dc8b91..997c0ed8f017c 100644
--- a/src/test/rustdoc-gui/implementors.goml
+++ b/src/test/rustdoc-gui/implementors.goml
@@ -33,3 +33,9 @@ goto: "file://" + |DOC_PATH| + "/lib2/trait.TraitToReexport.html"
assert-count: ("#implementors-list .impl", 1)
goto: "file://" + |DOC_PATH| + "/implementors/trait.TraitToReexport.html"
assert-count: ("#implementors-list .impl", 1)
+
+// Now check that the link is properly rewritten for a crate called `http`.
+// An older version of rustdoc had a buggy check for absolute links.
+goto: "file://" + |DOC_PATH| + "/http/trait.HttpTrait.html"
+assert-count: ("#implementors-list .impl", 1)
+assert-attribute: ("#implementors-list .impl a.trait", {"href": "../http/trait.HttpTrait.html"})
diff --git a/src/test/rustdoc-gui/search-filter.goml b/src/test/rustdoc-gui/search-filter.goml
index e556da0c54eba..5bc6e87d6d24d 100644
--- a/src/test/rustdoc-gui/search-filter.goml
+++ b/src/test/rustdoc-gui/search-filter.goml
@@ -15,6 +15,7 @@ click: "#crate-search"
press-key: "ArrowDown"
press-key: "ArrowDown"
press-key: "ArrowDown"
+press-key: "ArrowDown"
press-key: "Enter"
// Waiting for the search results to appear...
wait-for: "#search-tabs"
@@ -39,6 +40,7 @@ click: "#crate-search"
press-key: "ArrowUp"
press-key: "ArrowUp"
press-key: "ArrowUp"
+press-key: "ArrowUp"
press-key: "Enter"
// Waiting for the search results to appear...
wait-for: "#search-tabs"
diff --git a/src/test/rustdoc-gui/sidebar-source-code.goml b/src/test/rustdoc-gui/sidebar-source-code.goml
index d5f57ed6102c7..6bc07fbae04da 100644
--- a/src/test/rustdoc-gui/sidebar-source-code.goml
+++ b/src/test/rustdoc-gui/sidebar-source-code.goml
@@ -73,7 +73,7 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
// Only "another_folder" should be "open" in "lib2".
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
// All other trees should be collapsed.
-assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 7)
+assert-count: ("//*[@id='source-sidebar']/details[not(text()='lib2') and not(@open)]", 8)
// We now switch to mobile mode.
size: (600, 600)
diff --git a/src/test/rustdoc-gui/source-code-page.goml b/src/test/rustdoc-gui/source-code-page.goml
index aa79219696020..e0397890519bb 100644
--- a/src/test/rustdoc-gui/source-code-page.goml
+++ b/src/test/rustdoc-gui/source-code-page.goml
@@ -102,7 +102,7 @@ assert: ".source-sidebar-expanded"
// We check that the first entry of the sidebar is collapsed
assert-property: ("#source-sidebar details:first-of-type", {"open": "false"})
-assert-text: ("#source-sidebar details:first-of-type > summary", "huge_logo")
+assert-text: ("#source-sidebar details:first-of-type > summary", "http")
// We now click on it.
click: "#source-sidebar details:first-of-type > summary"
assert-property: ("#source-sidebar details:first-of-type", {"open": "true"})
diff --git a/src/test/rustdoc-gui/src/lib2/Cargo.lock b/src/test/rustdoc-gui/src/lib2/Cargo.lock
index a5873ceb3256a..425a3ae7e5c92 100644
--- a/src/test/rustdoc-gui/src/lib2/Cargo.lock
+++ b/src/test/rustdoc-gui/src/lib2/Cargo.lock
@@ -2,13 +2,21 @@
# It is not intended for manual editing.
version = 3
+[[package]]
+name = "http"
+version = "0.1.0"
+
[[package]]
name = "implementors"
version = "0.1.0"
+dependencies = [
+ "http",
+]
[[package]]
name = "lib2"
version = "0.1.0"
dependencies = [
+ "http",
"implementors",
]
diff --git a/src/test/rustdoc-gui/src/lib2/Cargo.toml b/src/test/rustdoc-gui/src/lib2/Cargo.toml
index 2e37f3f667a02..8bca77ff834d8 100644
--- a/src/test/rustdoc-gui/src/lib2/Cargo.toml
+++ b/src/test/rustdoc-gui/src/lib2/Cargo.toml
@@ -8,3 +8,4 @@ path = "lib.rs"
[dependencies]
implementors = { path = "./implementors" }
+http = { path = "./http" }
diff --git a/src/test/rustdoc-gui/src/lib2/http/Cargo.toml b/src/test/rustdoc-gui/src/lib2/http/Cargo.toml
new file mode 100644
index 0000000000000..fa719efa52635
--- /dev/null
+++ b/src/test/rustdoc-gui/src/lib2/http/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "http"
+version = "0.1.0"
+edition = "2018"
+
+[lib]
+path = "lib.rs"
diff --git a/src/test/rustdoc-gui/src/lib2/http/lib.rs b/src/test/rustdoc-gui/src/lib2/http/lib.rs
new file mode 100644
index 0000000000000..204e07494275b
--- /dev/null
+++ b/src/test/rustdoc-gui/src/lib2/http/lib.rs
@@ -0,0 +1 @@
+pub trait HttpTrait {}
diff --git a/src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml b/src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml
index 7ef1052c49fd2..9dafc43df5f80 100644
--- a/src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml
+++ b/src/test/rustdoc-gui/src/lib2/implementors/Cargo.toml
@@ -5,3 +5,6 @@ edition = "2018"
[lib]
path = "lib.rs"
+
+[dependencies]
+http = { path = "../http/" }
diff --git a/src/test/rustdoc-gui/src/lib2/implementors/lib.rs b/src/test/rustdoc-gui/src/lib2/implementors/lib.rs
index 1620e84229191..2842ac50dc1e8 100644
--- a/src/test/rustdoc-gui/src/lib2/implementors/lib.rs
+++ b/src/test/rustdoc-gui/src/lib2/implementors/lib.rs
@@ -10,6 +10,8 @@ impl Whatever for Struct {
type Foo = u8;
}
+impl http::HttpTrait for Struct {}
+
mod traits {
pub trait TraitToReexport {
fn method() {}