about summary refs log tree commit diff
path: root/tests/rustdoc/source-code-pages
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-05-06 06:37:30 +0000
committerbors <bors@rust-lang.org>2025-05-06 06:37:30 +0000
commit651e9cf327358b28db7e37a2ae61727f4a2ef232 (patch)
tree9e08a2741b303e04c0f4b98a180efd01d8716f1d /tests/rustdoc/source-code-pages
parent7295b08a17d1107155acd4b552069e3705b0ab1f (diff)
parent546c1c2dd48ba6eded56a9ee74d78cab8e7ad204 (diff)
downloadrust-651e9cf327358b28db7e37a2ae61727f4a2ef232.tar.gz
rust-651e9cf327358b28db7e37a2ae61727f4a2ef232.zip
Auto merge of #140695 - Zalathar:rollup-i32gzbo, r=Zalathar
Rollup of 12 pull requests

Successful merges:

 - #139550 (Fix `-Zremap-path-scope` rmeta handling)
 - #139764 (Consistent trait bounds for ExtractIf Debug impls)
 - #139773 (Implement `Iterator::last` for `vec::IntoIter`)
 - #140035 (Implement RFC 3503: frontmatters)
 - #140251 (coverage-dump: Resolve global file IDs to filenames)
 - #140393 (std: get rid of `sys_common::process`)
 - #140532 (Fix RustAnalyzer discovery of rustc's `stable_mir` crate)
 - #140598 (Steer docs to `utf8_chunks` and `Iterator::take`)
 - #140634 (Use more accurate ELF flags on MIPS)
 - #140673 (Clean rustdoc tests folder)
 - #140678 (Be a bit more relaxed about not yet constrained infer vars in closure upvar analysis)
 - #140687 (Update mdbook to 0.4.49)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests/rustdoc/source-code-pages')
