From 6f96dc221c53a80f20883d285d55099fbeba15f4 Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Sun, 5 Apr 2020 22:37:06 +0100 Subject: rustdoc: Don't try to load source files from external crates Local items defined in external macros shouldn't generate rendered source files and should link to the external crate's docs instead. --- src/test/rustdoc/auxiliary/external-macro-src.rs | 15 +++++++++++++++ src/test/rustdoc/external-macro-src.rs | 15 +++++++++++++++ src/test/rustdoc/issue-26606.rs | 2 +- src/test/rustdoc/thread-local-src.rs | 6 ++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/test/rustdoc/auxiliary/external-macro-src.rs create mode 100644 src/test/rustdoc/external-macro-src.rs create mode 100644 src/test/rustdoc/thread-local-src.rs (limited to 'src/test') diff --git a/src/test/rustdoc/auxiliary/external-macro-src.rs b/src/test/rustdoc/auxiliary/external-macro-src.rs new file mode 100644 index 00000000000..ce20ca5c91e --- /dev/null +++ b/src/test/rustdoc/auxiliary/external-macro-src.rs @@ -0,0 +1,15 @@ +// compile-flags:--remap-path-prefix={{src-base}}=/does-not-exist + +#![doc(html_root_url = "https://example.com/")] + +#[macro_export] +macro_rules! make_foo { + () => { + pub struct Foo; + impl Foo { + pub fn new() -> Foo { + Foo + } + } + } +} diff --git a/src/test/rustdoc/external-macro-src.rs b/src/test/rustdoc/external-macro-src.rs new file mode 100644 index 00000000000..4394415e5c7 --- /dev/null +++ b/src/test/rustdoc/external-macro-src.rs @@ -0,0 +1,15 @@ +// aux-build:external-macro-src.rs +// ignore-tidy-linelength + +#![crate_name = "foo"] + +#[macro_use] +extern crate external_macro_src; + +// @has foo/index.html '//a[@href="../src/foo/external-macro-src.rs.html#4-15"]' '[src]' + +// @has foo/struct.Foo.html +// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#8"]' '[src]' +// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#9-13"]' '[src]' +// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#10-12"]' '[src]' +make_foo!(); diff --git a/src/test/rustdoc/issue-26606.rs b/src/test/rustdoc/issue-26606.rs index d2aa4bbbd12..c8e9a63ea9f 100644 --- a/src/test/rustdoc/issue-26606.rs +++ b/src/test/rustdoc/issue-26606.rs @@ -7,5 +7,5 @@ extern crate issue_26606_macro; // @has issue_26606/constant.FOO.html -// @has - '//a/@href' '../src/issue_26606/auxiliary/issue-26606-macro.rs.html#3' +// @has - '//a/@href' '../src/issue_26606_macro/issue-26606-macro.rs.html#3' make_item!(FOO); diff --git a/src/test/rustdoc/thread-local-src.rs b/src/test/rustdoc/thread-local-src.rs new file mode 100644 index 00000000000..022d81a4dbf --- /dev/null +++ b/src/test/rustdoc/thread-local-src.rs @@ -0,0 +1,6 @@ +#![crate_name = "foo"] + +// @has foo/index.html '//a[@href="../src/foo/thread-local-src.rs.html#1-6"]' '[src]' + +// @has foo/constant.FOO.html '//a/@href' 'https://doc.rust-lang.org/nightly/src/std/' +thread_local!(pub static FOO: bool = false); -- cgit 1.4.1-3-g733a5