diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index 3fd04449d4cc..30dacde94cf0 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -532,6 +532,7 @@ fn make_href(
fqp: &[Symbol],
is_absolute: bool,
) -> String {
+ // FIXME: relative extern URLs may break when prefixed with root_path
if !is_absolute && let Some(root_path) = root_path {
let root = root_path.trim_end_matches('/');
url_parts.push_front(root);
diff --git a/tests/rustdoc-html/extern/extern-html-root-url-relative.rs b/tests/rustdoc-html/extern/extern-html-root-url-relative.rs
index df6ebf1aedd5..ba2b50c6bf22 100644
--- a/tests/rustdoc-html/extern/extern-html-root-url-relative.rs
+++ b/tests/rustdoc-html/extern/extern-html-root-url-relative.rs
@@ -1,4 +1,4 @@
-//@ compile-flags:-Z unstable-options --extern-html-root-url core=../ --extern-html-root-takes-precedence
+//@ compile-flags:-Z unstable-options --extern-html-root-url core=../ --extern-html-root-takes-precedence --generate-link-to-definition
// At depth 1 (top-level), the href should be ../core/...
//@ has extern_html_root_url_relative/index.html
@@ -9,7 +9,19 @@
// At depth 2 (inside a module), the href should be ../../core/...
pub mod nested {
//@ has extern_html_root_url_relative/nested/index.html
- //@ has - '//a/@href' '../../core/iter/index.html'
+ //@ has - '//a/@href' '../../core/future/index.html'
#[doc(no_inline)]
- pub use std::iter;
+ pub use std::future;
}
+
+// Also depth 2, but for an intra-doc link.
+//@ has extern_html_root_url_relative/intra_doc_link/index.html
+//@ has - '//a/@href' '../../core/ptr/fn.write.html'
+/// [write]()
+pub mod intra_doc_link {
+}
+
+// link-to-definition
+//@ has src/extern_html_root_url_relative/extern-html-root-url-relative.rs.html
+//@ has - '//a/@href' '../../core/iter/index.html'
+//@ has - '//a/@href' '../../core/future/index.html'