-rw-r--r--tests/rustdoc/source-code-pages/assoc-type-source-link.rs26
-rw-r--r--tests/rustdoc/source-code-pages/auxiliary/issue-26606-macro.rs4
-rw-r--r--tests/rustdoc/source-code-pages/auxiliary/issue-34274.rs3
-rw-r--r--tests/rustdoc/source-code-pages/auxiliary/source-code-bar.rs17
-rw-r--r--tests/rustdoc/source-code-pages/auxiliary/source_code.rs1
-rw-r--r--tests/rustdoc/source-code-pages/auxiliary/src-links-external.rs1
-rw-r--r--tests/rustdoc/source-code-pages/check-source-code-urls-to-def-std.rs42
-rw-r--r--tests/rustdoc/source-code-pages/check-source-code-urls-to-def.rs71
-rw-r--r--tests/rustdoc/source-code-pages/doc-hidden-source.rs16
-rw-r--r--tests/rustdoc/source-code-pages/html-no-source.rs30
-rw-r--r--tests/rustdoc/source-code-pages/source-code-highlight.rs29
-rw-r--r--tests/rustdoc/source-code-pages/source-file.rs5
-rw-r--r--tests/rustdoc/source-code-pages/source-line-numbers.rs35
-rw-r--r--tests/rustdoc/source-code-pages/source-version-separator.rs30
-rw-r--r--tests/rustdoc/source-code-pages/src-link-external-macro-26606.rs14
-rw-r--r--tests/rustdoc/source-code-pages/src-links-auto-impls.rs12
-rw-r--r--tests/rustdoc/source-code-pages/src-links-external.rs13
-rw-r--r--tests/rustdoc/source-code-pages/src-links-implementor-43893.rs21
-rw-r--r--tests/rustdoc/source-code-pages/src-links-inlined-34274.rs11
-rw-r--r--tests/rustdoc/source-code-pages/src-links.rs51
-rw-r--r--tests/rustdoc/source-code-pages/src-links/compiletest-ignore-dir0
-rw-r--r--tests/rustdoc/source-code-pages/src-links/fizz.rs1
-rw-r--r--tests/rustdoc/source-code-pages/src-links/mod.rs19
-rw-r--r--tests/rustdoc/source-code-pages/src-mod-path-absolute-26995.rs10
-rw-r--r--tests/rustdoc/source-code-pages/version-separator-without-source.rs23
25 files changed, 485 insertions, 0 deletions
diff --git a/tests/rustdoc/source-code-pages/assoc-type-source-link.rs b/tests/rustdoc/source-code-pages/assoc-type-source-link.rs
new file mode 100644
index 00000000000..a955a67a457
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/assoc-type-source-link.rs
@@ -0,0 +1,26 @@
+// This test ensures that the source links are generated for impl associated types.
+
+#![crate_name = "foo"]
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+
+//@ has 'foo/struct.Bar.html'
+pub struct Bar;
+
+impl Bar {
+    //@ has - '//*[@id="implementations-list"]//*[@id="associatedtype.Y"]/a' 'Source'
+    //@ has - '//*[@id="implementations-list"]//*[@id="associatedtype.Y"]/a/@href' \
+    // '../src/foo/assoc-type-source-link.rs.html#14'
+    pub type Y = u8;
+}
+
+pub trait Foo {
+    type Z;
+}
+
+impl Foo for Bar {
+    //@ has - '//*[@id="trait-implementations-list"]//*[@id="associatedtype.Z"]/a' 'Source'
+    //@ has - '//*[@id="trait-implementations-list"]//*[@id="associatedtype.Z"]/a/@href' \
+    // '../src/foo/assoc-type-source-link.rs.html#25'
+    type Z = u8;
+}
diff --git a/tests/rustdoc/source-code-pages/auxiliary/issue-26606-macro.rs b/tests/rustdoc/source-code-pages/auxiliary/issue-26606-macro.rs
new file mode 100644
index 00000000000..d60d32526aa
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/auxiliary/issue-26606-macro.rs
@@ -0,0 +1,4 @@
+#[macro_export]
+macro_rules! make_item (
+    ($name: ident) => (pub const $name: usize = 42;)
+);
diff --git a/tests/rustdoc/source-code-pages/auxiliary/issue-34274.rs b/tests/rustdoc/source-code-pages/auxiliary/issue-34274.rs
new file mode 100644
index 00000000000..c46660579a8
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/auxiliary/issue-34274.rs
@@ -0,0 +1,3 @@
+extern "C" {
+    pub fn extern_c_fn();
+}
diff --git a/tests/rustdoc/source-code-pages/auxiliary/source-code-bar.rs b/tests/rustdoc/source-code-pages/auxiliary/source-code-bar.rs
new file mode 100644
index 00000000000..8700d688ef7
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/auxiliary/source-code-bar.rs
@@ -0,0 +1,17 @@
+//! just some other file. :)
+
+use crate::Foo;
+
+pub struct Bar {
+    field: Foo,
+}
+
+pub struct Bar2 {
+    field: crate::Foo,
+}
+
+pub mod sub {
+    pub trait Trait {
+        fn tadam() {}
+    }
+}
diff --git a/tests/rustdoc/source-code-pages/auxiliary/source_code.rs b/tests/rustdoc/source-code-pages/auxiliary/source_code.rs
new file mode 100644
index 00000000000..72a5c1a0ae9
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/auxiliary/source_code.rs
@@ -0,0 +1 @@
+pub struct SourceCode;
diff --git a/tests/rustdoc/source-code-pages/auxiliary/src-links-external.rs b/tests/rustdoc/source-code-pages/auxiliary/src-links-external.rs
new file mode 100644
index 00000000000..4a835673a59
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/auxiliary/src-links-external.rs
@@ -0,0 +1 @@
+pub struct Foo;
diff --git a/tests/rustdoc/source-code-pages/check-source-code-urls-to-def-std.rs b/tests/rustdoc/source-code-pages/check-source-code-urls-to-def-std.rs
new file mode 100644
index 00000000000..42468f7dde6
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/check-source-code-urls-to-def-std.rs
@@ -0,0 +1,42 @@
+//@ compile-flags: -Zunstable-options --generate-link-to-definition
+
+#![crate_name = "foo"]
+
+//@ has 'src/foo/check-source-code-urls-to-def-std.rs.html'
+
+fn babar() {}
+
+//@ has - '//a[@href="{{channel}}/std/primitive.u32.html"]' 'u32'
+//@ has - '//a[@href="{{channel}}/std/primitive.str.html"]' 'str'
+//@ has - '//a[@href="{{channel}}/std/primitive.bool.html"]' 'bool'
+//@ has - '//a[@href="#7"]' 'babar'
+pub fn foo(a: u32, b: &str, c: String) {
+    let x = 12;
+    let y: bool = true;
+    babar();
+}
+
+macro_rules! yolo { () => {}}
+
+fn bar(a: i32) {}
+
+macro_rules! bar {
+    ($a:ident) => { bar($a) }
+}
+
+macro_rules! data {
+    ($x:expr) => { $x * 2 }
+}
+
+pub fn another_foo() {
+    // This is known limitation: if the macro doesn't generate anything, the visitor
+    // can't find any item or anything that could tell us that it comes from expansion.
+    //@ !has - '//a[@href="#19"]' 'yolo!'
+    yolo!();
+    //@ has - '//a[@href="{{channel}}/std/macro.eprintln.html"]' 'eprintln!'
+    eprintln!();
+    //@ has - '//a[@href="#27-29"]' 'data!'
+    let x = data!(4);
+    //@ has - '//a[@href="#23-25"]' 'bar!'
+    bar!(x);
+}
diff --git a/tests/rustdoc/source-code-pages/check-source-code-urls-to-def.rs b/tests/rustdoc/source-code-pages/check-source-code-urls-to-def.rs
new file mode 100644
index 00000000000..d701b88bf9f
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/check-source-code-urls-to-def.rs
@@ -0,0 +1,71 @@
+//@ compile-flags: -Zunstable-options --generate-link-to-definition
+//@ aux-build:source_code.rs
+//@ build-aux-docs
+
+#![feature(rustc_attrs)]
+
+#![crate_name = "foo"]
+
+extern crate source_code;
+
+//@ has 'src/foo/check-source-code-urls-to-def.rs.html'
+
+//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#1-17"]' 'bar'
+#[path = "auxiliary/source-code-bar.rs"]
+pub mod bar;
+
+//@ count - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#5-7"]' 4
+use bar::Bar;
+//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#13-17"]' 'self'
+//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait'
+use bar::sub::{self, Trait};
+
+pub struct Foo;
+
+impl Foo {
+    fn hello(&self) {}
+}
+
+fn babar() {}
+
+//@ has - '//pre[@class="rust"]//a/@href' '/struct.String.html'
+//@ has - '//pre[@class="rust"]//a/@href' '/primitive.u32.html'
+//@ has - '//pre[@class="rust"]//a/@href' '/primitive.str.html'
+// The 5 links to line 23 and the line 23 itself.
+//@ count - '//pre[@class="rust"]//a[@href="#23"]' 6
+//@ has - '//pre[@class="rust"]//a[@href="../../source_code/struct.SourceCode.html"]' \
+//        'source_code::SourceCode'
+pub fn foo(a: u32, b: &str, c: String, d: Foo, e: bar::Bar, f: source_code::SourceCode) {
+    let x = 12;
+    let y: Foo = Foo;
+    let z: Bar = bar::Bar { field: Foo };
+    babar();
+    //@ has - '//pre[@class="rust"]//a[@href="#26"]' 'hello'
+    y.hello();
+}
+
+//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'bar::sub::Trait'
+//@ has - '//pre[@class="rust"]//a[@href="auxiliary/source-code-bar.rs.html#14-16"]' 'Trait'
+pub fn foo2<T: bar::sub::Trait, V: Trait>(t: &T, v: &V, b: bool) {}
+
+pub trait AnotherTrait {}
+pub trait WhyNot {}
+
+//@ has - '//pre[@class="rust"]//a[@href="#51"]' 'AnotherTrait'
+//@ has - '//pre[@class="rust"]//a[@href="#52"]' 'WhyNot'
+pub fn foo3<T, V>(t: &T, v: &V)
+where
+    T: AnotherTrait,
+    V: WhyNot
+{}
+
+pub trait AnotherTrait2 {}
+
+//@ has - '//pre[@class="rust"]//a[@href="#62"]' 'AnotherTrait2'
+pub fn foo4() {
+    let x: Vec<&dyn AnotherTrait2> = Vec::new();
+}
+
+//@ has - '//pre[@class="rust"]//a[@href="../../foo/primitive.bool.html"]' 'bool'
+#[rustc_doc_primitive = "bool"]
+mod whatever {}
diff --git a/tests/rustdoc/source-code-pages/doc-hidden-source.rs b/tests/rustdoc/source-code-pages/doc-hidden-source.rs
new file mode 100644
index 00000000000..b6bc622dd58
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/doc-hidden-source.rs
@@ -0,0 +1,16 @@
+// Test for <https://github.com/rust-lang/rust/issues/137342>.
+
+#![crate_name = "foo"]
+
+//@ has 'foo/index.html'
+//@ !has - '//*[@id="main-content"]//*[@class="struct"]' 'Bar'
+#[doc(hidden)]
+pub struct Bar;
+
+//@ !has - '//*' 'pub use crate::Bar as A;'
+pub use crate::Bar as A;
+//@ !has - '//*' 'pub use crate::A as B;'
+pub use crate::A as B;
+//@ has - '//dt/a[@class="struct"]' 'C'
+#[doc(inline)]
+pub use crate::Bar as C;
diff --git a/tests/rustdoc/source-code-pages/html-no-source.rs b/tests/rustdoc/source-code-pages/html-no-source.rs
new file mode 100644
index 00000000000..248afbd00ef
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/html-no-source.rs
@@ -0,0 +1,30 @@
+//@ compile-flags: -Zunstable-options --html-no-source
+
+// This test ensures that the `--html-no-source` flag disables
+// the creation of the `src` folder.
+
+#![feature(staged_api)]
+#![stable(feature = "bar", since = "1.0")]
+#![crate_name = "foo"]
+
+// Ensures that there is no items in the corresponding "src" folder.
+//@ files 'src/foo' '[]'
+
+//@ has foo/fn.foo.html
+//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0'
+//@ !has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · source'
+#[stable(feature = "bar", since = "1.0")]
+pub fn foo() {}
+
+//@ has foo/struct.Bar.html
+//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0'
+//@ !has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · source'
+#[stable(feature = "bar", since = "1.0")]
+pub struct Bar;
+
+impl Bar {
+    //@ has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0.0'
+    //@ !has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0.0 ·'
+    #[stable(feature = "foobar", since = "2.0")]
+    pub fn bar() {}
+}
diff --git a/tests/rustdoc/source-code-pages/source-code-highlight.rs b/tests/rustdoc/source-code-pages/source-code-highlight.rs
new file mode 100644
index 00000000000..f1c905e64c0
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/source-code-highlight.rs
@@ -0,0 +1,29 @@
+// We need this option to be enabled for the `foo` macro declaration to ensure
+// that the link on the ident is not including whitespace characters.
+
+//@ compile-flags: -Zunstable-options --generate-link-to-definition
+#![crate_name = "foo"]
+
+//@ has 'src/foo/source-code-highlight.rs.html'
+
+//@ hasraw - '<a href="../../foo/macro.foo.html">foo</a>'
+#[macro_export]
+macro_rules! foo {
+    () => {}
+}
+
+//@ hasraw - '<span class="macro">foo!</span>'
+foo! {}
+
+//@ hasraw - '<a href="../../foo/fn.f.html">f</a>'
+#[rustfmt::skip]
+pub fn f () {}
+//@ hasraw - '<a href="../../foo/struct.Bar.html">Bar</a>'
+//@ hasraw - '<a href="../../foo/struct.Bar.html">Bar</a>'
+//@ hasraw - '<a href="{{channel}}/std/primitive.u32.html">u32</a>'
+#[rustfmt::skip]
+pub struct Bar ( u32 );
+//@ hasraw - '<a href="../../foo/enum.Foo.html">Foo</a>'
+pub enum Foo {
+    A,
+}
diff --git a/tests/rustdoc/source-code-pages/source-file.rs b/tests/rustdoc/source-code-pages/source-file.rs
new file mode 100644
index 00000000000..6cff5edf146
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/source-file.rs
@@ -0,0 +1,5 @@
+#![crate_name = "foo"]
+
+//@ hasraw src-files.js source-file.rs
+
+pub struct Foo;
diff --git a/tests/rustdoc/source-code-pages/source-line-numbers.rs b/tests/rustdoc/source-code-pages/source-line-numbers.rs
new file mode 100644
index 00000000000..0b654b1a004
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/source-line-numbers.rs
@@ -0,0 +1,35 @@
+// This test ensures that we have the expected number of line generated.
+
+#![crate_name = "foo"]
+
+//@ has 'src/foo/source-line-numbers.rs.html'
+//@ count - '//a[@data-nosnippet]' 35
+//@ has - '//a[@id="35"]' '35'
+
+#[
+macro_export
+]
+macro_rules! bar {
+    ($x:ident) => {{
+        $x += 2;
+        $x *= 2;
+    }}
+}
+
+/*
+multi line
+comment
+*/
+fn x(_: u8, _: u8) {}
+
+fn foo() {
+    let mut y = 0;
+    bar!(y);
+    println!("
+    {y}
+    ");
+    x(
+      1,
+      2,
+    );
+}
diff --git a/tests/rustdoc/source-code-pages/source-version-separator.rs b/tests/rustdoc/source-code-pages/source-version-separator.rs
new file mode 100644
index 00000000000..78b9d364d21
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/source-version-separator.rs
@@ -0,0 +1,30 @@
+#![stable(feature = "bar", since = "1.0")]
+#![crate_name = "foo"]
+#![feature(staged_api)]
+
+//@ has foo/trait.Bar.html
+//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · Source'
+#[stable(feature = "bar", since = "1.0")]
+pub trait Bar {
+    //@ has - '//*[@id="tymethod.foo"]/*[@class="rightside"]' '3.0.0 · Source'
+    #[stable(feature = "foobar", since = "3.0")]
+    fn foo();
+}
+
+//@ has - '//div[@id="implementors-list"]//*[@class="rightside"]' '4.0.0 · Source'
+
+//@ has foo/struct.Foo.html
+//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · Source'
+#[stable(feature = "baz", since = "1.0")]
+pub struct Foo;
+
+impl Foo {
+    //@ has - '//*[@id="method.foofoo"]/*[@class="rightside"]' '3.0.0 · Source'
+    #[stable(feature = "foobar", since = "3.0")]
+    pub fn foofoo() {}
+}
+
+#[stable(feature = "yolo", since = "4.0")]
+impl Bar for Foo {
+    fn foo() {}
+}
diff --git a/tests/rustdoc/source-code-pages/src-link-external-macro-26606.rs b/tests/rustdoc/source-code-pages/src-link-external-macro-26606.rs
new file mode 100644
index 00000000000..0ce829f06f5
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/src-link-external-macro-26606.rs
@@ -0,0 +1,14 @@
+//@ aux-build:issue-26606-macro.rs
+//@ ignore-cross-compile
+//@ build-aux-docs
+
+// https://github.com/rust-lang/rust/issues/26606
+#![crate_name="issue_26606"]
+
+//@ has issue_26606_macro/macro.make_item.html
+#[macro_use]
+extern crate issue_26606_macro;
+
+//@ has issue_26606/constant.FOO.html
+//@ has - '//a[@href="../src/issue_26606/src-link-external-macro-26606.rs.html#14"]' 'Source'
+make_item!(FOO);
diff --git a/tests/rustdoc/source-code-pages/src-links-auto-impls.rs b/tests/rustdoc/source-code-pages/src-links-auto-impls.rs
new file mode 100644
index 00000000000..5a777f59b7e
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/src-links-auto-impls.rs
@@ -0,0 +1,12 @@
+#![crate_name = "foo"]
+
+//@ has foo/struct.Unsized.html
+//@ has - '//*[@id="impl-Sized-for-Unsized"]/h3[@class="code-header"]' 'impl !Sized for Unsized'
+//@ !has - '//*[@id="impl-Sized-for-Unsized"]//a[@class="src"]' 'Source'
+//@ has - '//*[@id="impl-Sync-for-Unsized"]/h3[@class="code-header"]' 'impl Sync for Unsized'
+//@ !has - '//*[@id="impl-Sync-for-Unsized"]//a[@class="src"]' 'Source'
+//@ has - '//*[@id="impl-Any-for-T"]/h3[@class="code-header"]' 'impl<T> Any for T'
+//@ has - '//*[@id="impl-Any-for-T"]//a[@class="src rightside"]' 'Source'
+pub struct Unsized {
+    data: [u8],
+}
diff --git a/tests/rustdoc/source-code-pages/src-links-external.rs b/tests/rustdoc/source-code-pages/src-links-external.rs
new file mode 100644
index 00000000000..e8acbf1b9b4
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/src-links-external.rs
@@ -0,0 +1,13 @@
+//@ aux-build:src-links-external.rs
+//@ build-aux-docs
+//@ ignore-cross-compile
+
+#![crate_name = "foo"]
+
+extern crate src_links_external;
+
+//@ has foo/bar/index.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#1'
+#[doc(inline)]
+pub use src_links_external as bar;
+
+//@ has foo/bar/struct.Foo.html '//a/@href' '../../src/src_links_external/src-links-external.rs.html#1'
diff --git a/tests/rustdoc/source-code-pages/src-links-implementor-43893.rs b/tests/rustdoc/source-code-pages/src-links-implementor-43893.rs
new file mode 100644
index 00000000000..d9abdcde08d
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/src-links-implementor-43893.rs
@@ -0,0 +1,21 @@
+//@ ignore-cross-compile
+
+// https://github.com/rust-lang/rust/issues/43893
+
+#![crate_name = "foo"]
+
+pub trait SomeTrait {}
+pub struct SomeStruct;
+
+//@ has foo/trait.SomeTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#11'
+impl SomeTrait for usize {}
+
+//@ has foo/trait.SomeTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#14-16'
+impl SomeTrait for SomeStruct {
+    // deliberately multi-line impl
+}
+
+pub trait AnotherTrait {}
+
+//@ has foo/trait.AnotherTrait.html '//a/@href' '../src/foo/src-links-implementor-43893.rs.html#21'
+impl<T> AnotherTrait for T {}
diff --git a/tests/rustdoc/source-code-pages/src-links-inlined-34274.rs b/tests/rustdoc/source-code-pages/src-links-inlined-34274.rs
new file mode 100644
index 00000000000..8675ae4736e
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/src-links-inlined-34274.rs
@@ -0,0 +1,11 @@
+//@ aux-build:issue-34274.rs
+//@ build-aux-docs
+//@ ignore-cross-compile
+
+// https://github.com/rust-lang/rust/issues/34274
+#![crate_name = "foo"]
+
+extern crate issue_34274;
+
+//@ has foo/fn.extern_c_fn.html '//a/@href' '../src/issue_34274/issue-34274.rs.html#2'
+pub use issue_34274::extern_c_fn;
diff --git a/tests/rustdoc/source-code-pages/src-links.rs b/tests/rustdoc/source-code-pages/src-links.rs
new file mode 100644
index 00000000000..24039a5d84e
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/src-links.rs
@@ -0,0 +1,51 @@
+#![crate_name = "foo"]
+
+//! Dox
+//@ has src/foo/src-links.rs.html
+//@ has foo/index.html '//a/@href' '../src/foo/src-links.rs.html'
+
+#[path = "src-links/mod.rs"]
+pub mod qux;
+
+//@ has src/foo/src-links.rs.html
+//@ has foo/fizz/index.html '//a/@href' '../src/foo/src-links/fizz.rs.html'
+#[path = "src-links/../src-links/fizz.rs"]
+pub mod fizz;
+
+//@ has foo/bar/index.html '//a/@href' '../../src/foo/src-links.rs.html'
+pub mod bar {
+
+    /// Dox
+    //@ has foo/bar/baz/index.html '//a/@href' '../../../src/foo/src-links.rs.html'
+    pub mod baz {
+        /// Dox
+        //@ has foo/bar/baz/fn.baz.html '//a/@href' '../../../src/foo/src-links.rs.html'
+        pub fn baz() { }
+    }
+
+    /// Dox
+    //@ has foo/bar/trait.Foobar.html '//a/@href' '../../src/foo/src-links.rs.html'
+    pub trait Foobar { fn dummy(&self) { } }
+
+    //@ has foo/bar/struct.Foo.html '//a/@href' '../../src/foo/src-links.rs.html'
+    pub struct Foo { x: i32, y: u32 }
+
+    //@ has foo/bar/fn.prawns.html '//a/@href' '../../src/foo/src-links.rs.html'
+    pub fn prawns((a, b): (i32, u32), Foo { x, y }: Foo) { }
+}
+
+/// Dox
+//@ has foo/fn.modfn.html '//a/@href' '../src/foo/src-links.rs.html'
+pub fn modfn() { }
+
+// same hierarchy as above, but just for the submodule
+
+//@ has src/foo/src-links/mod.rs.html
+//@ has foo/qux/index.html '//a/@href' '../../src/foo/src-links/mod.rs.html'
+//@ has foo/qux/bar/index.html '//a/@href' '../../../src/foo/src-links/mod.rs.html'
+//@ has foo/qux/bar/baz/index.html '//a/@href' '../../../../src/foo/src-links/mod.rs.html'
+//@ has foo/qux/bar/baz/fn.baz.html '//a/@href' '../../../../src/foo/src-links/mod.rs.html'
+//@ has foo/qux/bar/trait.Foobar.html '//a/@href' '../../../src/foo/src-links/mod.rs.html'
+//@ has foo/qux/bar/struct.Foo.html '//a/@href' '../../../src/foo/src-links/mod.rs.html'
+//@ has foo/qux/bar/fn.prawns.html '//a/@href' '../../../src/foo/src-links/mod.rs.html'
+//@ has foo/qux/fn.modfn.html '//a/@href' '../../src/foo/src-links/mod.rs.html'
diff --git a/tests/rustdoc/source-code-pages/src-links/compiletest-ignore-dir b/tests/rustdoc/source-code-pages/src-links/compiletest-ignore-dir
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/src-links/compiletest-ignore-dir
diff --git a/tests/rustdoc/source-code-pages/src-links/fizz.rs b/tests/rustdoc/source-code-pages/src-links/fizz.rs
new file mode 100644
index 00000000000..d2b76b1cec8
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/src-links/fizz.rs
@@ -0,0 +1 @@
+pub struct Buzz;
diff --git a/tests/rustdoc/source-code-pages/src-links/mod.rs b/tests/rustdoc/source-code-pages/src-links/mod.rs
new file mode 100644
index 00000000000..27b2396811a
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/src-links/mod.rs
@@ -0,0 +1,19 @@
+//! Dox
+pub mod bar {
+
+    /// Dox
+    pub mod baz {
+        /// Dox
+        pub fn baz() { }
+    }
+
+    /// Dox
+    pub trait Foobar { fn dummy(&self) { } }
+
+    pub struct Foo { x: i32, y: u32 }
+
+    pub fn prawns((a, b): (i32, u32), Foo { x, y }: Foo) { }
+}
+
+/// Dox
+pub fn modfn() { }
diff --git a/tests/rustdoc/source-code-pages/src-mod-path-absolute-26995.rs b/tests/rustdoc/source-code-pages/src-mod-path-absolute-26995.rs
new file mode 100644
index 00000000000..f754b64977f
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/src-mod-path-absolute-26995.rs
@@ -0,0 +1,10 @@
+//@ ignore-windows
+//@ compile-flags: --no-defaults
+
+// https://github.com/rust-lang/rust/issues/26995
+#![crate_name="issue_26995"]
+
+//@ has src/issue_26995/dev/null.html
+//@ has issue_26995/null/index.html '//a/@href' '../../src/issue_26995/dev/null.html'
+#[path="/dev/null"]
+pub mod null;
diff --git a/tests/rustdoc/source-code-pages/version-separator-without-source.rs b/tests/rustdoc/source-code-pages/version-separator-without-source.rs
new file mode 100644
index 00000000000..7cd1780f1d3
--- /dev/null
+++ b/tests/rustdoc/source-code-pages/version-separator-without-source.rs
@@ -0,0 +1,23 @@
+#![doc(html_no_source)]
+#![feature(staged_api)]
+#![stable(feature = "bar", since = "1.0")]
+#![crate_name = "foo"]
+
+//@ has foo/fn.foo.html
+//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0'
+//@ !has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · source'
+#[stable(feature = "bar", since = "1.0")]
+pub fn foo() {}
+
+//@ has foo/struct.Bar.html
+//@ has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0'
+//@ !has - '//div[@class="main-heading"]/*[@class="sub-heading"]' '1.0.0 · source'
+#[stable(feature = "bar", since = "1.0")]
+pub struct Bar;
+
+impl Bar {
+    //@ has - '//*[@id="method.bar"]/*[@class="since rightside"]' '2.0.0'
+    //@ !has - '//*[@id="method.bar"]/*[@class="rightside"]' '2.0.0 ·'
+    #[stable(feature = "foobar", since = "2.0")]
+    pub fn bar() {}
+}