Initial check in

Bug: 137197907
diff --git a/src/test/rustdoc/all.rs b/src/test/rustdoc/all.rs
new file mode 100644
index 0000000..a95d6c4
--- /dev/null
+++ b/src/test/rustdoc/all.rs
@@ -0,0 +1,28 @@
+#![crate_name = "foo"]
+
+// @has foo/all.html '//a[@href="struct.Struct.html"]' 'Struct'
+// @has foo/all.html '//a[@href="enum.Enum.html"]' 'Enum'
+// @has foo/all.html '//a[@href="union.Union.html"]' 'Union'
+// @has foo/all.html '//a[@href="constant.CONST.html"]' 'CONST'
+// @has foo/all.html '//a[@href="static.STATIC.html"]' 'STATIC'
+// @has foo/all.html '//a[@href="fn.function.html"]' 'function'
+
+pub struct Struct;
+pub enum Enum {
+    X,
+    Y,
+}
+pub union Union {
+    x: u32,
+}
+pub const CONST: u32 = 0;
+pub static STATIC: &str = "baguette";
+pub fn function() {}
+
+mod private_module {
+    pub struct ReexportedStruct;
+}
+
+// @has foo/all.html '//a[@href="struct.ReexportedStruct.html"]' 'ReexportedStruct'
+// @!has foo/all.html 'private_module'
+pub use private_module::ReexportedStruct;
diff --git a/src/test/rustdoc/assoc-consts-version.rs b/src/test/rustdoc/assoc-consts-version.rs
new file mode 100644
index 0000000..c561269
--- /dev/null
+++ b/src/test/rustdoc/assoc-consts-version.rs
@@ -0,0 +1,16 @@
+// ignore-tidy-linelength
+
+#![crate_name = "foo"]
+
+#![feature(staged_api)]
+
+#![stable(since="1.1.1", feature="rust1")]
+
+#[stable(since="1.1.1", feature="rust1")]
+pub struct SomeStruct;
+
+impl SomeStruct {
+    // @has 'foo/struct.SomeStruct.html' '//*[@id="associatedconstant.SOME_CONST"]//div[@class="since"]' '1.1.2'
+    #[stable(since="1.1.2", feature="rust2")]
+    pub const SOME_CONST: usize = 0;
+}
diff --git a/src/test/rustdoc/assoc-consts.rs b/src/test/rustdoc/assoc-consts.rs
new file mode 100644
index 0000000..ee622e7
--- /dev/null
+++ b/src/test/rustdoc/assoc-consts.rs
@@ -0,0 +1,99 @@
+pub trait Foo {
+    // @has assoc_consts/trait.Foo.html '//*[@class="rust trait"]' \
+    //      'const FOO: usize;'
+    // @has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize'
+    const FOO: usize = 12;
+    // @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool'
+    const FOO_NO_DEFAULT: bool;
+    // @!has - FOO_HIDDEN
+    #[doc(hidden)]
+    const FOO_HIDDEN: u8 = 0;
+}
+
+pub struct Bar;
+
+impl Foo for Bar {
+    // @has assoc_consts/struct.Bar.html '//code' 'impl Foo for Bar'
+    // @has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize'
+    const FOO: usize = 12;
+    // @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool'
+    const FOO_NO_DEFAULT: bool = false;
+    // @!has - FOO_HIDDEN
+    #[doc(hidden)]
+    const FOO_HIDDEN: u8 = 0;
+}
+
+impl Bar {
+    // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAR"]' \
+    //      'const BAR: usize'
+    pub const BAR: usize = 3;
+}
+
+pub struct Baz<'a, U: 'a, T>(T, &'a [U]);
+
+impl Bar {
+    // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAZ"]' \
+    //      "const BAZ: Baz<'static, u8, u32>"
+    pub const BAZ: Baz<'static, u8, u32> = Baz(321, &[1, 2, 3]);
+}
+
+pub fn f(_: &(ToString + 'static)) {}
+
+impl Bar {
+    // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \
+    //      "const F: fn(_: &(dyn ToString + 'static))"
+    pub const F: fn(_: &(ToString + 'static)) = f;
+}
+
+impl Bar {
+    // @!has assoc_consts/struct.Bar.html 'BAR_PRIVATE'
+    const BAR_PRIVATE: char = 'a';
+    // @!has assoc_consts/struct.Bar.html 'BAR_HIDDEN'
+    #[doc(hidden)]
+    pub const BAR_HIDDEN: &'static str = "a";
+}
+
+// @has assoc_consts/trait.Qux.html
+pub trait Qux {
+    // @has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8'
+    // @has - '//*[@class="docblock"]' "Docs for QUX0 in trait."
+    /// Docs for QUX0 in trait.
+    const QUX0: u8;
+    // @has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8'
+    // @has - '//*[@class="docblock"]' "Docs for QUX1 in trait."
+    /// Docs for QUX1 in trait.
+    const QUX1: i8;
+    // @has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16'
+    // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait."
+    /// Docs for QUX_DEFAULT12 in trait.
+    const QUX_DEFAULT0: u16 = 1;
+    // @has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16'
+    // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in trait."
+    /// Docs for QUX_DEFAULT1 in trait.
+    const QUX_DEFAULT1: i16 = 2;
+    // @has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32'
+    // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait."
+    /// Docs for QUX_DEFAULT2 in trait.
+    const QUX_DEFAULT2: u32 = 3;
+}
+
+// @has assoc_consts/struct.Bar.html '//code' 'impl Qux for Bar'
+impl Qux for Bar {
+    // @has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8'
+    // @has - '//*[@class="docblock"]' "Docs for QUX0 in trait."
+    /// Docs for QUX0 in trait.
+    const QUX0: u8 = 4;
+    // @has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8'
+    // @has - '//*[@class="docblock"]' "Docs for QUX1 in impl."
+    /// Docs for QUX1 in impl.
+    const QUX1: i8 = 5;
+    // @has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16'
+    // @has - '//*[@class="docblock hidden"]' "Docs for QUX_DEFAULT12 in trait."
+    const QUX_DEFAULT0: u16 = 6;
+    // @has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16'
+    // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl."
+    /// Docs for QUX_DEFAULT1 in impl.
+    const QUX_DEFAULT1: i16 = 7;
+    // @has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32'
+    // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait."
+}
diff --git a/src/test/rustdoc/assoc-item-cast.rs b/src/test/rustdoc/assoc-item-cast.rs
new file mode 100644
index 0000000..dc62fac
--- /dev/null
+++ b/src/test/rustdoc/assoc-item-cast.rs
@@ -0,0 +1,16 @@
+#![crate_name = "foo"]
+
+// ignore-tidy-linelength
+
+pub trait Expression {
+    type SqlType;
+}
+
+pub trait AsExpression<T> {
+    type Expression: Expression<SqlType = T>;
+    fn as_expression(self) -> Self::Expression;
+}
+
+// @has foo/type.AsExprOf.html
+// @has - '//*[@class="rust typedef"]' 'type AsExprOf<Item, Type> = <Item as AsExpression<Type>>::Expression;'
+pub type AsExprOf<Item, Type> = <Item as AsExpression<Type>>::Expression;
diff --git a/src/test/rustdoc/assoc-types.rs b/src/test/rustdoc/assoc-types.rs
new file mode 100644
index 0000000..b708dc0
--- /dev/null
+++ b/src/test/rustdoc/assoc-types.rs
@@ -0,0 +1,41 @@
+// ignore-tidy-linelength
+
+#![crate_type="lib"]
+
+// @has assoc_types/trait.Index.html
+pub trait Index<I: ?Sized> {
+    // @has - '//*[@id="associatedtype.Output"]//code' 'type Output: ?Sized'
+    // @has - '//code[@id="Output.t"]' 'type Output: ?Sized'
+    type Output: ?Sized;
+    // @has - '//code[@id="index.v"]' 'fn index'
+    // @has - '//*[@id="tymethod.index"]//code' \
+    //      "fn index<'a>(&'a self, index: I) -> &'a Self::Output"
+    // @has - '//*[@id="tymethod.index"]//code//a[@href="../assoc_types/trait.Index.html#associatedtype.Output"]' \
+    //      "Output"
+    fn index<'a>(&'a self, index: I) -> &'a Self::Output;
+}
+
+// @has assoc_types/fn.use_output.html
+// @has - '//*[@class="rust fn"]' '-> &T::Output'
+// @has - '//*[@class="rust fn"]//a[@href="../assoc_types/trait.Index.html#associatedtype.Output"]' 'Output'
+pub fn use_output<T: Index<usize>>(obj: &T, index: usize) -> &T::Output {
+    obj.index(index)
+}
+
+pub trait Feed {
+    type Input;
+}
+
+// @has assoc_types/fn.use_input.html
+// @has - '//*[@class="rust fn"]' 'T::Input'
+// @has - '//*[@class="rust fn"]//a[@href="../assoc_types/trait.Feed.html#associatedtype.Input"]' 'Input'
+pub fn use_input<T: Feed>(_feed: &T, _element: T::Input) { }
+
+// @has assoc_types/fn.cmp_input.html
+// @has - '//*[@class="rust fn"]' 'where T::Input: PartialEq<U::Input>'
+// @has - '//*[@class="rust fn"]//a[@href="../assoc_types/trait.Feed.html#associatedtype.Input"]' 'Input'
+pub fn cmp_input<T: Feed, U: Feed>(a: &T::Input, b: &U::Input) -> bool
+    where T::Input: PartialEq<U::Input>
+{
+    a == b
+}
diff --git a/src/test/rustdoc/async-fn.rs b/src/test/rustdoc/async-fn.rs
new file mode 100644
index 0000000..ba4997a
--- /dev/null
+++ b/src/test/rustdoc/async-fn.rs
@@ -0,0 +1,35 @@
+// edition:2018
+
+#![feature(async_await, futures_api)]
+
+// @has async_fn/fn.foo.html '//pre[@class="rust fn"]' 'pub async fn foo() -> Option<Foo>'
+pub async fn foo() -> Option<Foo> {
+    None
+}
+
+// @has async_fn/fn.bar.html '//pre[@class="rust fn"]' 'pub async fn bar(a: i32, b: i32) -> i32'
+pub async fn bar(a: i32, b: i32) -> i32 {
+    0
+}
+
+// @has async_fn/fn.baz.html '//pre[@class="rust fn"]' 'pub async fn baz<T>(a: T) -> T'
+pub async fn baz<T>(a: T) -> T {
+    a
+}
+
+trait Bar {}
+
+impl Bar for () {}
+
+// @has async_fn/fn.quux.html '//pre[@class="rust fn"]' 'pub async fn quux() -> impl Bar'
+pub async fn quux() -> impl Bar {
+    ()
+}
+
+// @has async_fn/struct.Foo.html
+// @matches - '//code' 'pub async fn f\(\)$'
+pub struct Foo;
+
+impl Foo {
+    pub async fn f() {}
+}
diff --git a/src/test/rustdoc/attributes.rs b/src/test/rustdoc/attributes.rs
new file mode 100644
index 0000000..eb0e3f0
--- /dev/null
+++ b/src/test/rustdoc/attributes.rs
@@ -0,0 +1,17 @@
+#![crate_name = "foo"]
+
+// @has foo/fn.f.html '//*[@class="docblock attributes"]' '#[no_mangle]'
+#[no_mangle]
+pub extern "C" fn f() {}
+
+// @has foo/fn.g.html '//*[@class="docblock attributes"]' '#[export_name = "bar"]'
+#[export_name = "bar"]
+pub extern "C" fn g() {}
+
+// @has foo/enum.Foo.html '//*[@class="docblock attributes"]' '#[repr(i64)]'
+// @has foo/enum.Foo.html '//*[@class="docblock attributes"]' '#[must_use]'
+#[repr(i64)]
+#[must_use]
+pub enum Foo {
+    Bar,
+}
diff --git a/src/test/rustdoc/auto-impl-for-trait.rs b/src/test/rustdoc/auto-impl-for-trait.rs
new file mode 100644
index 0000000..bc658fb
--- /dev/null
+++ b/src/test/rustdoc/auto-impl-for-trait.rs
@@ -0,0 +1,16 @@
+// Test for https://github.com/rust-lang/rust/issues/48463 issue.
+
+use std::any::Any;
+use std::ops::Deref;
+
+pub struct AnyValue {
+    val: Box<Any>,
+}
+
+impl Deref for AnyValue {
+    type Target = Any;
+
+    fn deref(&self) -> &Any {
+        &*self.val
+    }
+}
diff --git a/src/test/rustdoc/auto-impl-primitive.rs b/src/test/rustdoc/auto-impl-primitive.rs
new file mode 100644
index 0000000..83631b8
--- /dev/null
+++ b/src/test/rustdoc/auto-impl-primitive.rs
@@ -0,0 +1,7 @@
+#![crate_name = "foo"]
+pub use std::fs::File;
+
+// @has 'foo/primitive.i16.html' '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementation'
+#[doc(primitive = "i16")]
+/// I love poneys!
+mod prim {}
diff --git a/src/test/rustdoc/auto-traits.rs b/src/test/rustdoc/auto-traits.rs
new file mode 100644
index 0000000..a1fa611
--- /dev/null
+++ b/src/test/rustdoc/auto-traits.rs
@@ -0,0 +1,13 @@
+// aux-build:auto-traits.rs
+
+#![feature(optin_builtin_traits)]
+
+#![crate_name = "foo"]
+
+extern crate auto_traits;
+
+// @has 'foo/trait.Foo.html' '//pre' 'pub unsafe auto trait Foo'
+pub unsafe auto trait Foo {}
+
+// @has 'foo/trait.Bar.html' '//pre' 'pub unsafe auto trait Bar'
+pub use auto_traits::Bar;
diff --git a/src/test/rustdoc/auxiliary/all-item-types.rs b/src/test/rustdoc/auxiliary/all-item-types.rs
new file mode 100644
index 0000000..f94bd99
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/all-item-types.rs
@@ -0,0 +1,22 @@
+#![feature(extern_types)]
+
+pub mod foo_mod {}
+extern "C" {
+    pub fn foo_ffn();
+    pub static FOO_FSTATIC: FooStruct;
+    pub type FooFType;
+}
+pub fn foo_fn() {}
+pub trait FooTrait {}
+pub struct FooStruct;
+pub enum FooEnum {}
+pub union FooUnion {
+    x: (),
+}
+pub type FooType = FooStruct;
+pub static FOO_STATIC: FooStruct = FooStruct;
+pub const FOO_CONSTANT: FooStruct = FooStruct;
+#[macro_export]
+macro_rules! foo_macro {
+    () => ();
+}
diff --git a/src/test/rustdoc/auxiliary/auto-traits.rs b/src/test/rustdoc/auxiliary/auto-traits.rs
new file mode 100644
index 0000000..f522106
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/auto-traits.rs
@@ -0,0 +1,3 @@
+#![feature(optin_builtin_traits)]
+
+pub unsafe auto trait Bar {}
diff --git a/src/test/rustdoc/auxiliary/empty.rs b/src/test/rustdoc/auxiliary/empty.rs
new file mode 100644
index 0000000..d11c69f
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/empty.rs
@@ -0,0 +1 @@
+// intentionally empty
diff --git a/src/test/rustdoc/auxiliary/enum-primitive.rs b/src/test/rustdoc/auxiliary/enum-primitive.rs
new file mode 100644
index 0000000..ed1da25
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/enum-primitive.rs
@@ -0,0 +1,207 @@
+// Copyright (c) 2015 Anders Kaseorg <[email protected]>
+
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// “Software”), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+
+// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+//! This crate exports a macro `enum_from_primitive!` that wraps an
+//! `enum` declaration and automatically adds an implementation of
+//! `num::FromPrimitive` (reexported here), to allow conversion from
+//! primitive integers to the enum. It therefore provides an
+//! alternative to the built-in `#[derive(FromPrimitive)]`, which
+//! requires the unstable `std::num::FromPrimitive` and is disabled in
+//! Rust 1.0.
+//!
+//! # Example
+//!
+//! ```
+//! #[macro_use] extern crate enum_primitive;
+//! extern crate num_traits;
+//! use num_traits::FromPrimitive;
+//!
+//! enum_from_primitive! {
+//! #[derive(Debug, PartialEq)]
+//! enum FooBar {
+//!     Foo = 17,
+//!     Bar = 42,
+//!     Baz,
+//! }
+//! }
+//!
+//! fn main() {
+//!     assert_eq!(FooBar::from_i32(17), Some(FooBar::Foo));
+//!     assert_eq!(FooBar::from_i32(42), Some(FooBar::Bar));
+//!     assert_eq!(FooBar::from_i32(43), Some(FooBar::Baz));
+//!     assert_eq!(FooBar::from_i32(91), None);
+//! }
+//! ```
+
+pub mod num_traits {
+    pub trait FromPrimitive: Sized {
+        fn from_i64(n: i64) -> Option<Self>;
+        fn from_u64(n: u64) -> Option<Self>;
+    }
+}
+
+pub use std::option::Option;
+pub use num_traits::FromPrimitive;
+
+/// Helper macro for internal use by `enum_from_primitive!`.
+#[macro_export]
+macro_rules! enum_from_primitive_impl_ty {
+    ($meth:ident, $ty:ty, $name:ident, $( $variant:ident )*) => {
+        #[allow(non_upper_case_globals, unused)]
+        fn $meth(n: $ty) -> $crate::Option<Self> {
+            $( if n == $name::$variant as $ty {
+                $crate::Option::Some($name::$variant)
+            } else )* {
+                $crate::Option::None
+            }
+        }
+    };
+}
+
+/// Helper macro for internal use by `enum_from_primitive!`.
+#[macro_export]
+#[macro_use(enum_from_primitive_impl_ty)]
+macro_rules! enum_from_primitive_impl {
+    ($name:ident, $( $variant:ident )*) => {
+        impl $crate::FromPrimitive for $name {
+            enum_from_primitive_impl_ty! { from_i64, i64, $name, $( $variant )* }
+            enum_from_primitive_impl_ty! { from_u64, u64, $name, $( $variant )* }
+        }
+    };
+}
+
+/// Wrap this macro around an `enum` declaration to get an
+/// automatically generated implementation of `num::FromPrimitive`.
+#[macro_export]
+#[macro_use(enum_from_primitive_impl)]
+macro_rules! enum_from_primitive {
+    (
+        $( #[$enum_attr:meta] )*
+        enum $name:ident {
+            $( $( #[$variant_attr:meta] )* $variant:ident ),+
+            $( = $discriminator:expr, $( $( #[$variant_two_attr:meta] )* $variant_two:ident ),+ )*
+        }
+    ) => {
+        $( #[$enum_attr] )*
+        enum $name {
+            $( $( #[$variant_attr] )* $variant ),+
+            $( = $discriminator, $( $( #[$variant_two_attr] )* $variant_two ),+ )*
+        }
+        enum_from_primitive_impl! { $name, $( $variant )+ $( $( $variant_two )+ )* }
+    };
+
+    (
+        $( #[$enum_attr:meta] )*
+        enum $name:ident {
+            $( $( $( #[$variant_attr:meta] )* $variant:ident ),+ = $discriminator:expr ),*
+        }
+    ) => {
+        $( #[$enum_attr] )*
+        enum $name {
+            $( $( $( #[$variant_attr] )* $variant ),+ = $discriminator ),*
+        }
+        enum_from_primitive_impl! { $name, $( $( $variant )+ )* }
+    };
+
+    (
+        $( #[$enum_attr:meta] )*
+        enum $name:ident {
+            $( $( #[$variant_attr:meta] )* $variant:ident ),+
+            $( = $discriminator:expr, $( $( #[$variant_two_attr:meta] )* $variant_two:ident ),+ )*,
+        }
+    ) => {
+        $( #[$enum_attr] )*
+        enum $name {
+            $( $( #[$variant_attr] )* $variant ),+
+            $( = $discriminator, $( $( #[$variant_two_attr] )* $variant_two ),+ )*,
+        }
+        enum_from_primitive_impl! { $name, $( $variant )+ $( $( $variant_two )+ )* }
+    };
+
+    (
+        $( #[$enum_attr:meta] )*
+        enum $name:ident {
+            $( $( $( #[$variant_attr:meta] )* $variant:ident ),+ = $discriminator:expr ),+,
+        }
+    ) => {
+        $( #[$enum_attr] )*
+        enum $name {
+            $( $( $( #[$variant_attr] )* $variant ),+ = $discriminator ),+,
+        }
+        enum_from_primitive_impl! { $name, $( $( $variant )+ )+ }
+    };
+
+    (
+        $( #[$enum_attr:meta] )*
+        pub enum $name:ident {
+            $( $( #[$variant_attr:meta] )* $variant:ident ),+
+            $( = $discriminator:expr, $( $( #[$variant_two_attr:meta] )* $variant_two:ident ),+ )*
+        }
+    ) => {
+        $( #[$enum_attr] )*
+        pub enum $name {
+            $( $( #[$variant_attr] )* $variant ),+
+            $( = $discriminator, $( $( #[$variant_two_attr] )* $variant_two ),+ )*
+        }
+        enum_from_primitive_impl! { $name, $( $variant )+ $( $( $variant_two )+ )* }
+    };
+
+    (
+        $( #[$enum_attr:meta] )*
+        pub enum $name:ident {
+            $( $( $( #[$variant_attr:meta] )* $variant:ident ),+ = $discriminator:expr ),*
+        }
+    ) => {
+        $( #[$enum_attr] )*
+        pub enum $name {
+            $( $( $( #[$variant_attr] )* $variant ),+ = $discriminator ),*
+        }
+        enum_from_primitive_impl! { $name, $( $( $variant )+ )* }
+    };
+
+    (
+        $( #[$enum_attr:meta] )*
+        pub enum $name:ident {
+            $( $( #[$variant_attr:meta] )* $variant:ident ),+
+            $( = $discriminator:expr, $( $( #[$variant_two_attr:meta] )* $variant_two:ident ),+ )*,
+        }
+    ) => {
+        $( #[$enum_attr] )*
+        pub enum $name {
+            $( $( #[$variant_attr] )* $variant ),+
+            $( = $discriminator, $( $( #[$variant_two_attr] )* $variant_two ),+ )*,
+        }
+        enum_from_primitive_impl! { $name, $( $variant )+ $( $( $variant_two )+ )* }
+    };
+
+    (
+        $( #[$enum_attr:meta] )*
+        pub enum $name:ident {
+            $( $( $( #[$variant_attr:meta] )* $variant:ident ),+ = $discriminator:expr ),+,
+        }
+    ) => {
+        $( #[$enum_attr] )*
+        pub enum $name {
+            $( $( $( #[$variant_attr] )* $variant ),+ = $discriminator ),+,
+        }
+        enum_from_primitive_impl! { $name, $( $( $variant )+ )+ }
+    };
+}
diff --git a/src/test/rustdoc/auxiliary/extern-impl-trait.rs b/src/test/rustdoc/auxiliary/extern-impl-trait.rs
new file mode 100644
index 0000000..dbd5439
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/extern-impl-trait.rs
@@ -0,0 +1,27 @@
+pub trait Foo {
+    type Associated;
+}
+
+pub struct X;
+pub struct Y;
+
+
+impl Foo for X {
+    type Associated = ();
+}
+
+impl Foo for Y {
+    type Associated = ();
+}
+
+impl X {
+    pub fn returns_sized<'a>(&'a self) -> impl Foo<Associated=()> + 'a {
+        X
+    }
+}
+
+impl Y {
+    pub fn returns_unsized<'a>(&'a self) -> Box<impl ?Sized + Foo<Associated=()> + 'a> {
+        Box::new(X)
+    }
+}
diff --git a/src/test/rustdoc/auxiliary/extern-links.rs b/src/test/rustdoc/auxiliary/extern-links.rs
new file mode 100644
index 0000000..4a83567
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/extern-links.rs
@@ -0,0 +1 @@
+pub struct Foo;
diff --git a/src/test/rustdoc/auxiliary/external-cross-doc.md b/src/test/rustdoc/auxiliary/external-cross-doc.md
new file mode 100644
index 0000000..8b4e6ed
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/external-cross-doc.md
@@ -0,0 +1,4 @@
+# Cross-crate imported docs
+
+This file is to make sure `#[doc(include="file.md")]` works when you re-export an item with included
+docs.
diff --git a/src/test/rustdoc/auxiliary/external-cross.rs b/src/test/rustdoc/auxiliary/external-cross.rs
new file mode 100644
index 0000000..473d4ec
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/external-cross.rs
@@ -0,0 +1,5 @@
+#![feature(external_doc)]
+#![deny(missing_doc)]
+
+#[doc(include="external-cross-doc.md")]
+pub struct NeedMoreDocs;
diff --git a/src/test/rustdoc/auxiliary/external-doc.md b/src/test/rustdoc/auxiliary/external-doc.md
new file mode 100644
index 0000000..38478c1
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/external-doc.md
@@ -0,0 +1,3 @@
+# External Docs
+
+This file is here to test the `#[doc(include="file")]` attribute.
diff --git a/src/test/rustdoc/auxiliary/inline-default-methods.rs b/src/test/rustdoc/auxiliary/inline-default-methods.rs
new file mode 100644
index 0000000..8a636f4
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/inline-default-methods.rs
@@ -0,0 +1,6 @@
+// compile-flags: -Cmetadata=aux
+
+pub trait Foo {
+    fn bar(&self);
+    fn foo(&mut self) {}
+}
diff --git a/src/test/rustdoc/auxiliary/intra-link-extern-crate.rs b/src/test/rustdoc/auxiliary/intra-link-extern-crate.rs
new file mode 100644
index 0000000..db3bb38
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/intra-link-extern-crate.rs
@@ -0,0 +1,3 @@
+#![crate_name="inner"]
+
+//! ooh, i'm a rebel just for [kicks]
diff --git a/src/test/rustdoc/auxiliary/issue-13698.rs b/src/test/rustdoc/auxiliary/issue-13698.rs
new file mode 100644
index 0000000..a65ebfe
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-13698.rs
@@ -0,0 +1,8 @@
+// compile-flags: -Cmetadata=aux
+
+pub trait Foo {
+    #[doc(hidden)]
+    fn foo(&self) {}
+}
+
+impl Foo for i32 {}
diff --git a/src/test/rustdoc/auxiliary/issue-15318.rs b/src/test/rustdoc/auxiliary/issue-15318.rs
new file mode 100644
index 0000000..83cc31b
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-15318.rs
@@ -0,0 +1,7 @@
+// compile-flags: -Cmetadata=aux
+
+#![doc(html_root_url = "http://example.com/")]
+
+/// dox
+#[doc(primitive = "pointer")]
+pub mod ptr {}
diff --git a/src/test/rustdoc/auxiliary/issue-17476.rs b/src/test/rustdoc/auxiliary/issue-17476.rs
new file mode 100644
index 0000000..80c915e
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-17476.rs
@@ -0,0 +1,7 @@
+// compile-flags: -Cmetadata=aux
+
+#![doc(html_root_url = "http://example.com")]
+
+pub trait Foo {
+    fn foo(&self) {}
+}
diff --git a/src/test/rustdoc/auxiliary/issue-19190-3.rs b/src/test/rustdoc/auxiliary/issue-19190-3.rs
new file mode 100644
index 0000000..8c526a8
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-19190-3.rs
@@ -0,0 +1,23 @@
+// compile-flags: -Cmetadata=aux
+
+use std::ops::Deref;
+
+pub struct Foo;
+
+impl Deref for Foo {
+    type Target = String;
+    fn deref(&self) -> &String { loop {} }
+}
+
+pub struct Bar;
+pub struct Baz;
+
+impl Baz {
+    pub fn baz(&self) {}
+    pub fn static_baz() {}
+}
+
+impl Deref for Bar {
+    type Target = Baz;
+    fn deref(&self) -> &Baz { loop {} }
+}
diff --git a/src/test/rustdoc/auxiliary/issue-20646.rs b/src/test/rustdoc/auxiliary/issue-20646.rs
new file mode 100644
index 0000000..8e16f2d
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-20646.rs
@@ -0,0 +1,7 @@
+// compile-flags: -Cmetadata=aux
+
+pub trait Trait {
+    type Output;
+}
+
+pub fn fun<T>(_: T) where T: Trait<Output=i32> {}
diff --git a/src/test/rustdoc/auxiliary/issue-20727.rs b/src/test/rustdoc/auxiliary/issue-20727.rs
new file mode 100644
index 0000000..7ffc198
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-20727.rs
@@ -0,0 +1,30 @@
+// compile-flags: -Cmetadata=aux
+
+pub trait Deref {
+    type Target: ?Sized;
+
+    fn deref<'a>(&'a self) -> &'a Self::Target;
+}
+
+pub trait Add<RHS = Self> {
+    type Output;
+
+    fn add(self, rhs: RHS) -> Self::Output;
+}
+
+
+pub trait Bar {}
+pub trait Deref2 {
+    type Target: Bar;
+
+    fn deref(&self) -> Self::Target;
+}
+
+pub trait Index<Idx: ?Sized> {
+    type Output: ?Sized;
+    fn index(&self, index: Idx) -> &Self::Output;
+}
+
+pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
+    fn index_mut(&mut self, index: Idx) -> &mut Self::Output;
+}
diff --git a/src/test/rustdoc/auxiliary/issue-21092.rs b/src/test/rustdoc/auxiliary/issue-21092.rs
new file mode 100644
index 0000000..51ab7de
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-21092.rs
@@ -0,0 +1,12 @@
+// compile-flags: -Cmetadata=aux
+
+pub trait Foo {
+    type Bar;
+    fn foo(&self) {}
+}
+
+pub struct Bar;
+
+impl Foo for Bar {
+    type Bar = i32;
+}
diff --git a/src/test/rustdoc/auxiliary/issue-21801.rs b/src/test/rustdoc/auxiliary/issue-21801.rs
new file mode 100644
index 0000000..732612f
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-21801.rs
@@ -0,0 +1,9 @@
+// compile-flags: -Cmetadata=aux
+
+pub struct Foo;
+
+impl Foo {
+    pub fn new<F>(f: F) -> Foo where F: FnMut() -> i32 {
+        loop {}
+    }
+}
diff --git a/src/test/rustdoc/auxiliary/issue-22025.rs b/src/test/rustdoc/auxiliary/issue-22025.rs
new file mode 100644
index 0000000..5346c0e
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-22025.rs
@@ -0,0 +1,10 @@
+// compile-flags: -Cmetadata=aux
+
+pub mod foo {
+
+    pub trait Foo {}
+    pub struct Bar;
+
+    impl Foo for Bar {}
+
+}
diff --git a/src/test/rustdoc/auxiliary/issue-23207-1.rs b/src/test/rustdoc/auxiliary/issue-23207-1.rs
new file mode 100644
index 0000000..8531d5f
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-23207-1.rs
@@ -0,0 +1,3 @@
+pub mod fmt {
+    pub struct Error;
+}
diff --git a/src/test/rustdoc/auxiliary/issue-23207-2.rs b/src/test/rustdoc/auxiliary/issue-23207-2.rs
new file mode 100644
index 0000000..e1afb68
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-23207-2.rs
@@ -0,0 +1,6 @@
+extern crate issue_23207_1;
+
+pub mod fmt {
+    pub use issue_23207_1::fmt::Error;
+}
+
diff --git a/src/test/rustdoc/auxiliary/issue-26606-macro.rs b/src/test/rustdoc/auxiliary/issue-26606-macro.rs
new file mode 100644
index 0000000..d60d325
--- /dev/null
+++ b/src/test/rustdoc/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/src/test/rustdoc/auxiliary/issue-27362.rs b/src/test/rustdoc/auxiliary/issue-27362.rs
new file mode 100644
index 0000000..077bdc3
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-27362.rs
@@ -0,0 +1,10 @@
+// compile-flags: -Cmetadata=aux
+
+pub const fn foo() {}
+pub const unsafe fn bar() {}
+
+pub struct Foo;
+
+impl Foo {
+    pub const unsafe fn baz() {}
+}
diff --git a/src/test/rustdoc/auxiliary/issue-28927-1.rs b/src/test/rustdoc/auxiliary/issue-28927-1.rs
new file mode 100644
index 0000000..688c734
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-28927-1.rs
@@ -0,0 +1,4 @@
+mod detail {
+    pub extern crate issue_28927_2 as inner2;
+}
+pub use detail::inner2 as bar;
diff --git a/src/test/rustdoc/auxiliary/issue-28927-2.rs b/src/test/rustdoc/auxiliary/issue-28927-2.rs
new file mode 100644
index 0000000..7c0937f
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-28927-2.rs
@@ -0,0 +1 @@
+pub struct Baz;
diff --git a/src/test/rustdoc/auxiliary/issue-29584.rs b/src/test/rustdoc/auxiliary/issue-29584.rs
new file mode 100644
index 0000000..a9b8796
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-29584.rs
@@ -0,0 +1,10 @@
+// compile-flags: -Cmetadata=aux
+
+pub struct Foo;
+
+#[doc(hidden)]
+mod bar {
+    trait Bar {}
+
+    impl Bar for ::Foo {}
+}
diff --git a/src/test/rustdoc/auxiliary/issue-30109-1.rs b/src/test/rustdoc/auxiliary/issue-30109-1.rs
new file mode 100644
index 0000000..ca05a6a
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-30109-1.rs
@@ -0,0 +1 @@
+pub struct Bar;
diff --git a/src/test/rustdoc/auxiliary/issue-34274.rs b/src/test/rustdoc/auxiliary/issue-34274.rs
new file mode 100644
index 0000000..b0c3b4f
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-34274.rs
@@ -0,0 +1,3 @@
+extern {
+    pub fn extern_c_fn();
+}
diff --git a/src/test/rustdoc/auxiliary/issue-36031.rs b/src/test/rustdoc/auxiliary/issue-36031.rs
new file mode 100644
index 0000000..da68813
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-36031.rs
@@ -0,0 +1,9 @@
+pub trait Foo {
+    const FOO: usize;
+}
+
+pub struct Bar;
+
+impl Bar {
+    pub const BAR: usize = 3;
+}
diff --git a/src/test/rustdoc/auxiliary/issue-40936.rs b/src/test/rustdoc/auxiliary/issue-40936.rs
new file mode 100644
index 0000000..b921e52
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-40936.rs
@@ -0,0 +1,5 @@
+pub mod outermod {
+    pub mod innermod {
+        pub use super::*;
+    }
+}
diff --git a/src/test/rustdoc/auxiliary/issue-46727.rs b/src/test/rustdoc/auxiliary/issue-46727.rs
new file mode 100644
index 0000000..30dccfa
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-46727.rs
@@ -0,0 +1,7 @@
+// compile-flags: -Cmetadata=aux
+
+pub trait Foo {}
+
+pub struct Bar<T> { x: T }
+
+impl<T> Foo for Bar<[T; 1 + 1 + 1]> {}
diff --git a/src/test/rustdoc/auxiliary/issue-48414.rs b/src/test/rustdoc/auxiliary/issue-48414.rs
new file mode 100644
index 0000000..f442ac7
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-48414.rs
@@ -0,0 +1,5 @@
+/// Woah, this trait links to [OtherTrait](OtherTrait)!
+pub trait SomeTrait {}
+
+/// Woah, this trait links to [SomeTrait](SomeTrait)!
+pub trait OtherTrait {}
diff --git a/src/test/rustdoc/auxiliary/issue-53689.rs b/src/test/rustdoc/auxiliary/issue-53689.rs
new file mode 100644
index 0000000..5003c2c
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/issue-53689.rs
@@ -0,0 +1 @@
+pub struct MyStruct;
diff --git a/src/test/rustdoc/auxiliary/masked.rs b/src/test/rustdoc/auxiliary/masked.rs
new file mode 100644
index 0000000..f289359
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/masked.rs
@@ -0,0 +1,10 @@
+#[derive(Clone)]
+pub struct MaskedStruct;
+
+pub trait MaskedTrait {
+    fn masked_method();
+}
+
+impl MaskedTrait for String {
+    fn masked_method() {}
+}
diff --git a/src/test/rustdoc/auxiliary/mod-stackoverflow.rs b/src/test/rustdoc/auxiliary/mod-stackoverflow.rs
new file mode 100644
index 0000000..e0b90f1
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/mod-stackoverflow.rs
@@ -0,0 +1,11 @@
+// compile-flags: -Cmetadata=aux
+
+pub mod tree {
+    pub use tree;
+}
+
+pub mod tree2 {
+    pub mod prelude {
+        pub use tree2;
+    }
+}
diff --git a/src/test/rustdoc/auxiliary/pub-extern-crate.rs b/src/test/rustdoc/auxiliary/pub-extern-crate.rs
new file mode 100644
index 0000000..8c89c8d
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/pub-extern-crate.rs
@@ -0,0 +1,2 @@
+#![crate_name = "inner"]
+pub struct SomeStruct;
diff --git a/src/test/rustdoc/auxiliary/pub-use-extern-macros.rs b/src/test/rustdoc/auxiliary/pub-use-extern-macros.rs
new file mode 100644
index 0000000..7934e07
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/pub-use-extern-macros.rs
@@ -0,0 +1,21 @@
+#![crate_name="macros"]
+
+#[macro_export]
+macro_rules! foo {
+    () => {};
+}
+
+#[macro_export]
+macro_rules! bar {
+    () => {};
+}
+
+#[macro_export]
+macro_rules! baz {
+    () => {};
+}
+
+#[macro_export]
+macro_rules! quux {
+    () => {};
+}
diff --git a/src/test/rustdoc/auxiliary/reexp-stripped.rs b/src/test/rustdoc/auxiliary/reexp-stripped.rs
new file mode 100644
index 0000000..ccc3dc1
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/reexp-stripped.rs
@@ -0,0 +1,11 @@
+pub use private::Quz;
+pub use hidden::Bar;
+
+mod private {
+    pub struct Quz;
+}
+
+#[doc(hidden)]
+pub mod hidden {
+    pub struct Bar;
+}
diff --git a/src/test/rustdoc/auxiliary/rustdoc-default-impl.rs b/src/test/rustdoc/auxiliary/rustdoc-default-impl.rs
new file mode 100644
index 0000000..36e2821
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/rustdoc-default-impl.rs
@@ -0,0 +1,23 @@
+#![feature(optin_builtin_traits)]
+
+pub mod bar {
+    use std::marker;
+
+    pub auto trait Bar {}
+
+    pub trait Foo {
+        fn foo(&self) {}
+    }
+
+    impl Foo {
+        pub fn test<T: Bar>(&self) {}
+    }
+
+    pub struct TypeId;
+
+    impl TypeId {
+        pub fn of<T: Bar + ?Sized>() -> TypeId {
+            panic!()
+        }
+    }
+}
diff --git a/src/test/rustdoc/auxiliary/rustdoc-extern-default-method.rs b/src/test/rustdoc/auxiliary/rustdoc-extern-default-method.rs
new file mode 100644
index 0000000..1293423
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/rustdoc-extern-default-method.rs
@@ -0,0 +1,11 @@
+#![crate_type="lib"]
+
+pub trait Trait {
+    fn provided(&self) {}
+}
+
+pub struct Struct;
+
+impl Trait for Struct {
+    fn provided(&self) {}
+}
diff --git a/src/test/rustdoc/auxiliary/rustdoc-extern-method.rs b/src/test/rustdoc/auxiliary/rustdoc-extern-method.rs
new file mode 100644
index 0000000..e493048
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/rustdoc-extern-method.rs
@@ -0,0 +1,7 @@
+#![crate_type="lib"]
+#![feature(unboxed_closures)]
+
+pub trait Foo {
+    extern "rust-call" fn foo(&self, _: ()) -> i32;
+    extern "rust-call" fn foo_(&self, _: ()) -> i32 { 0 }
+}
diff --git a/src/test/rustdoc/auxiliary/rustdoc-ffi.rs b/src/test/rustdoc/auxiliary/rustdoc-ffi.rs
new file mode 100644
index 0000000..b74d190
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/rustdoc-ffi.rs
@@ -0,0 +1,6 @@
+#![crate_type="lib"]
+
+extern "C" {
+    // @has lib/fn.foreigner.html //pre 'pub unsafe fn foreigner(cold_as_ice: u32)'
+    pub fn foreigner(cold_as_ice: u32);
+}
diff --git a/src/test/rustdoc/auxiliary/rustdoc-impl-parts-crosscrate.rs b/src/test/rustdoc/auxiliary/rustdoc-impl-parts-crosscrate.rs
new file mode 100644
index 0000000..869aebc
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/rustdoc-impl-parts-crosscrate.rs
@@ -0,0 +1,3 @@
+#![feature(optin_builtin_traits)]
+
+pub auto trait AnOibit {}
diff --git a/src/test/rustdoc/auxiliary/src-links-external.rs b/src/test/rustdoc/auxiliary/src-links-external.rs
new file mode 100644
index 0000000..4a83567
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/src-links-external.rs
@@ -0,0 +1 @@
+pub struct Foo;
diff --git a/src/test/rustdoc/auxiliary/unit-return.rs b/src/test/rustdoc/auxiliary/unit-return.rs
new file mode 100644
index 0000000..7b99861
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/unit-return.rs
@@ -0,0 +1,3 @@
+pub fn f2<F: FnMut(u32) + Clone>(f: F) {}
+
+pub fn f3<F: FnMut(u64) -> () + Clone>(f: F) {}
diff --git a/src/test/rustdoc/auxiliary/variant-struct.rs b/src/test/rustdoc/auxiliary/variant-struct.rs
new file mode 100644
index 0000000..0f3d2e5
--- /dev/null
+++ b/src/test/rustdoc/auxiliary/variant-struct.rs
@@ -0,0 +1,5 @@
+pub enum Foo {
+    Bar {
+        qux: (),
+    }
+}
diff --git a/src/test/rustdoc/bad-codeblock-syntax.rs b/src/test/rustdoc/bad-codeblock-syntax.rs
new file mode 100644
index 0000000..0ab2f68
--- /dev/null
+++ b/src/test/rustdoc/bad-codeblock-syntax.rs
@@ -0,0 +1,27 @@
+// @has bad_codeblock_syntax/fn.foo.html
+// @has - '//*[@class="docblock"]/pre/code' '\_'
+/// ```
+/// \_
+/// ```
+pub fn foo() {}
+
+// @has bad_codeblock_syntax/fn.bar.html
+// @has - '//*[@class="docblock"]/pre/code' '`baz::foobar`'
+/// ```
+/// `baz::foobar`
+/// ```
+pub fn bar() {}
+
+// @has bad_codeblock_syntax/fn.quux.html
+// @has - '//*[@class="docblock"]/pre/code' '\_'
+/// ```rust
+/// \_
+/// ```
+pub fn quux() {}
+
+// @has bad_codeblock_syntax/fn.ok.html
+// @has - '//*[@class="docblock"]/pre/code[@class="language-text"]' '\_'
+/// ```text
+/// \_
+/// ```
+pub fn ok() {}
diff --git a/src/test/rustdoc/blanket-reexport-item.rs b/src/test/rustdoc/blanket-reexport-item.rs
new file mode 100644
index 0000000..a1db90d
--- /dev/null
+++ b/src/test/rustdoc/blanket-reexport-item.rs
@@ -0,0 +1,8 @@
+#![crate_name = "foo"]
+
+// @has foo/struct.S.html '//h3[@id="impl-Into"]//code' 'impl<T, U> Into for T'
+pub struct S2 {}
+mod m {
+    pub struct S {}
+}
+pub use m::*;
diff --git a/src/test/rustdoc/cap-lints.rs b/src/test/rustdoc/cap-lints.rs
new file mode 100644
index 0000000..b66f756
--- /dev/null
+++ b/src/test/rustdoc/cap-lints.rs
@@ -0,0 +1,10 @@
+// This should fail a normal compile due to non_camel_case_types,
+// It should pass a doc-compile as it only needs to type-check and
+// therefore should not concern itself with the lints.
+#[deny(warnings)]
+
+// @has cap_lints/struct.Foo.html //pre '#[must_use]'
+#[must_use]
+pub struct Foo {
+    field: i32,
+}
diff --git a/src/test/rustdoc/check-styled-link.rs b/src/test/rustdoc/check-styled-link.rs
new file mode 100644
index 0000000..b479820
--- /dev/null
+++ b/src/test/rustdoc/check-styled-link.rs
@@ -0,0 +1,8 @@
+#![crate_name = "foo"]
+
+pub struct Foo;
+
+// @has foo/struct.Bar.html '//a[@href="../foo/struct.Foo.html"]' 'Foo'
+
+/// Code-styled reference to [`Foo`].
+pub struct Bar;
diff --git a/src/test/rustdoc/codeblock-title.rs b/src/test/rustdoc/codeblock-title.rs
new file mode 100644
index 0000000..2f77929
--- /dev/null
+++ b/src/test/rustdoc/codeblock-title.rs
@@ -0,0 +1,21 @@
+#![crate_name = "foo"]
+
+// ignore-tidy-linelength
+
+// @has foo/fn.bar.html '//*[@class="tooltip compile_fail"]/span' "This example deliberately fails to compile"
+// @has foo/fn.bar.html '//*[@class="tooltip ignore"]/span' "This example is not tested"
+
+/// foo
+///
+/// ```compile_fail
+/// foo();
+/// ```
+///
+/// ```ignore (tidy)
+/// goo();
+/// ```
+///
+/// ```
+/// let x = 0;
+/// ```
+pub fn bar() -> usize { 2 }
diff --git a/src/test/rustdoc/comment-in-doctest.rs b/src/test/rustdoc/comment-in-doctest.rs
new file mode 100644
index 0000000..e4e41bc
--- /dev/null
+++ b/src/test/rustdoc/comment-in-doctest.rs
@@ -0,0 +1,20 @@
+// compile-flags:--test
+
+// comments, both doc comments and regular ones, used to trick rustdoc's doctest parser into
+// thinking that everything after it was part of the regular program. combined with the libsyntax
+// parser loop failing to detect the manual main function, it would wrap everything in `fn main`,
+// which would cause the doctest to fail as the "extern crate" declaration was no longer valid.
+// oddly enough, it would pass in 2018 if a crate was in the extern prelude. see
+// https://github.com/rust-lang/rust/issues/56727
+
+//! ```
+//! // crate: proc-macro-test
+//! //! this is a test
+//!
+//! // used to pull in proc-macro specific items
+//! extern crate proc_macro;
+//!
+//! use proc_macro::TokenStream;
+//!
+//! # fn main() {}
+//! ```
diff --git a/src/test/rustdoc/const-display.rs b/src/test/rustdoc/const-display.rs
new file mode 100644
index 0000000..9df0368
--- /dev/null
+++ b/src/test/rustdoc/const-display.rs
@@ -0,0 +1,32 @@
+#![crate_name = "foo"]
+
+#![unstable(feature = "humans",
+            reason = "who ever let humans program computers, we're apparently really bad at it",
+            issue = "0")]
+
+#![feature(rustc_const_unstable, const_fn, foo, foo2)]
+#![feature(staged_api)]
+
+// @has 'foo/fn.foo.html' '//pre' 'pub unsafe fn foo() -> u32'
+#[stable(feature = "rust1", since = "1.0.0")]
+#[rustc_const_unstable(feature="foo")]
+pub const unsafe fn foo() -> u32 { 42 }
+
+// @has 'foo/fn.foo2.html' '//pre' 'pub fn foo2() -> u32'
+#[unstable(feature = "humans", issue="0")]
+pub const fn foo2() -> u32 { 42 }
+
+// @has 'foo/fn.bar2.html' '//pre' 'pub const fn bar2() -> u32'
+#[stable(feature = "rust1", since = "1.0.0")]
+pub const fn bar2() -> u32 { 42 }
+
+// @has 'foo/fn.foo2_gated.html' '//pre' 'pub unsafe fn foo2_gated() -> u32'
+#[unstable(feature = "foo2", issue="0")]
+pub const unsafe fn foo2_gated() -> u32 { 42 }
+
+// @has 'foo/fn.bar2_gated.html' '//pre' 'pub const unsafe fn bar2_gated() -> u32'
+#[stable(feature = "rust1", since = "1.0.0")]
+pub const unsafe fn bar2_gated() -> u32 { 42 }
+
+// @has 'foo/fn.bar_not_gated.html' '//pre' 'pub unsafe fn bar_not_gated() -> u32'
+pub const unsafe fn bar_not_gated() -> u32 { 42 }
diff --git a/src/test/rustdoc/const-doc.rs b/src/test/rustdoc/const-doc.rs
new file mode 100644
index 0000000..74ab4af
--- /dev/null
+++ b/src/test/rustdoc/const-doc.rs
@@ -0,0 +1,19 @@
+use std::marker::PhantomData;
+
+pub struct Foo<'a> {
+    f: PhantomData<&'a u32>,
+}
+
+pub struct ContentType {
+    pub ttype: Foo<'static>,
+    pub subtype: Foo<'static>,
+    pub params: Option<Foo<'static>>,
+}
+
+impl ContentType {
+    // @has const_doc/struct.ContentType.html
+    // @has  - '//*[@id="associatedconstant.Any"]' 'const Any: ContentType'
+    pub const Any: ContentType = ContentType { ttype: Foo { f: PhantomData, },
+                                               subtype: Foo { f: PhantomData, },
+                                               params: None, };
+}
diff --git a/src/test/rustdoc/const-evalutation-ice.rs b/src/test/rustdoc/const-evalutation-ice.rs
new file mode 100644
index 0000000..68c7f9c
--- /dev/null
+++ b/src/test/rustdoc/const-evalutation-ice.rs
@@ -0,0 +1,10 @@
+// Just check we don't get an ICE for `N`.
+
+use std::cell::Cell;
+use std::mem;
+
+pub struct S {
+    s: Cell<usize>
+}
+
+pub const N: usize = 0 - (mem::size_of::<S>() != 4) as usize;
diff --git a/src/test/rustdoc/const-fn.rs b/src/test/rustdoc/const-fn.rs
new file mode 100644
index 0000000..9ea7343
--- /dev/null
+++ b/src/test/rustdoc/const-fn.rs
@@ -0,0 +1,16 @@
+#![crate_name = "foo"]
+
+// @has foo/fn.bar.html
+// @has - '//*[@class="rust fn"]' 'pub const fn bar() -> '
+/// foo
+pub const fn bar() -> usize {
+    2
+}
+
+// @has foo/struct.Foo.html
+// @has - '//*[@class="method"]' 'const fn new()'
+pub struct Foo(usize);
+
+impl Foo {
+    pub const fn new() -> Foo { Foo(0) }
+}
diff --git a/src/test/rustdoc/const.rs b/src/test/rustdoc/const.rs
new file mode 100644
index 0000000..c33db58
--- /dev/null
+++ b/src/test/rustdoc/const.rs
@@ -0,0 +1,10 @@
+#![crate_type="lib"]
+
+pub struct Foo;
+
+impl Foo {
+    // @has const/struct.Foo.html '//code[@id="new.v"]' 'const unsafe fn new'
+    pub const unsafe fn new() -> Foo {
+        Foo
+    }
+}
diff --git a/src/test/rustdoc/constructor-imports.rs b/src/test/rustdoc/constructor-imports.rs
new file mode 100644
index 0000000..26795c2
--- /dev/null
+++ b/src/test/rustdoc/constructor-imports.rs
@@ -0,0 +1,15 @@
+#![crate_name = "foo"]
+
+pub mod a {
+    pub struct Foo;
+    pub enum Bar {
+        Baz,
+    }
+}
+
+// @count 'foo/index.html' '//*[code="pub use a::Foo;"]' 1
+#[doc(no_inline)]
+pub use a::Foo;
+// @count 'foo/index.html' '//*[code="pub use a::Bar::Baz;"]' 1
+#[doc(no_inline)]
+pub use a::Bar::Baz;
diff --git a/src/test/rustdoc/crate-version.rs b/src/test/rustdoc/crate-version.rs
new file mode 100644
index 0000000..9ea84ac
--- /dev/null
+++ b/src/test/rustdoc/crate-version.rs
@@ -0,0 +1,3 @@
+// compile-flags: --crate-version=1.3.37 -Z unstable-options
+
+// @has 'crate_version/index.html' '//div[@class="block version"]/p' 'Version 1.3.37'
diff --git a/src/test/rustdoc/cross-crate-links.rs b/src/test/rustdoc/cross-crate-links.rs
new file mode 100644
index 0000000..7c736a4
--- /dev/null
+++ b/src/test/rustdoc/cross-crate-links.rs
@@ -0,0 +1,59 @@
+// aux-build:all-item-types.rs
+// build-aux-docs
+
+#![crate_name = "foo"]
+
+#[macro_use]
+extern crate all_item_types;
+
+// @has 'foo/index.html' '//a[@href="../all_item_types/foo_mod/index.html"]' 'foo_mod'
+#[doc(no_inline)]
+pub use all_item_types::foo_mod;
+
+// @has 'foo/index.html' '//a[@href="../all_item_types/fn.foo_ffn.html"]' 'foo_ffn'
+#[doc(no_inline)]
+pub use all_item_types::foo_ffn;
+
+// @has 'foo/index.html' '//a[@href="../all_item_types/static.FOO_FSTATIC.html"]' 'FOO_FSTATIC'
+#[doc(no_inline)]
+pub use all_item_types::FOO_FSTATIC;
+
+// @has 'foo/index.html' '//a[@href="../all_item_types/foreigntype.FooFType.html"]' 'FooFType'
+#[doc(no_inline)]
+pub use all_item_types::FooFType;
+
+// @has 'foo/index.html' '//a[@href="../all_item_types/fn.foo_fn.html"]' 'foo_fn'
+#[doc(no_inline)]
+pub use all_item_types::foo_fn;
+
+// @has 'foo/index.html' '//a[@href="../all_item_types/trait.FooTrait.html"]' 'FooTrait'
+#[doc(no_inline)]
+pub use all_item_types::FooTrait;
+
+// @has 'foo/index.html' '//a[@href="../all_item_types/struct.FooStruct.html"]' 'FooStruct'
+#[doc(no_inline)]
+pub use all_item_types::FooStruct;
+
+// @has 'foo/index.html' '//a[@href="../all_item_types/enum.FooEnum.html"]' 'FooEnum'
+#[doc(no_inline)]
+pub use all_item_types::FooEnum;
+
+// @has 'foo/index.html' '//a[@href="../all_item_types/union.FooUnion.html"]' 'FooUnion'
+#[doc(no_inline)]
+pub use all_item_types::FooUnion;
+
+// @has 'foo/index.html' '//a[@href="../all_item_types/type.FooType.html"]' 'FooType'
+#[doc(no_inline)]
+pub use all_item_types::FooType;
+
+// @has 'foo/index.html' '//a[@href="../all_item_types/static.FOO_STATIC.html"]' 'FOO_STATIC'
+#[doc(no_inline)]
+pub use all_item_types::FOO_STATIC;
+
+// @has 'foo/index.html' '//a[@href="../all_item_types/constant.FOO_CONSTANT.html"]' 'FOO_CONSTANT'
+#[doc(no_inline)]
+pub use all_item_types::FOO_CONSTANT;
+
+// @has 'foo/index.html' '//a[@href="../all_item_types/macro.foo_macro.html"]' 'foo_macro'
+#[doc(no_inline)]
+pub use all_item_types::foo_macro;
diff --git a/src/test/rustdoc/default-impl.rs b/src/test/rustdoc/default-impl.rs
new file mode 100644
index 0000000..f11b3b2
--- /dev/null
+++ b/src/test/rustdoc/default-impl.rs
@@ -0,0 +1,9 @@
+// aux-build:rustdoc-default-impl.rs
+// ignore-cross-compile
+
+extern crate rustdoc_default_impl as foo;
+
+pub use foo::bar;
+
+pub fn wut<T: bar::Bar>() {
+}
diff --git a/src/test/rustdoc/default-trait-method-link.rs b/src/test/rustdoc/default-trait-method-link.rs
new file mode 100644
index 0000000..e4f0bda
--- /dev/null
+++ b/src/test/rustdoc/default-trait-method-link.rs
@@ -0,0 +1,15 @@
+#![crate_name = "foo"]
+
+// @has foo/trait.Foo.html '//a[@href="../foo/trait.Foo.html#tymethod.req"]' 'req'
+// @has foo/trait.Foo.html '//a[@href="../foo/trait.Foo.html#method.prov"]' 'prov'
+
+/// Always make sure to implement [`req`], but you don't have to implement [`prov`].
+///
+/// [`req`]: Foo::req
+/// [`prov`]: Foo::prov
+pub trait Foo {
+    /// Required
+    fn req();
+    /// Provided
+    fn prov() {}
+}
diff --git a/src/test/rustdoc/default-trait-method.rs b/src/test/rustdoc/default-trait-method.rs
new file mode 100644
index 0000000..3d6ebef
--- /dev/null
+++ b/src/test/rustdoc/default-trait-method.rs
@@ -0,0 +1,26 @@
+#![feature(specialization)]
+
+// @has default_trait_method/trait.Item.html
+// @has - '//*[@id="tymethod.foo"]' 'fn foo()'
+// @!has - '//*[@id="tymethod.foo"]' 'default fn foo()'
+// @has - '//*[@id="tymethod.bar"]' 'fn bar()'
+// @!has - '//*[@id="tymethod.bar"]' 'default fn bar()'
+// @has - '//*[@id="method.baz"]' 'fn baz()'
+// @!has - '//*[@id="method.baz"]' 'default fn baz()'
+pub trait Item {
+    fn foo();
+    fn bar();
+    fn baz() {}
+}
+
+// @has default_trait_method/struct.Foo.html
+// @has - '//*[@id="method.foo"]' 'default fn foo()'
+// @has - '//*[@id="method.bar"]' 'fn bar()'
+// @!has - '//*[@id="method.bar"]' 'default fn bar()'
+// @has - '//*[@id="method.baz"]' 'fn baz()'
+// @!has - '//*[@id="method.baz"]' 'default fn baz()'
+pub struct Foo;
+impl Item for Foo {
+    default fn foo() {}
+    fn bar() {}
+}
diff --git a/src/test/rustdoc/deprecated-future.rs b/src/test/rustdoc/deprecated-future.rs
new file mode 100644
index 0000000..c5248c5
--- /dev/null
+++ b/src/test/rustdoc/deprecated-future.rs
@@ -0,0 +1,8 @@
+#![feature(deprecated)]
+
+// @has deprecated_future/index.html '//*[@class="stab deprecated"]' \
+//      'Deprecated'
+// @has deprecated_future/struct.S.html '//*[@class="stab deprecated"]' \
+//      'Deprecated since 99.99.99: effectively never'
+#[deprecated(since = "99.99.99", note = "effectively never")]
+pub struct S;
diff --git a/src/test/rustdoc/deprecated-impls.rs b/src/test/rustdoc/deprecated-impls.rs
new file mode 100644
index 0000000..efd250c
--- /dev/null
+++ b/src/test/rustdoc/deprecated-impls.rs
@@ -0,0 +1,118 @@
+#![crate_name = "foo"]
+
+// @has foo/struct.Foo0.html
+pub struct Foo0;
+
+impl Foo0 {
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.1: fn_with_doc'
+    // @has - 'fn_with_doc short'
+    // @has - 'fn_with_doc full'
+    /// fn_with_doc short
+    ///
+    /// fn_with_doc full
+    #[deprecated(since = "1.0.1", note = "fn_with_doc")]
+    pub fn fn_with_doc() {}
+
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.2: fn_without_doc'
+    #[deprecated(since = "1.0.2", note = "fn_without_doc")]
+    pub fn fn_without_doc() {}
+}
+
+pub trait Bar {
+    /// fn_empty_with_doc short
+    ///
+    /// fn_empty_with_doc full
+    #[deprecated(since = "1.0.3", note = "fn_empty_with_doc")]
+    fn fn_empty_with_doc();
+
+    #[deprecated(since = "1.0.4", note = "fn_empty_without_doc")]
+    fn fn_empty_without_doc();
+
+    /// fn_def_with_doc short
+    ///
+    /// fn_def_with_doc full
+    #[deprecated(since = "1.0.5", note = "fn_def_with_doc")]
+    fn fn_def_with_doc() {}
+
+    #[deprecated(since = "1.0.6", note = "fn_def_without_doc")]
+    fn fn_def_without_doc() {}
+
+    /// fn_def_def_with_doc short
+    ///
+    /// fn_def_def_with_doc full
+    #[deprecated(since = "1.0.7", note = "fn_def_def_with_doc")]
+    fn fn_def_def_with_doc() {}
+
+    #[deprecated(since = "1.0.8", note = "fn_def_def_without_doc")]
+    fn fn_def_def_without_doc() {}
+}
+
+// @has foo/struct.Foo1.html
+pub struct Foo1;
+
+impl Bar for Foo1 {
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc'
+    // @has - 'fn_empty_with_doc_impl short'
+    // @has - 'fn_empty_with_doc_impl full'
+    /// fn_empty_with_doc_impl short
+    ///
+    /// fn_empty_with_doc_impl full
+    fn fn_empty_with_doc() {}
+
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc'
+    fn fn_empty_without_doc() {}
+
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc'
+    // @has - 'fn_def_with_doc_impl short'
+    // @has - 'fn_def_with_doc_impl full'
+    /// fn_def_with_doc_impl short
+    ///
+    /// fn_def_with_doc_impl full
+    fn fn_def_with_doc() {}
+
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc'
+    fn fn_def_without_doc() {}
+
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc'
+    // @has - 'fn_def_def_with_doc short'
+    // @!has - 'fn_def_def_with_doc full'
+
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc'
+}
+
+// @has foo/struct.Foo2.html
+pub struct Foo2;
+
+impl Bar for Foo2 {
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc'
+    // @has - 'fn_empty_with_doc short'
+    // @!has - 'fn_empty_with_doc full'
+    fn fn_empty_with_doc() {}
+
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc'
+    // @has - 'fn_empty_without_doc_impl short'
+    // @has - 'fn_empty_without_doc_impl full'
+    /// fn_empty_without_doc_impl short
+    ///
+    /// fn_empty_without_doc_impl full
+    fn fn_empty_without_doc() {}
+
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc'
+    // @has - 'fn_def_with_doc short'
+    // @!has - 'fn_def_with_doc full'
+    fn fn_def_with_doc() {}
+
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc'
+    // @has - 'fn_def_without_doc_impl short'
+    // @has - 'fn_def_without_doc_impl full'
+    /// fn_def_without_doc_impl short
+    ///
+    /// fn_def_without_doc_impl full
+    fn fn_def_without_doc() {}
+
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc'
+    // @has - 'fn_def_def_with_doc short'
+    // @!has - 'fn_def_def_with_doc full'
+
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc'
+}
diff --git a/src/test/rustdoc/deprecated.rs b/src/test/rustdoc/deprecated.rs
new file mode 100644
index 0000000..18a3343
--- /dev/null
+++ b/src/test/rustdoc/deprecated.rs
@@ -0,0 +1,35 @@
+#![feature(deprecated)]
+
+// @has deprecated/index.html '//*[@class="docblock-short"]/span[@class="stab deprecated"]' \
+//      'Deprecated'
+// @has - '//*[@class="docblock-short"]' 'Deprecated docs'
+
+// @has deprecated/struct.S.html '//*[@class="stab deprecated"]' \
+//      'Deprecated since 1.0.0: text'
+/// Deprecated docs
+#[deprecated(since = "1.0.0", note = "text")]
+pub struct S;
+
+// @matches deprecated/index.html '//*[@class="docblock-short"]' '^Docs'
+/// Docs
+pub struct T;
+
+// @matches deprecated/struct.U.html '//*[@class="stab deprecated"]' \
+//      'Deprecated since 1.0.0$'
+#[deprecated(since = "1.0.0")]
+pub struct U;
+
+// @matches deprecated/struct.V.html '//*[@class="stab deprecated"]' \
+//      'Deprecated: text$'
+#[deprecated(note = "text")]
+pub struct V;
+
+// @matches deprecated/struct.W.html '//*[@class="stab deprecated"]' \
+//      'Deprecated$'
+#[deprecated]
+pub struct W;
+
+// @matches deprecated/struct.X.html '//*[@class="stab deprecated"]' \
+//      'Deprecated: shorthand reason$'
+#[deprecated = "shorthand reason"]
+pub struct X;
diff --git a/src/test/rustdoc/doc-assoc-item.rs b/src/test/rustdoc/doc-assoc-item.rs
new file mode 100644
index 0000000..4d5c9f8
--- /dev/null
+++ b/src/test/rustdoc/doc-assoc-item.rs
@@ -0,0 +1,18 @@
+pub struct Foo<T> {
+    x: T,
+}
+
+pub trait Bar {
+    type Fuu;
+
+    fn foo(foo: Self::Fuu);
+}
+
+// @has doc_assoc_item/struct.Foo.html '//*[@class="impl"]' 'impl<T: Bar<Fuu = u32>> Foo<T>'
+impl<T: Bar<Fuu = u32>> Foo<T> {
+    pub fn new(t: T) -> Foo<T> {
+        Foo {
+            x: t,
+        }
+    }
+}
diff --git a/src/test/rustdoc/doc-cfg-target-feature.rs b/src/test/rustdoc/doc-cfg-target-feature.rs
new file mode 100644
index 0000000..f1b000d
--- /dev/null
+++ b/src/test/rustdoc/doc-cfg-target-feature.rs
@@ -0,0 +1,21 @@
+// only-x86_64
+// compile-flags:--test
+// should-fail
+// no-system-llvm
+
+// #49723: rustdoc didn't add target features when extracting or running doctests
+
+#![feature(doc_cfg)]
+
+/// Foo
+///
+/// # Examples
+///
+/// ```
+/// #![feature(cfg_target_feature)]
+///
+/// #[cfg(target_feature = "sse")]
+/// assert!(false);
+/// ```
+#[doc(cfg(target_feature = "sse"))]
+pub unsafe fn foo() {}
diff --git a/src/test/rustdoc/doc-cfg.rs b/src/test/rustdoc/doc-cfg.rs
new file mode 100644
index 0000000..aa407b7
--- /dev/null
+++ b/src/test/rustdoc/doc-cfg.rs
@@ -0,0 +1,61 @@
+#![feature(doc_cfg)]
+#![feature(target_feature, cfg_target_feature)]
+
+// @has doc_cfg/struct.Portable.html
+// @!has - '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' ''
+// @has - '//*[@id="method.unix_and_arm_only_function"]' 'fn unix_and_arm_only_function()'
+// @has - '//*[@class="stab portability"]' 'This is supported on Unix and ARM only.'
+pub struct Portable;
+
+// @has doc_cfg/unix_only/index.html \
+//  '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
+//  'This is supported on Unix only.'
+// @matches - '//*[@class="module-item"]//*[@class="stab portability"]' '\AUnix\Z'
+// @matches - '//*[@class="module-item"]//*[@class="stab portability"]' '\AUnix and ARM\Z'
+// @count - '//*[@class="stab portability"]' 3
+#[doc(cfg(unix))]
+pub mod unix_only {
+    // @has doc_cfg/unix_only/fn.unix_only_function.html \
+    //  '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
+    //  'This is supported on Unix only.'
+    // @count - '//*[@class="stab portability"]' 1
+    pub fn unix_only_function() {
+        content::should::be::irrelevant();
+    }
+
+    // @has doc_cfg/unix_only/trait.ArmOnly.html \
+    //  '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
+    //  'This is supported on Unix and ARM only.'
+    // @count - '//*[@class="stab portability"]' 3
+    #[doc(cfg(target_arch = "arm"))]
+    pub trait ArmOnly {
+        fn unix_and_arm_only_function();
+    }
+
+    impl ArmOnly for super::Portable {
+        fn unix_and_arm_only_function() {}
+    }
+}
+
+// tagging a function with `#[target_feature]` creates a doc(cfg(target_feature)) node for that
+// item as well
+
+// the portability header is different on the module view versus the full view
+// @has doc_cfg/index.html
+// @matches - '//*[@class="module-item"]//*[@class="stab portability"]' '\Aavx\Z'
+
+// @has doc_cfg/fn.uses_target_feature.html
+// @has - '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
+//        'This is supported with target feature avx only.'
+#[target_feature(enable = "avx")]
+pub unsafe fn uses_target_feature() {
+    content::should::be::irrelevant();
+}
+
+// @has doc_cfg/fn.uses_cfg_target_feature.html
+// @has - '//*[@id="main"]/*[@class="stability"]/*[@class="stab portability"]' \
+//        'This is supported with target feature avx only.'
+#[doc(cfg(target_feature = "avx"))]
+pub fn uses_cfg_target_feature() {
+    uses_target_feature();
+}
diff --git a/src/test/rustdoc/doc-proc-macro.rs b/src/test/rustdoc/doc-proc-macro.rs
new file mode 100644
index 0000000..19172ff
--- /dev/null
+++ b/src/test/rustdoc/doc-proc-macro.rs
@@ -0,0 +1,8 @@
+// Issue #52129: ICE when trying to document the `quote` proc-macro from proc_macro
+
+// As of this writing, we don't currently attempt to document proc-macros. However, we shouldn't
+// crash when we try.
+
+extern crate proc_macro;
+
+pub use proc_macro::*;
diff --git a/src/test/rustdoc/doc-spotlight.rs b/src/test/rustdoc/doc-spotlight.rs
new file mode 100644
index 0000000..ddd46c3
--- /dev/null
+++ b/src/test/rustdoc/doc-spotlight.rs
@@ -0,0 +1,36 @@
+#![feature(doc_spotlight)]
+
+pub struct Wrapper<T> {
+    inner: T,
+}
+
+impl<T: SomeTrait> SomeTrait for Wrapper<T> {}
+
+#[doc(spotlight)]
+pub trait SomeTrait {
+    // @has doc_spotlight/trait.SomeTrait.html
+    // @has - '//code[@class="content"]' 'impl<T: SomeTrait> SomeTrait for Wrapper<T>'
+    fn wrap_me(self) -> Wrapper<Self> where Self: Sized {
+        Wrapper {
+            inner: self,
+        }
+    }
+}
+
+pub struct SomeStruct;
+impl SomeTrait for SomeStruct {}
+
+impl SomeStruct {
+    // @has doc_spotlight/struct.SomeStruct.html
+    // @has - '//code[@class="content"]' 'impl SomeTrait for SomeStruct'
+    // @has - '//code[@class="content"]' 'impl<T: SomeTrait> SomeTrait for Wrapper<T>'
+    pub fn new() -> SomeStruct {
+        SomeStruct
+    }
+}
+
+// @has doc_spotlight/fn.bare_fn.html
+// @has - '//code[@class="content"]' 'impl SomeTrait for SomeStruct'
+pub fn bare_fn() -> SomeStruct {
+    SomeStruct
+}
diff --git a/src/test/rustdoc/doctest-manual-crate-name.rs b/src/test/rustdoc/doctest-manual-crate-name.rs
new file mode 100644
index 0000000..3a5e373
--- /dev/null
+++ b/src/test/rustdoc/doctest-manual-crate-name.rs
@@ -0,0 +1,7 @@
+// compile-flags:--test
+
+//! ```
+//! #![crate_name="asdf"]
+//!
+//! println!("yo");
+//! ```
diff --git a/src/test/rustdoc/dont-show-const-contents.rs b/src/test/rustdoc/dont-show-const-contents.rs
new file mode 100644
index 0000000..656d579
--- /dev/null
+++ b/src/test/rustdoc/dont-show-const-contents.rs
@@ -0,0 +1,5 @@
+// Test that the contents of constants are not displayed as part of the
+// documentation.
+
+// @!has dont_show_const_contents/constant.CONST_S.html 'dont show this'
+pub const CONST_S: &'static str = "dont show this";
diff --git a/src/test/rustdoc/double-quote-escape.rs b/src/test/rustdoc/double-quote-escape.rs
new file mode 100644
index 0000000..243d8ad
--- /dev/null
+++ b/src/test/rustdoc/double-quote-escape.rs
@@ -0,0 +1,13 @@
+#![crate_name = "foo"]
+
+// ignore-tidy-linelength
+
+pub trait Foo<T> {
+    fn foo() {}
+}
+
+pub struct Bar;
+
+// @has foo/struct.Bar.html
+// @has - '//*[@class="sidebar-links"]/a[@href="#impl-Foo%3Cunsafe%20extern%20%22C%22%20fn()%3E"]' 'Foo<unsafe extern "C" fn()>'
+impl Foo<unsafe extern "C" fn()> for Bar {}
diff --git a/src/test/rustdoc/duplicate_impls/impls.rs b/src/test/rustdoc/duplicate_impls/impls.rs
new file mode 100644
index 0000000..6875ad2
--- /dev/null
+++ b/src/test/rustdoc/duplicate_impls/impls.rs
@@ -0,0 +1,12 @@
+pub struct Foo;
+
+// just so that `Foo` doesn't show up on `Bar`s sidebar
+pub mod bar {
+    pub trait Bar {}
+}
+
+impl Foo {
+    pub fn new() -> Foo { Foo }
+}
+
+impl bar::Bar for Foo {}
diff --git a/src/test/rustdoc/duplicate_impls/issue-33054.rs b/src/test/rustdoc/duplicate_impls/issue-33054.rs
new file mode 100644
index 0000000..3f7cec1
--- /dev/null
+++ b/src/test/rustdoc/duplicate_impls/issue-33054.rs
@@ -0,0 +1,12 @@
+// @has issue_33054/impls/struct.Foo.html
+// @has - '//code' 'impl Foo'
+// @has - '//code' 'impl Bar for Foo'
+// @count - '//*[@id="implementations-list"]/*[@class="impl"]' 1
+// @count - '//*[@id="main"]/*[@class="impl"]' 1
+// @has issue_33054/impls/bar/trait.Bar.html
+// @has - '//code' 'impl Bar for Foo'
+// @count - '//*[@class="struct"]' 1
+pub mod impls;
+
+#[doc(inline)]
+pub use impls as impls2;
diff --git a/src/test/rustdoc/edition-doctest.rs b/src/test/rustdoc/edition-doctest.rs
new file mode 100644
index 0000000..6de2599
--- /dev/null
+++ b/src/test/rustdoc/edition-doctest.rs
@@ -0,0 +1,44 @@
+// compile-flags:--test
+
+/// ```rust,edition2018
+/// #![feature(try_blocks)]
+///
+/// use std::num::ParseIntError;
+///
+/// let result: Result<i32, ParseIntError> = try {
+///     "1".parse::<i32>()?
+///         + "2".parse::<i32>()?
+///         + "3".parse::<i32>()?
+/// };
+/// assert_eq!(result, Ok(6));
+///
+/// let result: Result<i32, ParseIntError> = try {
+///     "1".parse::<i32>()?
+///         + "foo".parse::<i32>()?
+///         + "3".parse::<i32>()?
+/// };
+/// assert!(result.is_err());
+/// ```
+
+
+/// ```rust,edition2015,compile_fail,E0574
+/// #![feature(try_blocks)]
+///
+/// use std::num::ParseIntError;
+///
+/// let result: Result<i32, ParseIntError> = try {
+///     "1".parse::<i32>()?
+///         + "2".parse::<i32>()?
+///         + "3".parse::<i32>()?
+/// };
+/// assert_eq!(result, Ok(6));
+///
+/// let result: Result<i32, ParseIntError> = try {
+///     "1".parse::<i32>()?
+///         + "foo".parse::<i32>()?
+///         + "3".parse::<i32>()?
+/// };
+/// assert!(result.is_err());
+/// ```
+
+pub fn foo() {}
diff --git a/src/test/rustdoc/edition-flag.rs b/src/test/rustdoc/edition-flag.rs
new file mode 100644
index 0000000..5571245
--- /dev/null
+++ b/src/test/rustdoc/edition-flag.rs
@@ -0,0 +1,14 @@
+// compile-flags:--test -Z unstable-options
+// edition:2018
+
+#![feature(async_await)]
+
+/// ```rust
+/// #![feature(async_await)]
+/// fn main() {
+///     let _ = async { };
+/// }
+/// ```
+fn main() {
+    let _ = async { };
+}
diff --git a/src/test/rustdoc/empty-mod-private.rs b/src/test/rustdoc/empty-mod-private.rs
new file mode 100644
index 0000000..12576a1
--- /dev/null
+++ b/src/test/rustdoc/empty-mod-private.rs
@@ -0,0 +1,17 @@
+// ignore-tidy-linelength
+// compile-flags: --document-private-items
+
+// @has 'empty_mod_private/index.html' '//a[@href="foo/index.html"]' 'foo'
+// @has 'empty_mod_private/sidebar-items.js' 'foo'
+// @matches 'empty_mod_private/foo/index.html' '//h1' 'Module empty_mod_private::foo'
+mod foo {}
+
+// @has 'empty_mod_private/index.html' '//a[@href="bar/index.html"]' 'bar'
+// @has 'empty_mod_private/sidebar-items.js' 'bar'
+// @matches 'empty_mod_private/bar/index.html' '//h1' 'Module empty_mod_private::bar'
+mod bar {
+    // @has 'empty_mod_private/bar/index.html' '//a[@href="baz/index.html"]' 'baz'
+    // @has 'empty_mod_private/bar/sidebar-items.js' 'baz'
+    // @matches 'empty_mod_private/bar/baz/index.html' '//h1' 'Module empty_mod_private::bar::baz'
+    mod baz {}
+}
diff --git a/src/test/rustdoc/empty-mod-public.rs b/src/test/rustdoc/empty-mod-public.rs
new file mode 100644
index 0000000..d097fcf
--- /dev/null
+++ b/src/test/rustdoc/empty-mod-public.rs
@@ -0,0 +1,14 @@
+// @has 'empty_mod_public/index.html' '//a[@href="foo/index.html"]' 'foo'
+// @has 'empty_mod_public/sidebar-items.js' 'foo'
+// @matches 'empty_mod_public/foo/index.html' '//h1' 'Module empty_mod_public::foo'
+pub mod foo {}
+
+// @has 'empty_mod_public/index.html' '//a[@href="bar/index.html"]' 'bar'
+// @has 'empty_mod_public/sidebar-items.js' 'bar'
+// @matches 'empty_mod_public/bar/index.html' '//h1' 'Module empty_mod_public::bar'
+pub mod bar {
+    // @has 'empty_mod_public/bar/index.html' '//a[@href="baz/index.html"]' 'baz'
+    // @has 'empty_mod_public/bar/sidebar-items.js' 'baz'
+    // @matches 'empty_mod_public/bar/baz/index.html' '//h1' 'Module empty_mod_public::bar::baz'
+    pub mod baz {}
+}
diff --git a/src/test/rustdoc/empty-section.rs b/src/test/rustdoc/empty-section.rs
new file mode 100644
index 0000000..619f2d6
--- /dev/null
+++ b/src/test/rustdoc/empty-section.rs
@@ -0,0 +1,10 @@
+#![crate_name = "foo"]
+
+#![feature(optin_builtin_traits)]
+
+pub struct Foo;
+
+// @has foo/struct.Foo.html
+// @!has - 'Auto Trait Implementations'
+impl !Send for Foo {}
+impl !Sync for Foo {}
diff --git a/src/test/rustdoc/escape-deref-methods.rs b/src/test/rustdoc/escape-deref-methods.rs
new file mode 100644
index 0000000..a62ad2c
--- /dev/null
+++ b/src/test/rustdoc/escape-deref-methods.rs
@@ -0,0 +1,35 @@
+#![crate_name = "foo"]
+
+use std::ops::{Deref, DerefMut};
+
+#[derive(Debug, Clone)]
+pub struct Title {
+    name: String,
+}
+
+#[derive(Debug, Clone)]
+pub struct TitleList {
+    pub members: Vec<Title>,
+}
+
+impl TitleList {
+    pub fn new() -> Self {
+        TitleList { members: Vec::new() }
+    }
+}
+
+impl Deref for TitleList {
+    type Target = Vec<Title>;
+
+    fn deref(&self) -> &Self::Target {
+        &self.members
+    }
+}
+
+// @has foo/struct.TitleList.html
+// @has - '//*[@class="sidebar-title"]' 'Methods from Deref<Target=Vec<Title>>'
+impl DerefMut for TitleList {
+    fn deref_mut(&mut self) -> &mut Self::Target {
+        &mut self.members
+    }
+}
diff --git a/src/test/rustdoc/extern-default-method.rs b/src/test/rustdoc/extern-default-method.rs
new file mode 100644
index 0000000..810c591
--- /dev/null
+++ b/src/test/rustdoc/extern-default-method.rs
@@ -0,0 +1,7 @@
+// aux-build:rustdoc-extern-default-method.rs
+// ignore-cross-compile
+
+extern crate rustdoc_extern_default_method as ext;
+
+// @count extern_default_method/struct.Struct.html '//*[@id="method.provided"]' 1
+pub use ext::Struct;
diff --git a/src/test/rustdoc/extern-html-root-url.rs b/src/test/rustdoc/extern-html-root-url.rs
new file mode 100644
index 0000000..674d030
--- /dev/null
+++ b/src/test/rustdoc/extern-html-root-url.rs
@@ -0,0 +1,8 @@
+// ignore-tidy-linelength
+
+// compile-flags:-Z unstable-options --extern-html-root-url core=https://example.com/core/0.1.0
+
+// @has extern_html_root_url/index.html
+// @has - '//a/@href' 'https://example.com/core/0.1.0/core/iter/index.html'
+#[doc(no_inline)]
+pub use std::iter;
diff --git a/src/test/rustdoc/extern-impl-trait.rs b/src/test/rustdoc/extern-impl-trait.rs
new file mode 100644
index 0000000..58bd650
--- /dev/null
+++ b/src/test/rustdoc/extern-impl-trait.rs
@@ -0,0 +1,11 @@
+// aux-build:extern-impl-trait.rs
+
+#![crate_name = "foo"]
+
+extern crate extern_impl_trait;
+
+// @has 'foo/struct.X.html' '//code' "impl Foo<Associated = ()> + 'a"
+pub use extern_impl_trait::X;
+
+// @has 'foo/struct.Y.html' '//code' "impl ?Sized + Foo<Associated = ()> + 'a"
+pub use extern_impl_trait::Y;
diff --git a/src/test/rustdoc/extern-impl.rs b/src/test/rustdoc/extern-impl.rs
new file mode 100644
index 0000000..f68e10a
--- /dev/null
+++ b/src/test/rustdoc/extern-impl.rs
@@ -0,0 +1,27 @@
+#![crate_name = "foo"]
+
+// @has foo/struct.Foo.html
+pub struct Foo;
+
+impl Foo {
+    // @has - '//code' 'fn rust0()'
+    pub fn rust0() {}
+    // @has - '//code' 'fn rust1()'
+    pub extern "Rust" fn rust1() {}
+    // @has - '//code' 'extern "C" fn c0()'
+    pub extern fn c0() {}
+    // @has - '//code' 'extern "C" fn c1()'
+    pub extern "C" fn c1() {}
+    // @has - '//code' 'extern "system" fn system0()'
+    pub extern "system" fn system0() {}
+}
+
+// @has foo/trait.Bar.html
+pub trait Bar {}
+
+// @has - '//code' 'impl Bar for fn()'
+impl Bar for fn() {}
+// @has - '//code' 'impl Bar for extern "C" fn()'
+impl Bar for extern fn() {}
+// @has - '//code' 'impl Bar for extern "system" fn()'
+impl Bar for extern "system" fn() {}
diff --git a/src/test/rustdoc/extern-links.rs b/src/test/rustdoc/extern-links.rs
new file mode 100644
index 0000000..991f869
--- /dev/null
+++ b/src/test/rustdoc/extern-links.rs
@@ -0,0 +1,21 @@
+// aux-build:extern-links.rs
+// ignore-cross-compile
+
+#![crate_name = "foo"]
+
+extern crate extern_links;
+
+// @!has foo/index.html '//a' 'extern_links'
+#[doc(no_inline)]
+pub use extern_links as extern_links2;
+
+// @!has foo/index.html '//a' 'Foo'
+#[doc(no_inline)]
+pub use extern_links::Foo;
+
+#[doc(hidden)]
+pub mod hidden {
+    // @!has foo/hidden/extern_links/index.html
+    // @!has foo/hidden/extern_links/struct.Foo.html
+    pub use extern_links;
+}
diff --git a/src/test/rustdoc/extern-method.rs b/src/test/rustdoc/extern-method.rs
new file mode 100644
index 0000000..7fbe5fe
--- /dev/null
+++ b/src/test/rustdoc/extern-method.rs
@@ -0,0 +1,19 @@
+// aux-build:rustdoc-extern-method.rs
+// ignore-cross-compile
+
+#![feature(unboxed_closures)]
+
+extern crate rustdoc_extern_method as foo;
+
+// @has extern_method/trait.Foo.html //pre "pub trait Foo"
+// @has - '//*[@id="tymethod.foo"]//code' 'extern "rust-call" fn foo'
+// @has - '//*[@id="method.foo_"]//code' 'extern "rust-call" fn foo_'
+pub use foo::Foo;
+
+// @has extern_method/trait.Bar.html //pre "pub trait Bar"
+pub trait Bar {
+    // @has - '//*[@id="tymethod.bar"]//code' 'extern "rust-call" fn bar'
+    extern "rust-call" fn bar(&self, _: ());
+    // @has - '//*[@id="method.bar_"]//code' 'extern "rust-call" fn bar_'
+    extern "rust-call" fn bar_(&self, _: ()) { }
+}
diff --git a/src/test/rustdoc/external-cross.rs b/src/test/rustdoc/external-cross.rs
new file mode 100644
index 0000000..056ed35
--- /dev/null
+++ b/src/test/rustdoc/external-cross.rs
@@ -0,0 +1,10 @@
+// aux-build:external-cross.rs
+// ignore-cross-compile
+
+#![crate_name="host"]
+
+extern crate external_cross;
+
+// @has host/struct.NeedMoreDocs.html
+// @has - '//h1' 'Cross-crate imported docs'
+pub use external_cross::NeedMoreDocs;
diff --git a/src/test/rustdoc/external-doc.rs b/src/test/rustdoc/external-doc.rs
new file mode 100644
index 0000000..4a13f40
--- /dev/null
+++ b/src/test/rustdoc/external-doc.rs
@@ -0,0 +1,8 @@
+#![feature(external_doc)]
+
+// @has external_doc/struct.CanHasDocs.html
+// @has - '//h1' 'External Docs'
+// @has - '//h2' 'Inline Docs'
+#[doc(include = "auxiliary/external-doc.md")]
+/// ## Inline Docs
+pub struct CanHasDocs;
diff --git a/src/test/rustdoc/ffi.rs b/src/test/rustdoc/ffi.rs
new file mode 100644
index 0000000..8140dfc
--- /dev/null
+++ b/src/test/rustdoc/ffi.rs
@@ -0,0 +1,12 @@
+// aux-build:rustdoc-ffi.rs
+// ignore-cross-compile
+
+extern crate rustdoc_ffi as lib;
+
+// @has ffi/fn.foreigner.html //pre 'pub unsafe extern "C" fn foreigner(cold_as_ice: u32)'
+pub use lib::foreigner;
+
+extern "C" {
+    // @has ffi/fn.another.html //pre 'pub unsafe extern "C" fn another(cold_as_ice: u32)'
+    pub fn another(cold_as_ice: u32);
+}
diff --git a/src/test/rustdoc/fn-pointer-arg-name.rs b/src/test/rustdoc/fn-pointer-arg-name.rs
new file mode 100644
index 0000000..4293d84
--- /dev/null
+++ b/src/test/rustdoc/fn-pointer-arg-name.rs
@@ -0,0 +1,5 @@
+#![crate_name = "foo"]
+
+// @has foo/fn.f.html
+// @has - '//*[@class="rust fn"]' 'pub fn f(callback: fn(len: usize, foo: u32))'
+pub fn f(callback: fn(len: usize, foo: u32)) {}
diff --git a/src/test/rustdoc/fn-sidebar.rs b/src/test/rustdoc/fn-sidebar.rs
new file mode 100644
index 0000000..2fe8ebe
--- /dev/null
+++ b/src/test/rustdoc/fn-sidebar.rs
@@ -0,0 +1,9 @@
+#![crate_name = "foo"]
+
+// @has foo/fn.bar.html
+// @has - '//*[@class="sidebar-elems"]' ''
+pub fn bar() {}
+
+// @has foo/constant.BAR.html
+// @has - '//*[@class="sidebar-elems"]' ''
+pub const BAR: u32 = 0;
diff --git a/src/test/rustdoc/force-target-feature.rs b/src/test/rustdoc/force-target-feature.rs
new file mode 100644
index 0000000..b6c10e8
--- /dev/null
+++ b/src/test/rustdoc/force-target-feature.rs
@@ -0,0 +1,11 @@
+// only-x86_64
+// compile-flags:--test -C target-feature=+avx
+// should-fail
+
+/// (written on a spider's web) Some Struct
+///
+/// ```
+/// panic!("oh no");
+/// ```
+#[doc(cfg(target_feature = "avx"))]
+pub struct SomeStruct;
diff --git a/src/test/rustdoc/foreigntype-reexport.rs b/src/test/rustdoc/foreigntype-reexport.rs
new file mode 100644
index 0000000..616826c
--- /dev/null
+++ b/src/test/rustdoc/foreigntype-reexport.rs
@@ -0,0 +1,56 @@
+#![feature(extern_types)]
+
+mod sub {
+    extern {
+        /// Another extern type.
+        pub type C2;
+        pub fn f2();
+        pub static K: usize;
+    }
+}
+
+pub mod sub2 {
+    extern {
+        // @has foreigntype_reexport/sub2/foreigntype.C.html
+        pub type C;
+        // @has foreigntype_reexport/sub2/fn.f.html
+        pub fn f();
+        // @has foreigntype_reexport/sub2/static.K3.html
+        pub static K3: usize;
+    }
+}
+
+mod sub3 {
+    extern {
+        pub type C4;
+        pub fn f4();
+        pub static K4: usize;
+        type X4;
+    }
+}
+
+// @has foreigntype_reexport/foreigntype.C2.html
+// @has foreigntype_reexport/fn.f2.html
+// @has foreigntype_reexport/static.K2.html
+// @has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C2'
+// @has foreigntype_reexport/index.html '//a[@class="fn"]' 'f2'
+// @has foreigntype_reexport/index.html '//a[@class="static"]' 'K2'
+pub use self::sub::{C2, f2, K as K2};
+
+// @has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C'
+// @has foreigntype_reexport/index.html '//a[@class="fn"]' 'f'
+// @has foreigntype_reexport/index.html '//a[@class="static"]' 'K3'
+// @has foreigntype_reexport/index.html '//code' 'pub use self::sub2::C as C3;'
+// @has foreigntype_reexport/index.html '//code' 'pub use self::sub2::f as f3;'
+// @has foreigntype_reexport/index.html '//code' 'pub use self::sub2::K3;'
+pub use self::sub2::{C as C3, f as f3, K3};
+
+// @has foreigntype_reexport/foreigntype.C4.html
+// @has foreigntype_reexport/fn.f4.html
+// @has foreigntype_reexport/static.K4.html
+// @!has foreigntype_reexport/foreigntype.X4.html
+// @has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'C4'
+// @has foreigntype_reexport/index.html '//a[@class="fn"]' 'f4'
+// @has foreigntype_reexport/index.html '//a[@class="static"]' 'K4'
+// @!has foreigntype_reexport/index.html '//a[@class="foreigntype"]' 'X4'
+pub use self::sub3::*;
diff --git a/src/test/rustdoc/foreigntype.rs b/src/test/rustdoc/foreigntype.rs
new file mode 100644
index 0000000..bd8766c
--- /dev/null
+++ b/src/test/rustdoc/foreigntype.rs
@@ -0,0 +1,18 @@
+#![feature(extern_types)]
+
+extern {
+    // @has foreigntype/foreigntype.ExtType.html
+    pub type ExtType;
+}
+
+impl ExtType {
+    // @has - '//a[@class="fnname"]' 'do_something'
+    pub fn do_something(&self) {}
+}
+
+pub trait Trait {}
+
+// @has foreigntype/trait.Trait.html '//a[@class="foreigntype"]' 'ExtType'
+impl Trait for ExtType {}
+
+// @has foreigntype/index.html '//a[@class="foreigntype"]' 'ExtType'
diff --git a/src/test/rustdoc/generic-impl.rs b/src/test/rustdoc/generic-impl.rs
new file mode 100644
index 0000000..03a4d19
--- /dev/null
+++ b/src/test/rustdoc/generic-impl.rs
@@ -0,0 +1,16 @@
+#![crate_name = "foo"]
+
+use std::fmt;
+
+// @!has foo/struct.Bar.html '//h3[@id="impl-ToString"]//code' 'impl<T> ToString for T'
+pub struct Bar;
+
+// @has foo/struct.Foo.html '//h3[@id="impl-ToString"]//code' 'impl<T> ToString for T'
+pub struct Foo;
+// @has foo/struct.Foo.html '//div[@class="sidebar-links"]/a[@href="#impl-ToString"]' 'ToString'
+
+impl fmt::Display for Foo {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "Foo")
+    }
+}
diff --git a/src/test/rustdoc/hidden-impls.rs b/src/test/rustdoc/hidden-impls.rs
new file mode 100644
index 0000000..935bfb2
--- /dev/null
+++ b/src/test/rustdoc/hidden-impls.rs
@@ -0,0 +1,17 @@
+#![crate_name = "foo"]
+
+mod hidden {
+    #[derive(Clone)]
+    pub struct Foo;
+}
+
+#[doc(hidden)]
+pub mod __hidden {
+    pub use hidden::Foo;
+}
+
+// @has foo/trait.Clone.html
+// @!has - 'Foo'
+// @has implementors/foo/trait.Clone.js
+// @!has - 'Foo'
+pub use std::clone::Clone;
diff --git a/src/test/rustdoc/hidden-line.rs b/src/test/rustdoc/hidden-line.rs
new file mode 100644
index 0000000..f2f6173
--- /dev/null
+++ b/src/test/rustdoc/hidden-line.rs
@@ -0,0 +1,19 @@
+/// The '# ' lines should be removed from the output, but the #[derive] should be
+/// retained.
+///
+/// ```rust
+/// # #[derive(PartialEq)] // invisible
+/// # struct Foo; // invisible
+///
+/// #[derive(PartialEq)] // Bar
+/// struct Bar(Foo);
+///
+/// fn test() {
+///     let x = Bar(Foo);
+///     assert_eq!(x, x); // check that the derivings worked
+/// }
+/// ```
+pub fn foo() {}
+
+// @!has hidden_line/fn.foo.html invisible
+// @matches - //pre "#\[derive\(PartialEq\)\] // Bar"
diff --git a/src/test/rustdoc/hidden-methods.rs b/src/test/rustdoc/hidden-methods.rs
new file mode 100644
index 0000000..27181d4
--- /dev/null
+++ b/src/test/rustdoc/hidden-methods.rs
@@ -0,0 +1,29 @@
+#![crate_name = "foo"]
+
+#[doc(hidden)]
+pub mod hidden {
+    pub struct Foo;
+
+    impl Foo {
+        #[doc(hidden)]
+        pub fn this_should_be_hidden() {}
+    }
+
+    pub struct Bar;
+
+    impl Bar {
+        fn this_should_be_hidden() {}
+    }
+}
+
+// @has foo/struct.Foo.html
+// @!has - 'Methods'
+// @!has - '//code' 'impl Foo'
+// @!has - 'this_should_be_hidden'
+pub use hidden::Foo;
+
+// @has foo/struct.Bar.html
+// @!has - 'Methods'
+// @!has - '//code' 'impl Bar'
+// @!has - 'this_should_be_hidden'
+pub use hidden::Bar;
diff --git a/src/test/rustdoc/hidden-trait-struct-impls.rs b/src/test/rustdoc/hidden-trait-struct-impls.rs
new file mode 100644
index 0000000..1be956e
--- /dev/null
+++ b/src/test/rustdoc/hidden-trait-struct-impls.rs
@@ -0,0 +1,22 @@
+#![crate_name = "foo"]
+
+#[doc(hidden)]
+pub trait Foo {}
+
+trait Dark {}
+
+pub trait Bam {}
+
+pub struct Bar;
+
+struct Hidden;
+
+// @!has foo/struct.Bar.html '//*[@id="impl-Foo"]' 'impl Foo for Bar'
+impl Foo for Bar {}
+// @!has foo/struct.Bar.html '//*[@id="impl-Dark"]' 'impl Dark for Bar'
+impl Dark for Bar {}
+// @has foo/struct.Bar.html '//*[@id="impl-Bam"]' 'impl Bam for Bar'
+// @has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Bar'
+impl Bam for Bar {}
+// @!has foo/trait.Bam.html '//*[@id="implementors-list"]' 'impl Bam for Hidden'
+impl Bam for Hidden {}
diff --git a/src/test/rustdoc/impl-disambiguation.rs b/src/test/rustdoc/impl-disambiguation.rs
new file mode 100644
index 0000000..9f55318
--- /dev/null
+++ b/src/test/rustdoc/impl-disambiguation.rs
@@ -0,0 +1,30 @@
+#![crate_name = "foo"]
+
+pub trait Foo {}
+
+pub struct Bar<T> { field: T }
+
+// @has foo/trait.Foo.html '//*[@class="item-list"]//code' \
+//     "impl Foo for Bar<u8>"
+impl Foo for Bar<u8> {}
+// @has foo/trait.Foo.html '//*[@class="item-list"]//code' \
+//     "impl Foo for Bar<u16>"
+impl Foo for Bar<u16> {}
+// @has foo/trait.Foo.html '//*[@class="item-list"]//code' \
+//     "impl<'a> Foo for &'a Bar<u8>"
+impl<'a> Foo for &'a Bar<u8> {}
+
+pub mod mod1 {
+    pub struct Baz {}
+}
+
+pub mod mod2 {
+    pub enum Baz {}
+}
+
+// @has foo/trait.Foo.html '//*[@class="item-list"]//code' \
+//     "impl Foo for foo::mod1::Baz"
+impl Foo for mod1::Baz {}
+// @has foo/trait.Foo.html '//*[@class="item-list"]//code' \
+//     "impl<'a> Foo for &'a foo::mod2::Baz"
+impl<'a> Foo for &'a mod2::Baz {}
diff --git a/src/test/rustdoc/impl-everywhere.rs b/src/test/rustdoc/impl-everywhere.rs
new file mode 100644
index 0000000..9d86dd3
--- /dev/null
+++ b/src/test/rustdoc/impl-everywhere.rs
@@ -0,0 +1,30 @@
+#![crate_name = "foo"]
+
+pub trait Foo {}
+pub trait Foo2 {}
+
+pub struct Bar;
+
+impl Foo for Bar {}
+impl Foo2 for Bar {}
+
+// @!has foo/fn.foo.html '//section[@id="main"]//pre' "x: &\'x impl Foo"
+// @!has foo/fn.foo.html '//section[@id="main"]//pre' "-> &\'x impl Foo {"
+pub fn foo<'x>(x: &'x impl Foo) -> &'x impl Foo {
+    x
+}
+
+// @!has foo/fn.foo2.html '//section[@id="main"]//pre' "x: &\'x impl Foo"
+// @!has foo/fn.foo2.html '//section[@id="main"]//pre' '-> impl Foo2 {'
+pub fn foo2<'x>(_x: &'x impl Foo) -> impl Foo2 {
+    Bar
+}
+
+// @!has foo/fn.foo_foo.html '//section[@id="main"]//pre' '-> impl Foo + Foo2 {'
+pub fn foo_foo() -> impl Foo + Foo2 {
+    Bar
+}
+
+// @!has foo/fn.foo2.html '//section[@id="main"]//pre' "x: &'x (impl Foo + Foo2)"
+pub fn foo_foo_foo<'x>(_x: &'x (impl Foo + Foo2)) {
+}
diff --git a/src/test/rustdoc/impl-parts-crosscrate.rs b/src/test/rustdoc/impl-parts-crosscrate.rs
new file mode 100644
index 0000000..f9583d1
--- /dev/null
+++ b/src/test/rustdoc/impl-parts-crosscrate.rs
@@ -0,0 +1,20 @@
+// aux-build:rustdoc-impl-parts-crosscrate.rs
+// ignore-cross-compile
+
+#![feature(optin_builtin_traits)]
+
+extern crate rustdoc_impl_parts_crosscrate;
+
+pub struct Bar<T> { t: T }
+
+// The output file is html embedded in javascript, so the html tags
+// aren't stripped by the processing script and we can't check for the
+// full impl string.  Instead, just make sure something from each part
+// is mentioned.
+
+// @has implementors/rustdoc_impl_parts_crosscrate/trait.AnOibit.js Bar
+// @has - Send
+// @has - !AnOibit
+// @has - Copy
+impl<T: Send> !rustdoc_impl_parts_crosscrate::AnOibit for Bar<T>
+    where T: Copy {}
diff --git a/src/test/rustdoc/impl-parts.rs b/src/test/rustdoc/impl-parts.rs
new file mode 100644
index 0000000..fbb4e72
--- /dev/null
+++ b/src/test/rustdoc/impl-parts.rs
@@ -0,0 +1,11 @@
+#![feature(optin_builtin_traits)]
+
+pub auto trait AnOibit {}
+
+pub struct Foo<T> { field: T }
+
+// @has impl_parts/struct.Foo.html '//*[@class="impl"]//code' \
+//     "impl<T: Clone> !AnOibit for Foo<T> where T: Sync,"
+// @has impl_parts/trait.AnOibit.html '//*[@class="item-list"]//code' \
+//     "impl<T: Clone> !AnOibit for Foo<T> where T: Sync,"
+impl<T: Clone> !AnOibit for Foo<T> where T: Sync {}
diff --git a/src/test/rustdoc/index-page.rs b/src/test/rustdoc/index-page.rs
new file mode 100644
index 0000000..6998e73
--- /dev/null
+++ b/src/test/rustdoc/index-page.rs
@@ -0,0 +1,8 @@
+// compile-flags: -Z unstable-options --enable-index-page
+
+#![crate_name = "foo"]
+
+// @has foo/../index.html
+// @has - '//span[@class="in-band"]' 'List of all crates'
+// @has - '//ul[@class="mod"]//a[@href="foo/index.html"]' 'foo'
+pub struct Foo;
diff --git a/src/test/rustdoc/inline-default-methods.rs b/src/test/rustdoc/inline-default-methods.rs
new file mode 100644
index 0000000..c97644e
--- /dev/null
+++ b/src/test/rustdoc/inline-default-methods.rs
@@ -0,0 +1,9 @@
+// aux-build:inline-default-methods.rs
+// ignore-cross-compile
+
+extern crate inline_default_methods;
+
+// @has inline_default_methods/trait.Foo.html
+// @has - '//*[@class="rust trait"]' 'fn bar(&self);'
+// @has - '//*[@class="rust trait"]' 'fn foo(&mut self) { ... }'
+pub use inline_default_methods::Foo;
diff --git a/src/test/rustdoc/inline_cross/assoc-items.rs b/src/test/rustdoc/inline_cross/assoc-items.rs
new file mode 100644
index 0000000..d4f05bab
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/assoc-items.rs
@@ -0,0 +1,42 @@
+// aux-build:assoc-items.rs
+// build-aux-docs
+// ignore-cross-compile
+
+#![crate_name = "foo"]
+
+extern crate assoc_items;
+
+// @has foo/struct.MyStruct.html
+// @!has - 'PrivateConst'
+// @has - '//*[@id="associatedconstant.PublicConst"]' 'pub const PublicConst: u8'
+// @has - '//*[@class="docblock"]' 'docs for PublicConst'
+// @!has - 'private_method'
+// @has - '//*[@id="method.public_method"]' 'pub fn public_method()'
+// @has - '//*[@class="docblock"]' 'docs for public_method'
+// @has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16'
+// @has - '//*[@class="docblock"]' 'dox for ConstNoDefault'
+// @has - '//*[@id="associatedconstant.ConstWithDefault"]' 'const ConstWithDefault: u16'
+// @has - '//*[@class="docblock"]' 'docs for ConstWithDefault'
+// @has - '//*[@id="associatedtype.TypeNoDefault"]' 'type TypeNoDefault = i32'
+// @has - '//*[@class="docblock"]' 'dox for TypeNoDefault'
+// @has - '//*[@id="associatedtype.TypeWithDefault"]' 'type TypeWithDefault = u32'
+// @has - '//*[@class="docblock"]' 'docs for TypeWithDefault'
+// @has - '//*[@id="method.method_no_default"]' 'fn method_no_default()'
+// @has - '//*[@class="docblock"]' 'dox for method_no_default'
+// @has - '//*[@id="method.method_with_default"]' 'fn method_with_default()'
+// @has - '//*[@class="docblock"]' 'docs for method_with_default'
+pub use assoc_items::MyStruct;
+
+// @has foo/trait.MyTrait.html
+// @has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16'
+// @has - '//*[@class="docblock"]' 'docs for ConstNoDefault'
+// @has - '//*[@id="associatedconstant.ConstWithDefault"]' 'const ConstWithDefault: u16'
+// @has - '//*[@class="docblock"]' 'docs for ConstWithDefault'
+// @has - '//*[@id="associatedtype.TypeNoDefault"]' 'type TypeNoDefault'
+// @has - '//*[@class="docblock"]' 'docs for TypeNoDefault'
+// @has - '//*[@class="docblock"]' 'docs for TypeWithDefault'
+// @has - '//*[@id="tymethod.method_no_default"]' 'fn method_no_default()'
+// @has - '//*[@class="docblock"]' 'docs for method_no_default'
+// @has - '//*[@id="method.method_with_default"]' 'fn method_with_default()'
+// @has - '//*[@class="docblock"]' 'docs for method_with_default'
+pub use assoc_items::MyTrait;
diff --git a/src/test/rustdoc/inline_cross/auxiliary/assoc-items.rs b/src/test/rustdoc/inline_cross/auxiliary/assoc-items.rs
new file mode 100644
index 0000000..5fa2999
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/assoc-items.rs
@@ -0,0 +1,38 @@
+#![feature(associated_type_defaults)]
+
+pub struct MyStruct;
+
+impl MyStruct {
+    /// docs for PrivateConst
+    const PrivateConst: i8 = -123;
+    /// docs for PublicConst
+    pub const PublicConst: u8 = 123;
+    /// docs for private_method
+    fn private_method() {}
+    /// docs for public_method
+    pub fn public_method() {}
+}
+
+pub trait MyTrait {
+    /// docs for ConstNoDefault
+    const ConstNoDefault: i16;
+    /// docs for ConstWithDefault
+    const ConstWithDefault: u16 = 12345;
+    /// docs for TypeNoDefault
+    type TypeNoDefault;
+    /// docs for TypeWithDefault
+    type TypeWithDefault = u32;
+    /// docs for method_no_default
+    fn method_no_default();
+    /// docs for method_with_default
+    fn method_with_default() {}
+}
+
+impl MyTrait for MyStruct {
+    /// dox for ConstNoDefault
+    const ConstNoDefault: i16 = -12345;
+    /// dox for TypeNoDefault
+    type TypeNoDefault = i32;
+    /// dox for method_no_default
+    fn method_no_default() {}
+}
diff --git a/src/test/rustdoc/inline_cross/auxiliary/cross-glob.rs b/src/test/rustdoc/inline_cross/auxiliary/cross-glob.rs
new file mode 100644
index 0000000..cde7f68
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/cross-glob.rs
@@ -0,0 +1,5 @@
+#![crate_name = "inner"]
+
+pub struct SomeStruct;
+
+pub fn some_fn() {}
diff --git a/src/test/rustdoc/inline_cross/auxiliary/default-trait-method.rs b/src/test/rustdoc/inline_cross/auxiliary/default-trait-method.rs
new file mode 100644
index 0000000..ce60bbf
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/default-trait-method.rs
@@ -0,0 +1,16 @@
+#![feature(specialization)]
+
+#![crate_name = "foo"]
+
+pub trait Item {
+    fn foo();
+    fn bar();
+    fn baz() {}
+}
+
+pub struct Foo;
+
+impl Item for Foo {
+    default fn foo() {}
+    fn bar() {}
+}
diff --git a/src/test/rustdoc/inline_cross/auxiliary/impl-inline-without-trait.rs b/src/test/rustdoc/inline_cross/auxiliary/impl-inline-without-trait.rs
new file mode 100644
index 0000000..401a6a4
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/impl-inline-without-trait.rs
@@ -0,0 +1,8 @@
+pub trait MyTrait {
+    /// docs for my_trait_method
+    fn my_trait_method() {}
+}
+
+pub struct MyStruct;
+
+impl MyTrait for MyStruct {}
diff --git a/src/test/rustdoc/inline_cross/auxiliary/issue-33113.rs b/src/test/rustdoc/inline_cross/auxiliary/issue-33113.rs
new file mode 100644
index 0000000..4e1f191
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/issue-33113.rs
@@ -0,0 +1,7 @@
+#![crate_name="bar"]
+
+pub trait Bar {}
+pub struct Foo;
+
+impl<'a> Bar for &'a char {}
+impl Bar for Foo {}
diff --git a/src/test/rustdoc/inline_cross/auxiliary/macro-vis.rs b/src/test/rustdoc/inline_cross/auxiliary/macro-vis.rs
new file mode 100644
index 0000000..5615a4f
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/macro-vis.rs
@@ -0,0 +1,25 @@
+#![crate_name = "qwop"]
+
+/// (written on a spider's web) Some Macro
+#[macro_export]
+macro_rules! some_macro {
+    () => {
+        println!("this is some macro, for sure");
+    };
+}
+
+/// Some other macro, to fill space.
+#[macro_export]
+macro_rules! other_macro {
+    () => {
+        println!("this is some other macro, whatev");
+    };
+}
+
+/// This macro is so cool, it's Super.
+#[macro_export]
+macro_rules! super_macro {
+    () => {
+        println!("is it a bird? a plane? no, it's Super Macro!");
+    };
+}
diff --git a/src/test/rustdoc/inline_cross/auxiliary/macros.rs b/src/test/rustdoc/inline_cross/auxiliary/macros.rs
new file mode 100644
index 0000000..6189b01
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/macros.rs
@@ -0,0 +1,11 @@
+#![feature(staged_api)]
+
+#![stable(feature = "rust1", since = "1.0.0")]
+
+/// docs for my_macro
+#[unstable(feature = "macro_test", issue = "0")]
+#[rustc_deprecated(since = "1.2.3", reason = "text")]
+#[macro_export]
+macro_rules! my_macro {
+    () => ()
+}
diff --git a/src/test/rustdoc/inline_cross/auxiliary/proc_macro.rs b/src/test/rustdoc/inline_cross/auxiliary/proc_macro.rs
new file mode 100644
index 0000000..9836b6b
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/proc_macro.rs
@@ -0,0 +1,28 @@
+// force-host
+// no-prefer-dynamic
+
+#![crate_type="proc-macro"]
+#![crate_name="some_macros"]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+/// a proc-macro that swallows its input and does nothing.
+#[proc_macro]
+pub fn some_proc_macro(_input: TokenStream) -> TokenStream {
+    TokenStream::new()
+}
+
+/// a proc-macro attribute that passes its item through verbatim.
+#[proc_macro_attribute]
+pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream {
+    item
+}
+
+/// a derive attribute that adds nothing to its input.
+#[proc_macro_derive(SomeDerive)]
+pub fn some_derive(_item: TokenStream) -> TokenStream {
+    TokenStream::new()
+}
+
diff --git a/src/test/rustdoc/inline_cross/auxiliary/renamed-via-module.rs b/src/test/rustdoc/inline_cross/auxiliary/renamed-via-module.rs
new file mode 100644
index 0000000..2e52907
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/renamed-via-module.rs
@@ -0,0 +1,9 @@
+#![crate_name = "foo"]
+
+pub mod iter {
+    mod range {
+        pub struct StepBy;
+    }
+    pub use self::range::StepBy as DeprecatedStepBy;
+    pub struct StepBy;
+}
diff --git a/src/test/rustdoc/inline_cross/auxiliary/rustdoc-hidden-sig.rs b/src/test/rustdoc/inline_cross/auxiliary/rustdoc-hidden-sig.rs
new file mode 100644
index 0000000..6357b76
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/rustdoc-hidden-sig.rs
@@ -0,0 +1,12 @@
+pub struct Bar;
+
+impl Bar {
+    pub fn bar(_: u8) -> hidden::Hidden {
+        hidden::Hidden
+    }
+}
+
+#[doc(hidden)]
+pub mod hidden {
+    pub struct Hidden;
+}
diff --git a/src/test/rustdoc/inline_cross/auxiliary/rustdoc-hidden.rs b/src/test/rustdoc/inline_cross/auxiliary/rustdoc-hidden.rs
new file mode 100644
index 0000000..0c75b31
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/rustdoc-hidden.rs
@@ -0,0 +1,4 @@
+#[doc(hidden)]
+pub struct Foo;
+
+pub struct Bar;
diff --git a/src/test/rustdoc/inline_cross/auxiliary/rustdoc-nonreachable-impls.rs b/src/test/rustdoc/inline_cross/auxiliary/rustdoc-nonreachable-impls.rs
new file mode 100644
index 0000000..4e461d3
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/rustdoc-nonreachable-impls.rs
@@ -0,0 +1,34 @@
+pub struct Foo;
+
+pub trait Woof {}
+pub trait Bark {}
+
+mod private {
+    // should be shown
+    impl ::Woof for ::Foo {}
+
+    pub trait Bar {}
+    pub struct Wibble;
+
+    // these should not be shown
+    impl Bar for ::Foo {}
+    impl Bar for Wibble {}
+    impl ::Bark for Wibble {}
+    impl ::Woof for Wibble {}
+}
+
+#[doc(hidden)]
+pub mod hidden {
+    // should be shown
+    impl ::Bark for ::Foo {}
+
+    pub trait Qux {}
+    pub struct Wobble;
+
+
+    // these should only be shown if they're re-exported correctly
+    impl Qux for ::Foo {}
+    impl Qux for Wobble {}
+    impl ::Bark for Wobble {}
+    impl ::Woof for Wobble {}
+}
diff --git a/src/test/rustdoc/inline_cross/auxiliary/rustdoc-trait-object-impl.rs b/src/test/rustdoc/inline_cross/auxiliary/rustdoc-trait-object-impl.rs
new file mode 100644
index 0000000..76913f0
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/rustdoc-trait-object-impl.rs
@@ -0,0 +1,14 @@
+use std::fmt;
+
+pub trait Bar {}
+
+impl<'a> Bar + 'a {
+    pub fn bar(&self) -> usize { 42 }
+}
+
+impl<'a> fmt::Debug for Bar + 'a {
+    fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
+        Ok(())
+    }
+}
+
diff --git a/src/test/rustdoc/inline_cross/auxiliary/trait-vis.rs b/src/test/rustdoc/inline_cross/auxiliary/trait-vis.rs
new file mode 100644
index 0000000..e5bc796
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/trait-vis.rs
@@ -0,0 +1,13 @@
+#![crate_name = "inner"]
+
+pub struct SomeStruct;
+
+fn asdf() {
+    const _FOO: () = {
+        impl Clone for SomeStruct {
+            fn clone(&self) -> Self {
+                SomeStruct
+            }
+        }
+    };
+}
diff --git a/src/test/rustdoc/inline_cross/auxiliary/use_crate.rs b/src/test/rustdoc/inline_cross/auxiliary/use_crate.rs
new file mode 100644
index 0000000..75efbe0
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/use_crate.rs
@@ -0,0 +1,5 @@
+pub mod asdf {
+    pub struct SomeStruct;
+}
+
+pub trait SomeTrait {}
diff --git a/src/test/rustdoc/inline_cross/auxiliary/use_crate_2.rs b/src/test/rustdoc/inline_cross/auxiliary/use_crate_2.rs
new file mode 100644
index 0000000..25b4c20
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/auxiliary/use_crate_2.rs
@@ -0,0 +1 @@
+pub struct SomethingElse;
diff --git a/src/test/rustdoc/inline_cross/cross-glob.rs b/src/test/rustdoc/inline_cross/cross-glob.rs
new file mode 100644
index 0000000..f97da11
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/cross-glob.rs
@@ -0,0 +1,11 @@
+// aux-build:cross-glob.rs
+// build-aux-docs
+// ignore-cross-compile
+
+extern crate inner;
+
+// @has cross_glob/struct.SomeStruct.html
+// @has cross_glob/fn.some_fn.html
+// @!has cross_glob/index.html '//code' 'pub use inner::*;'
+#[doc(inline)]
+pub use inner::*;
diff --git a/src/test/rustdoc/inline_cross/default-trait-method.rs b/src/test/rustdoc/inline_cross/default-trait-method.rs
new file mode 100644
index 0000000..a4ec73a
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/default-trait-method.rs
@@ -0,0 +1,20 @@
+// aux-build:default-trait-method.rs
+
+extern crate foo;
+
+// @has default_trait_method/trait.Item.html
+// @has - '//*[@id="tymethod.foo"]' 'fn foo()'
+// @!has - '//*[@id="tymethod.foo"]' 'default fn foo()'
+// @has - '//*[@id="tymethod.bar"]' 'fn bar()'
+// @!has - '//*[@id="tymethod.bar"]' 'default fn bar()'
+// @has - '//*[@id="method.baz"]' 'fn baz()'
+// @!has - '//*[@id="method.baz"]' 'default fn baz()'
+pub use foo::Item;
+
+// @has default_trait_method/struct.Foo.html
+// @has - '//*[@id="method.foo"]' 'default fn foo()'
+// @has - '//*[@id="method.bar"]' 'fn bar()'
+// @!has - '//*[@id="method.bar"]' 'default fn bar()'
+// @has - '//*[@id="method.baz"]' 'fn baz()'
+// @!has - '//*[@id="method.baz"]' 'default fn baz()'
+pub use foo::Foo;
diff --git a/src/test/rustdoc/inline_cross/hidden-use.rs b/src/test/rustdoc/inline_cross/hidden-use.rs
new file mode 100644
index 0000000..9771573
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/hidden-use.rs
@@ -0,0 +1,12 @@
+// aux-build:rustdoc-hidden.rs
+// build-aux-docs
+// ignore-cross-compile
+
+extern crate rustdoc_hidden;
+
+// @has hidden_use/index.html
+// @!has - 'rustdoc_hidden'
+// @!has - 'Bar'
+// @!has hidden_use/struct.Bar.html
+#[doc(hidden)]
+pub use rustdoc_hidden::Bar;
diff --git a/src/test/rustdoc/inline_cross/impl-inline-without-trait.rs b/src/test/rustdoc/inline_cross/impl-inline-without-trait.rs
new file mode 100644
index 0000000..cadeccb
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/impl-inline-without-trait.rs
@@ -0,0 +1,12 @@
+// aux-build:impl-inline-without-trait.rs
+// build-aux-docs
+// ignore-cross-compile
+
+#![crate_name = "foo"]
+
+extern crate impl_inline_without_trait;
+
+// @has 'foo/struct.MyStruct.html'
+// @has - '//*[@id="method.my_trait_method"]' 'fn my_trait_method()'
+// @has - '//*[@class="docblock"]' 'docs for my_trait_method'
+pub use impl_inline_without_trait::MyStruct;
diff --git a/src/test/rustdoc/inline_cross/inline_hidden.rs b/src/test/rustdoc/inline_cross/inline_hidden.rs
new file mode 100644
index 0000000..dcceaad
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/inline_hidden.rs
@@ -0,0 +1,12 @@
+// aux-build:rustdoc-hidden.rs
+// build-aux-docs
+// ignore-cross-compile
+
+extern crate rustdoc_hidden;
+
+#[doc(no_inline)]
+pub use rustdoc_hidden::Foo;
+
+// @has inline_hidden/fn.foo.html
+// @!has - '//a/@title' 'Foo'
+pub fn foo(_: Foo) {}
diff --git a/src/test/rustdoc/inline_cross/issue-28480.rs b/src/test/rustdoc/inline_cross/issue-28480.rs
new file mode 100644
index 0000000..99f5b90
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/issue-28480.rs
@@ -0,0 +1,13 @@
+// aux-build:rustdoc-hidden-sig.rs
+// build-aux-docs
+// ignore-cross-compile
+
+// @has rustdoc_hidden_sig/struct.Bar.html
+// @!has -  '//a/@title' 'Hidden'
+// @has -  '//a' 'u8'
+extern crate rustdoc_hidden_sig;
+
+// @has issue_28480/struct.Bar.html
+// @!has -  '//a/@title' 'Hidden'
+// @has -  '//a' 'u8'
+pub use rustdoc_hidden_sig::Bar;
diff --git a/src/test/rustdoc/inline_cross/issue-31948-1.rs b/src/test/rustdoc/inline_cross/issue-31948-1.rs
new file mode 100644
index 0000000..f470562
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/issue-31948-1.rs
@@ -0,0 +1,27 @@
+// aux-build:rustdoc-nonreachable-impls.rs
+// build-aux-docs
+// ignore-cross-compile
+
+extern crate rustdoc_nonreachable_impls;
+
+// @has issue_31948_1/struct.Wobble.html
+// @has - '//*[@class="impl"]//code' 'Bark for'
+// @has - '//*[@class="impl"]//code' 'Woof for'
+// @!has - '//*[@class="impl"]//code' 'Bar for'
+// @!has - '//*[@class="impl"]//code' 'Qux for'
+pub use rustdoc_nonreachable_impls::hidden::Wobble;
+
+// @has issue_31948_1/trait.Bark.html
+// @has - '//code' 'for Foo'
+// @has - '//code' 'for Wobble'
+// @!has - '//code' 'for Wibble'
+pub use rustdoc_nonreachable_impls::Bark;
+
+// @has issue_31948_1/trait.Woof.html
+// @has - '//code' 'for Foo'
+// @has - '//code' 'for Wobble'
+// @!has - '//code' 'for Wibble'
+pub use rustdoc_nonreachable_impls::Woof;
+
+// @!has issue_31948_1/trait.Bar.html
+// @!has issue_31948_1/trait.Qux.html
diff --git a/src/test/rustdoc/inline_cross/issue-31948-2.rs b/src/test/rustdoc/inline_cross/issue-31948-2.rs
new file mode 100644
index 0000000..282f067
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/issue-31948-2.rs
@@ -0,0 +1,21 @@
+// aux-build:rustdoc-nonreachable-impls.rs
+// build-aux-docs
+// ignore-cross-compile
+
+extern crate rustdoc_nonreachable_impls;
+
+// @has issue_31948_2/struct.Wobble.html
+// @has - '//*[@class="impl"]//code' 'Qux for'
+// @has - '//*[@class="impl"]//code' 'Bark for'
+// @has - '//*[@class="impl"]//code' 'Woof for'
+// @!has - '//*[@class="impl"]//code' 'Bar for'
+pub use rustdoc_nonreachable_impls::hidden::Wobble;
+
+// @has issue_31948_2/trait.Qux.html
+// @has - '//code' 'for Foo'
+// @has - '//code' 'for Wobble'
+pub use rustdoc_nonreachable_impls::hidden::Qux;
+
+// @!has issue_31948_2/trait.Bar.html
+// @!has issue_31948_2/trait.Woof.html
+// @!has issue_31948_2/trait.Bark.html
diff --git a/src/test/rustdoc/inline_cross/issue-31948.rs b/src/test/rustdoc/inline_cross/issue-31948.rs
new file mode 100644
index 0000000..d572517
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/issue-31948.rs
@@ -0,0 +1,29 @@
+// aux-build:rustdoc-nonreachable-impls.rs
+// build-aux-docs
+// ignore-cross-compile
+
+extern crate rustdoc_nonreachable_impls;
+
+// @has issue_31948/struct.Foo.html
+// @has - '//*[@class="impl"]//code' 'Bark for'
+// @has - '//*[@class="impl"]//code' 'Woof for'
+// @!has - '//*[@class="impl"]//code' 'Bar for'
+// @!has - '//*[@class="impl"]//code' 'Qux for'
+pub use rustdoc_nonreachable_impls::Foo;
+
+// @has issue_31948/trait.Bark.html
+// @has - '//code' 'for Foo'
+// @!has - '//code' 'for Wibble'
+// @!has - '//code' 'for Wobble'
+pub use rustdoc_nonreachable_impls::Bark;
+
+// @has issue_31948/trait.Woof.html
+// @has - '//code' 'for Foo'
+// @!has - '//code' 'for Wibble'
+// @!has - '//code' 'for Wobble'
+pub use rustdoc_nonreachable_impls::Woof;
+
+// @!has issue_31948/trait.Bar.html
+// @!has issue_31948/trait.Qux.html
+// @!has issue_31948/struct.Wibble.html
+// @!has issue_31948/struct.Wobble.html
diff --git a/src/test/rustdoc/inline_cross/issue-32881.rs b/src/test/rustdoc/inline_cross/issue-32881.rs
new file mode 100644
index 0000000..f783837
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/issue-32881.rs
@@ -0,0 +1,12 @@
+// aux-build:rustdoc-trait-object-impl.rs
+// build-aux-docs
+// ignore-cross-compile
+
+extern crate rustdoc_trait_object_impl;
+
+// @has issue_32881/trait.Bar.html
+// @has - '//code' "impl<'a> dyn Bar"
+// @has - '//code' "impl<'a> Debug for dyn Bar"
+
+pub use rustdoc_trait_object_impl::Bar;
+
diff --git a/src/test/rustdoc/inline_cross/issue-33113.rs b/src/test/rustdoc/inline_cross/issue-33113.rs
new file mode 100644
index 0000000..1e63360
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/issue-33113.rs
@@ -0,0 +1,10 @@
+// aux-build:issue-33113.rs
+// build-aux-docs
+// ignore-cross-compile
+
+extern crate bar;
+
+// @has issue_33113/trait.Bar.html
+// @has - '//code' "for &'a char"
+// @has - '//code' "for Foo"
+pub use bar::Bar;
diff --git a/src/test/rustdoc/inline_cross/macro-vis.rs b/src/test/rustdoc/inline_cross/macro-vis.rs
new file mode 100644
index 0000000..9fefd38
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/macro-vis.rs
@@ -0,0 +1,36 @@
+// aux-build:macro-vis.rs
+// build-aux-docs
+// ignore-cross-compile
+
+#[macro_use] extern crate qwop;
+
+// @has macro_vis/macro.some_macro.html
+// @has macro_vis/index.html '//a/@href' 'macro.some_macro.html'
+pub use qwop::some_macro;
+
+// @has macro_vis/macro.renamed_macro.html
+// @!has - '//pre' 'some_macro'
+// @has macro_vis/index.html '//a/@href' 'macro.renamed_macro.html'
+#[doc(inline)]
+pub use qwop::some_macro as renamed_macro;
+
+// @!has macro_vis/macro.other_macro.html
+// @!has macro_vis/index.html '//a/@href' 'macro.other_macro.html'
+// @!has - '//code' 'pub use qwop::other_macro;'
+#[doc(hidden)]
+pub use qwop::other_macro;
+
+// @has macro_vis/index.html '//code' 'pub use qwop::super_macro;'
+// @!has macro_vis/macro.super_macro.html
+#[doc(no_inline)]
+pub use qwop::super_macro;
+
+// @has macro_vis/macro.this_is_dope.html
+// @has macro_vis/index.html '//a/@href' 'macro.this_is_dope.html'
+/// What it says on the tin.
+#[macro_export]
+macro_rules! this_is_dope {
+    () => {
+        println!("yo check this out");
+    };
+}
diff --git a/src/test/rustdoc/inline_cross/macros.rs b/src/test/rustdoc/inline_cross/macros.rs
new file mode 100644
index 0000000..f9bf982
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/macros.rs
@@ -0,0 +1,18 @@
+// aux-build:macros.rs
+// build-aux-docs
+
+#![feature(macro_test)]
+
+#![crate_name = "foo"]
+
+extern crate macros;
+
+// @has foo/index.html '//*[@class="docblock-short"]/span[@class="stab deprecated"]' Deprecated
+// @has - '//*[@class="docblock-short"]/span[@class="stab unstable"]' Experimental
+
+// @has foo/macro.my_macro.html
+// @has - '//*[@class="docblock"]' 'docs for my_macro'
+// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.2.3: text'
+// @has - '//*[@class="stab unstable"]' 'macro_test'
+// @has - '//a/@href' '../src/macros/macros.rs.html#9-11'
+pub use macros::my_macro;
diff --git a/src/test/rustdoc/inline_cross/proc_macro.rs b/src/test/rustdoc/inline_cross/proc_macro.rs
new file mode 100644
index 0000000..e1cdcf4
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/proc_macro.rs
@@ -0,0 +1,16 @@
+// aux-build:proc_macro.rs
+// build-aux-docs
+
+// FIXME: if/when proc-macros start exporting their doc attributes across crates, we can turn on
+// cross-crate inlining for them
+
+extern crate some_macros;
+
+// @has proc_macro/index.html
+// @has - '//a/@href' '../some_macros/macro.some_proc_macro.html'
+// @has - '//a/@href' '../some_macros/attr.some_proc_attr.html'
+// @has - '//a/@href' '../some_macros/derive.SomeDerive.html'
+// @!has proc_macro/macro.some_proc_macro.html
+// @!has proc_macro/attr.some_proc_attr.html
+// @!has proc_macro/derive.SomeDerive.html
+pub use some_macros::{some_proc_macro, some_proc_attr, SomeDerive};
diff --git a/src/test/rustdoc/inline_cross/renamed-via-module.rs b/src/test/rustdoc/inline_cross/renamed-via-module.rs
new file mode 100644
index 0000000..cdedbf0
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/renamed-via-module.rs
@@ -0,0 +1,24 @@
+// aux-build:renamed-via-module.rs
+// build-aux-docs
+// ignore-cross-compile
+
+#![crate_name = "bar"]
+
+extern crate foo;
+
+// @has foo/iter/index.html
+// @has - '//a/[@href="struct.DeprecatedStepBy.html"]' "DeprecatedStepBy"
+// @has - '//a/[@href="struct.StepBy.html"]' "StepBy"
+// @has foo/iter/struct.DeprecatedStepBy.html
+// @has - '//h1' "Struct foo::iter::DeprecatedStepBy"
+// @has foo/iter/struct.StepBy.html
+// @has - '//h1' "Struct foo::iter::StepBy"
+
+// @has bar/iter/index.html
+// @has - '//a/[@href="struct.DeprecatedStepBy.html"]' "DeprecatedStepBy"
+// @has - '//a/[@href="struct.StepBy.html"]' "StepBy"
+// @has bar/iter/struct.DeprecatedStepBy.html
+// @has - '//h1' "Struct bar::iter::DeprecatedStepBy"
+// @has bar/iter/struct.StepBy.html
+// @has - '//h1' "Struct bar::iter::StepBy"
+pub use foo::iter;
diff --git a/src/test/rustdoc/inline_cross/trait-vis.rs b/src/test/rustdoc/inline_cross/trait-vis.rs
new file mode 100644
index 0000000..e658544
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/trait-vis.rs
@@ -0,0 +1,7 @@
+// aux-build:trait-vis.rs
+
+extern crate inner;
+
+// @has trait_vis/struct.SomeStruct.html
+// @has - '//code' 'impl Clone for SomeStruct'
+pub use inner::SomeStruct;
diff --git a/src/test/rustdoc/inline_cross/use_crate.rs b/src/test/rustdoc/inline_cross/use_crate.rs
new file mode 100644
index 0000000..f678ba0
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/use_crate.rs
@@ -0,0 +1,27 @@
+// aux-build:use_crate.rs
+// aux-build:use_crate_2.rs
+// build-aux-docs
+// edition:2018
+// compile-flags:--extern use_crate --extern use_crate_2 -Z unstable-options
+
+// During the buildup to Rust 2018, rustdoc would eagerly inline `pub use some_crate;` as if it
+// were a module, so we changed it to make `pub use`ing crate roots remain as a `pub use` statement
+// in docs... unless you added `#[doc(inline)]`.
+
+#![crate_name = "local"]
+
+// @!has-dir local/use_crate
+// @has local/index.html
+// @has - '//code' 'pub use use_crate'
+pub use use_crate;
+
+// @has-dir local/asdf
+// @has local/asdf/index.html
+// @has local/index.html '//a/@href' 'asdf/index.html'
+pub use use_crate::asdf;
+
+// @has-dir local/use_crate_2
+// @has local/use_crate_2/index.html
+// @has local/index.html '//a/@href' 'use_crate_2/index.html'
+#[doc(inline)]
+pub use use_crate_2;
diff --git a/src/test/rustdoc/inline_local/glob-extern-no-defaults.rs b/src/test/rustdoc/inline_local/glob-extern-no-defaults.rs
new file mode 100644
index 0000000..276e409
--- /dev/null
+++ b/src/test/rustdoc/inline_local/glob-extern-no-defaults.rs
@@ -0,0 +1,25 @@
+// compile-flags: --no-defaults
+
+#![crate_name = "foo"]
+
+mod mod1 {
+    extern {
+        pub fn public_fn();
+        fn private_fn();
+    }
+}
+
+pub use mod1::*;
+
+// @has foo/index.html
+// @has - "mod1"
+// @has - "public_fn"
+// @!has - "private_fn"
+// @has foo/fn.public_fn.html
+// @!has foo/fn.private_fn.html
+
+// @has foo/mod1/index.html
+// @has - "public_fn"
+// @has - "private_fn"
+// @has foo/mod1/fn.public_fn.html
+// @has foo/mod1/fn.private_fn.html
diff --git a/src/test/rustdoc/inline_local/glob-extern.rs b/src/test/rustdoc/inline_local/glob-extern.rs
new file mode 100644
index 0000000..a23ec36
--- /dev/null
+++ b/src/test/rustdoc/inline_local/glob-extern.rs
@@ -0,0 +1,21 @@
+#![crate_name = "foo"]
+
+mod mod1 {
+    extern {
+        pub fn public_fn();
+        fn private_fn();
+    }
+}
+
+pub use mod1::*;
+
+// @has foo/index.html
+// @!has - "mod1"
+// @has - "public_fn"
+// @!has - "private_fn"
+// @has foo/fn.public_fn.html
+// @!has foo/fn.private_fn.html
+
+// @!has foo/mod1/index.html
+// @has foo/mod1/fn.public_fn.html
+// @!has foo/mod1/fn.private_fn.html
diff --git a/src/test/rustdoc/inline_local/glob-private-no-defaults.rs b/src/test/rustdoc/inline_local/glob-private-no-defaults.rs
new file mode 100644
index 0000000..ac854ac
--- /dev/null
+++ b/src/test/rustdoc/inline_local/glob-private-no-defaults.rs
@@ -0,0 +1,48 @@
+// compile-flags: --no-defaults
+
+#![crate_name = "foo"]
+
+mod mod1 {
+    mod mod2 {
+        pub struct Mod2Public;
+        struct Mod2Private;
+    }
+    pub use self::mod2::*;
+
+    pub struct Mod1Public;
+    struct Mod1Private;
+}
+pub use mod1::*;
+
+// @has foo/index.html
+// @has - "mod1"
+// @has - "Mod1Public"
+// @!has - "Mod1Private"
+// @!has - "mod2"
+// @has - "Mod2Public"
+// @!has - "Mod2Private"
+// @has foo/struct.Mod1Public.html
+// @!has foo/struct.Mod1Private.html
+// @has foo/struct.Mod2Public.html
+// @!has foo/struct.Mod2Private.html
+
+// @has foo/mod1/index.html
+// @has - "mod2"
+// @has - "Mod1Public"
+// @has - "Mod1Private"
+// @!has - "Mod2Public"
+// @!has - "Mod2Private"
+// @has foo/mod1/struct.Mod1Public.html
+// @has foo/mod1/struct.Mod1Private.html
+// @!has foo/mod1/struct.Mod2Public.html
+// @!has foo/mod1/struct.Mod2Private.html
+
+// @has foo/mod1/mod2/index.html
+// @has - "Mod2Public"
+// @has - "Mod2Private"
+// @has foo/mod1/mod2/struct.Mod2Public.html
+// @has foo/mod1/mod2/struct.Mod2Private.html
+
+// @!has foo/mod2/index.html
+// @!has foo/mod2/struct.Mod2Public.html
+// @!has foo/mod2/struct.Mod2Private.html
diff --git a/src/test/rustdoc/inline_local/glob-private.rs b/src/test/rustdoc/inline_local/glob-private.rs
new file mode 100644
index 0000000..d294d59
--- /dev/null
+++ b/src/test/rustdoc/inline_local/glob-private.rs
@@ -0,0 +1,42 @@
+#![crate_name = "foo"]
+
+mod mod1 {
+    mod mod2 {
+        pub struct Mod2Public;
+        struct Mod2Private;
+    }
+    pub use self::mod2::*;
+
+    pub struct Mod1Public;
+    struct Mod1Private;
+}
+pub use mod1::*;
+
+// @has foo/index.html
+// @!has - "mod1"
+// @has - "Mod1Public"
+// @!has - "Mod1Private"
+// @!has - "mod2"
+// @has - "Mod2Public"
+// @!has - "Mod2Private"
+// @has foo/struct.Mod1Public.html
+// @!has foo/struct.Mod1Private.html
+// @has foo/struct.Mod2Public.html
+// @!has foo/struct.Mod2Private.html
+
+// @has-dir foo/mod1
+// @!has foo/mod1/index.html
+// @has foo/mod1/struct.Mod1Public.html
+// @!has foo/mod1/struct.Mod1Private.html
+// @!has foo/mod1/struct.Mod2Public.html
+// @!has foo/mod1/struct.Mod2Private.html
+
+// @has-dir foo/mod1/mod2
+// @!has foo/mod1/mod2/index.html
+// @has foo/mod1/mod2/struct.Mod2Public.html
+// @!has foo/mod1/mod2/struct.Mod2Private.html
+
+// @!has-dir foo/mod2
+// @!has foo/mod2/index.html
+// @!has foo/mod2/struct.Mod2Public.html
+// @!has foo/mod2/struct.Mod2Private.html
diff --git a/src/test/rustdoc/inline_local/hidden-use.rs b/src/test/rustdoc/inline_local/hidden-use.rs
new file mode 100644
index 0000000..a972d37
--- /dev/null
+++ b/src/test/rustdoc/inline_local/hidden-use.rs
@@ -0,0 +1,10 @@
+mod private {
+    pub struct Foo {}
+}
+
+// @has hidden_use/index.html
+// @!has - 'private'
+// @!has - 'Foo'
+// @!has hidden_use/struct.Foo.html
+#[doc(hidden)]
+pub use private::Foo;
diff --git a/src/test/rustdoc/inline_local/issue-28537.rs b/src/test/rustdoc/inline_local/issue-28537.rs
new file mode 100644
index 0000000..da9cc4c
--- /dev/null
+++ b/src/test/rustdoc/inline_local/issue-28537.rs
@@ -0,0 +1,17 @@
+#[doc(hidden)]
+pub mod foo {
+    pub struct Foo;
+}
+
+mod bar {
+    pub use self::bar::Bar;
+    mod bar {
+        pub struct Bar;
+    }
+}
+
+// @has issue_28537/struct.Foo.html
+pub use foo::Foo;
+
+// @has issue_28537/struct.Bar.html
+pub use self::bar::Bar;
diff --git a/src/test/rustdoc/inline_local/issue-32343.rs b/src/test/rustdoc/inline_local/issue-32343.rs
new file mode 100644
index 0000000..5620ae0
--- /dev/null
+++ b/src/test/rustdoc/inline_local/issue-32343.rs
@@ -0,0 +1,23 @@
+// @!has issue_32343/struct.Foo.html
+// @has issue_32343/index.html
+// @has - '//code' 'pub use foo::Foo'
+// @!has - '//code/a' 'Foo'
+#[doc(no_inline)]
+pub use foo::Foo;
+
+// @!has issue_32343/struct.Bar.html
+// @has issue_32343/index.html
+// @has - '//code' 'pub use foo::Bar'
+// @has - '//code/a' 'Bar'
+#[doc(no_inline)]
+pub use foo::Bar;
+
+mod foo {
+    pub struct Foo;
+    pub struct Bar;
+}
+
+pub mod bar {
+    // @has issue_32343/bar/struct.Bar.html
+    pub use ::foo::Bar;
+}
diff --git a/src/test/rustdoc/inline_local/macro_by_example.rs b/src/test/rustdoc/inline_local/macro_by_example.rs
new file mode 100644
index 0000000..dacc7cf
--- /dev/null
+++ b/src/test/rustdoc/inline_local/macro_by_example.rs
@@ -0,0 +1,17 @@
+/// docs for foo
+#[deprecated(since = "1.2.3", note = "text")]
+#[macro_export]
+macro_rules! foo {
+    ($($tt:tt)*) => {}
+}
+
+// @has macro_by_example/macros/index.html
+pub mod macros {
+    // @!has - 'pub use foo as bar;'
+    // @has macro_by_example/macros/macro.bar.html
+    // @has - '//*[@class="docblock"]' 'docs for foo'
+    // @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.2.3: text'
+    // @has - '//a/@href' 'macro_by_example.rs.html#4-6'
+    #[doc(inline)]
+    pub use foo as bar;
+}
diff --git a/src/test/rustdoc/inline_local/please_inline.rs b/src/test/rustdoc/inline_local/please_inline.rs
new file mode 100644
index 0000000..4853936
--- /dev/null
+++ b/src/test/rustdoc/inline_local/please_inline.rs
@@ -0,0 +1,19 @@
+pub mod foo {
+    pub struct Foo;
+}
+
+// @has please_inline/a/index.html
+pub mod a {
+    // @!has - 'pub use foo::'
+    // @has please_inline/a/struct.Foo.html
+    #[doc(inline)]
+    pub use foo::Foo;
+}
+
+// @has please_inline/b/index.html
+pub mod b {
+    // @has - 'pub use foo::'
+    // @!has please_inline/b/struct.Foo.html
+    #[feature(inline)]
+    pub use foo::Foo;
+}
diff --git a/src/test/rustdoc/inline_local/trait-vis.rs b/src/test/rustdoc/inline_local/trait-vis.rs
new file mode 100644
index 0000000..a997d1e
--- /dev/null
+++ b/src/test/rustdoc/inline_local/trait-vis.rs
@@ -0,0 +1,18 @@
+pub trait ThisTrait {}
+
+mod asdf {
+    use ThisTrait;
+
+    pub struct SomeStruct;
+
+    impl ThisTrait for SomeStruct {}
+
+    trait PrivateTrait {}
+
+    impl PrivateTrait for SomeStruct {}
+}
+
+// @has trait_vis/struct.SomeStruct.html
+// @has - '//code' 'impl ThisTrait for SomeStruct'
+// !@has - '//code' 'impl PrivateTrait for SomeStruct'
+pub use asdf::SomeStruct;
diff --git a/src/test/rustdoc/internal.rs b/src/test/rustdoc/internal.rs
new file mode 100644
index 0000000..2cb7c47
--- /dev/null
+++ b/src/test/rustdoc/internal.rs
@@ -0,0 +1,12 @@
+// compile-flags: -Z force-unstable-if-unmarked
+
+// @matches internal/index.html '//*[@class="docblock-short"]/span[@class="stab internal"]' \
+//      'Internal'
+// @matches - '//*[@class="docblock-short"]' 'Docs'
+
+// @has internal/struct.S.html '//*[@class="stab internal"]' \
+//      'This is an internal compiler API. (rustc_private)'
+/// Docs
+pub struct S;
+
+fn main() {}
diff --git a/src/test/rustdoc/intra-link-extern-crate.rs b/src/test/rustdoc/intra-link-extern-crate.rs
new file mode 100644
index 0000000..bbe3eda
--- /dev/null
+++ b/src/test/rustdoc/intra-link-extern-crate.rs
@@ -0,0 +1,9 @@
+// aux-build:intra-link-extern-crate.rs
+
+// When loading `extern crate` statements, we would pull in their docs at the same time, even
+// though they would never actually get displayed. This tripped intra-doc-link resolution failures,
+// for items that aren't under our control, and not actually getting documented!
+
+#![deny(intra_doc_link_resolution_failure)]
+
+extern crate inner;
diff --git a/src/test/rustdoc/intra-link-in-bodies.rs b/src/test/rustdoc/intra-link-in-bodies.rs
new file mode 100644
index 0000000..4c69390
--- /dev/null
+++ b/src/test/rustdoc/intra-link-in-bodies.rs
@@ -0,0 +1,30 @@
+// we need to make sure that intra-doc links on trait impls get resolved in the right scope
+
+#![deny(intra_doc_link_resolution_failure)]
+
+pub mod inner {
+    pub struct SomethingOutOfScope;
+}
+
+pub mod other {
+    use inner::SomethingOutOfScope;
+    use SomeTrait;
+
+    pub struct OtherStruct;
+
+    /// Let's link to [SomethingOutOfScope] while we're at it.
+    impl SomeTrait for OtherStruct {}
+}
+
+pub trait SomeTrait {}
+
+pub struct SomeStruct;
+
+fn __implementation_details() {
+    use inner::SomethingOutOfScope;
+
+    // FIXME: intra-links resolve in their nearest module scope, not their actual scope in cases
+    // like this
+    // Let's link to [SomethingOutOfScope] while we're at it.
+    impl SomeTrait for SomeStruct {}
+}
diff --git a/src/test/rustdoc/intra-link-prim-methods.rs b/src/test/rustdoc/intra-link-prim-methods.rs
new file mode 100644
index 0000000..af0426b
--- /dev/null
+++ b/src/test/rustdoc/intra-link-prim-methods.rs
@@ -0,0 +1,3 @@
+#![deny(intra_doc_link_resolution_failure)]
+
+//! A [`char`] and its [`char::len_utf8`].
diff --git a/src/test/rustdoc/intra-link-private.rs b/src/test/rustdoc/intra-link-private.rs
new file mode 100644
index 0000000..c99b4d7
--- /dev/null
+++ b/src/test/rustdoc/intra-link-private.rs
@@ -0,0 +1,8 @@
+// Rustdoc would previously report resolution failures on items that weren't in the public docs.
+// These failures were legitimate, but not truly relevant - the docs in question couldn't be
+// checked for accuracy anyway.
+
+#![deny(intra_doc_link_resolution_failure)]
+
+/// ooh, i'm a [rebel] just for kicks
+struct SomeStruct;
diff --git a/src/test/rustdoc/intra-link-self.rs b/src/test/rustdoc/intra-link-self.rs
new file mode 100644
index 0000000..acf975f
--- /dev/null
+++ b/src/test/rustdoc/intra-link-self.rs
@@ -0,0 +1,29 @@
+#![crate_name = "foo"]
+
+// @has foo/index.html '//a/@href' '../foo/struct.Foo.html#method.new'
+// @has foo/struct.Foo.html '//a/@href' '../foo/struct.Foo.html#method.new'
+
+/// Use [`new`] to create a new instance.
+///
+/// [`new`]: Self::new
+pub struct Foo;
+
+impl Foo {
+    pub fn new() -> Self {
+        unimplemented!()
+    }
+}
+
+// @has foo/index.html '//a/@href' '../foo/struct.Bar.html#method.new2'
+// @has foo/struct.Bar.html '//a/@href' '../foo/struct.Bar.html#method.new2'
+
+/// Use [`new2`] to create a new instance.
+///
+/// [`new2`]: Self::new2
+pub struct Bar;
+
+impl Bar {
+    pub fn new2() -> Self {
+        unimplemented!()
+    }
+}
diff --git a/src/test/rustdoc/intra-links.rs b/src/test/rustdoc/intra-links.rs
new file mode 100644
index 0000000..c356ab3
--- /dev/null
+++ b/src/test/rustdoc/intra-links.rs
@@ -0,0 +1,82 @@
+// @has intra_links/index.html
+// @has - '//a/@href' '../intra_links/struct.ThisType.html'
+// @has - '//a/@href' '../intra_links/struct.ThisType.html#method.this_method'
+// @has - '//a/@href' '../intra_links/enum.ThisEnum.html'
+// @has - '//a/@href' '../intra_links/enum.ThisEnum.html#ThisVariant.v'
+// @has - '//a/@href' '../intra_links/trait.ThisTrait.html'
+// @has - '//a/@href' '../intra_links/trait.ThisTrait.html#tymethod.this_associated_method'
+// @has - '//a/@href' '../intra_links/trait.ThisTrait.html#associatedtype.ThisAssociatedType'
+// @has - '//a/@href' '../intra_links/trait.ThisTrait.html#associatedconstant.THIS_ASSOCIATED_CONST'
+// @has - '//a/@href' '../intra_links/trait.ThisTrait.html'
+// @has - '//a/@href' '../intra_links/type.ThisAlias.html'
+// @has - '//a/@href' '../intra_links/union.ThisUnion.html'
+// @has - '//a/@href' '../intra_links/fn.this_function.html'
+// @has - '//a/@href' '../intra_links/constant.THIS_CONST.html'
+// @has - '//a/@href' '../intra_links/static.THIS_STATIC.html'
+// @has - '//a/@href' '../intra_links/macro.this_macro.html'
+// @has - '//a/@href' '../intra_links/trait.SoAmbiguous.html'
+// @has - '//a/@href' '../intra_links/fn.SoAmbiguous.html'
+//! In this crate we would like to link to:
+//!
+//! * [`ThisType`](ThisType)
+//! * [`ThisType::this_method`](ThisType::this_method)
+//! * [`ThisEnum`](ThisEnum)
+//! * [`ThisEnum::ThisVariant`](ThisEnum::ThisVariant)
+//! * [`ThisEnum::ThisVariantCtor`](ThisEnum::ThisVariantCtor)
+//! * [`ThisTrait`](ThisTrait)
+//! * [`ThisTrait::this_associated_method`](ThisTrait::this_associated_method)
+//! * [`ThisTrait::ThisAssociatedType`](ThisTrait::ThisAssociatedType)
+//! * [`ThisTrait::THIS_ASSOCIATED_CONST`](ThisTrait::THIS_ASSOCIATED_CONST)
+//! * [`ThisAlias`](ThisAlias)
+//! * [`ThisUnion`](ThisUnion)
+//! * [`this_function`](this_function())
+//! * [`THIS_CONST`](const@THIS_CONST)
+//! * [`THIS_STATIC`](static@THIS_STATIC)
+//! * [`this_macro`](this_macro!)
+//!
+//! In addition, there's some specifics we want to look at. There's [a trait called
+//! SoAmbiguous][ambig-trait], but there's also [a function called SoAmbiguous][ambig-fn] too!
+//! Whatever shall we do?
+//!
+//! [ambig-trait]: trait@SoAmbiguous
+//! [ambig-fn]: SoAmbiguous()
+
+#[macro_export]
+macro_rules! this_macro {
+    () => {};
+}
+
+pub struct ThisType;
+
+impl ThisType {
+    pub fn this_method() {}
+}
+pub enum ThisEnum { ThisVariant, ThisVariantCtor(u32), }
+pub trait ThisTrait {
+    type ThisAssociatedType;
+    const THIS_ASSOCIATED_CONST: u8;
+    fn this_associated_method();
+}
+pub type ThisAlias = Result<(), ()>;
+pub union ThisUnion { this_field: usize, }
+
+pub fn this_function() {}
+pub const THIS_CONST: usize = 5usize;
+pub static THIS_STATIC: usize = 5usize;
+
+pub trait SoAmbiguous {}
+
+#[allow(nonstandard_style)]
+pub fn SoAmbiguous() {}
+
+
+// @has - '//a/@href' '../intra_links/struct.ThisType.html'
+// @has - '//a/@href' '../intra_links/struct.ThisType.html#method.this_method'
+// @has - '//a/@href' '../intra_links/enum.ThisEnum.html'
+// @has - '//a/@href' '../intra_links/enum.ThisEnum.html#ThisVariant.v'
+/// Shortcut links for:
+/// * [`ThisType`]
+/// * [`ThisType::this_method`]
+/// * [ThisEnum]
+/// * [ThisEnum::ThisVariant]
+pub struct SomeOtherType;
diff --git a/src/test/rustdoc/invalid.crate.name.rs b/src/test/rustdoc/invalid.crate.name.rs
new file mode 100644
index 0000000..c19713b
--- /dev/null
+++ b/src/test/rustdoc/invalid.crate.name.rs
@@ -0,0 +1,3 @@
+// compile-flags: --crate-name foo
+
+pub fn foo() {}
diff --git a/src/test/rustdoc/issue-12834.rs b/src/test/rustdoc/issue-12834.rs
new file mode 100644
index 0000000..558009e
--- /dev/null
+++ b/src/test/rustdoc/issue-12834.rs
@@ -0,0 +1,11 @@
+// Tests that failing to syntax highlight a rust code-block doesn't cause
+// rustdoc to fail, while still rendering the code-block (without highlighting).
+
+
+// @has issue_12834/fn.foo.html
+// @has - //pre 'a + b '
+
+/// ```
+/// a + b ∈ Self ∀ a, b ∈ Self
+/// ```
+pub fn foo() {}
diff --git a/src/test/rustdoc/issue-13698.rs b/src/test/rustdoc/issue-13698.rs
new file mode 100644
index 0000000..3046a8a
--- /dev/null
+++ b/src/test/rustdoc/issue-13698.rs
@@ -0,0 +1,16 @@
+// aux-build:issue-13698.rs
+// ignore-cross-compile
+
+extern crate issue_13698;
+
+pub struct Foo;
+// @!has issue_13698/struct.Foo.html '//*[@id="method.foo"]' 'fn foo'
+impl issue_13698::Foo for Foo {}
+
+pub trait Bar {
+    #[doc(hidden)]
+    fn bar(&self) {}
+}
+
+// @!has issue_13698/struct.Foo.html '//*[@id="method.bar"]' 'fn bar'
+impl Bar for Foo {}
diff --git a/src/test/rustdoc/issue-15169.rs b/src/test/rustdoc/issue-15169.rs
new file mode 100644
index 0000000..e525d85
--- /dev/null
+++ b/src/test/rustdoc/issue-15169.rs
@@ -0,0 +1,3 @@
+// @has issue_15169/struct.Foo.html '//*[@id="method.eq"]' 'fn eq'
+#[derive(PartialEq)]
+pub struct Foo;
diff --git a/src/test/rustdoc/issue-15318-2.rs b/src/test/rustdoc/issue-15318-2.rs
new file mode 100644
index 0000000..1dbfba9
--- /dev/null
+++ b/src/test/rustdoc/issue-15318-2.rs
@@ -0,0 +1,12 @@
+// aux-build:issue-15318.rs
+// ignore-cross-compile
+
+extern crate issue_15318;
+
+pub use issue_15318::ptr;
+
+// @has issue_15318_2/fn.bar.html \
+//          '//*[@href="primitive.pointer.html"]' \
+//          '*mut T'
+pub fn bar<T>(ptr: *mut T) {}
+
diff --git a/src/test/rustdoc/issue-15318-3.rs b/src/test/rustdoc/issue-15318-3.rs
new file mode 100644
index 0000000..1f7443a
--- /dev/null
+++ b/src/test/rustdoc/issue-15318-3.rs
@@ -0,0 +1,5 @@
+// @has issue_15318_3/primitive.pointer.html
+
+/// dox
+#[doc(primitive = "pointer")]
+pub mod ptr {}
diff --git a/src/test/rustdoc/issue-15318.rs b/src/test/rustdoc/issue-15318.rs
new file mode 100644
index 0000000..0349fe2
--- /dev/null
+++ b/src/test/rustdoc/issue-15318.rs
@@ -0,0 +1,11 @@
+// aux-build:issue-15318.rs
+// ignore-cross-compile
+
+#![no_std]
+
+extern crate issue_15318;
+
+// @has issue_15318/fn.bar.html \
+//      '//*[@href="http://example.com/issue_15318/primitive.pointer.html"]' \
+//      '*mut T'
+pub fn bar<T>(ptr: *mut T) {}
diff --git a/src/test/rustdoc/issue-15347.rs b/src/test/rustdoc/issue-15347.rs
new file mode 100644
index 0000000..fa67da8
--- /dev/null
+++ b/src/test/rustdoc/issue-15347.rs
@@ -0,0 +1,5 @@
+// compile-flags: --no-defaults --passes collapse-docs --passes unindent-comments
+
+// @has issue_15347/fn.foo.html
+#[doc(hidden)]
+pub fn foo() {}
diff --git a/src/test/rustdoc/issue-16019.rs b/src/test/rustdoc/issue-16019.rs
new file mode 100644
index 0000000..239d923
--- /dev/null
+++ b/src/test/rustdoc/issue-16019.rs
@@ -0,0 +1,9 @@
+macro_rules! define_struct {
+    ($rounds:expr) => (
+        struct Struct {
+            sk: [u32; $rounds + 1]
+        }
+        )
+}
+
+define_struct!(2);
diff --git a/src/test/rustdoc/issue-16265-1.rs b/src/test/rustdoc/issue-16265-1.rs
new file mode 100644
index 0000000..653fd4c
--- /dev/null
+++ b/src/test/rustdoc/issue-16265-1.rs
@@ -0,0 +1,8 @@
+pub struct Foo;
+
+// @has issue_16265_1/traits/index.html '[src]'
+pub mod traits {
+    impl PartialEq for super::Foo {
+        fn eq(&self, _: &super::Foo) -> bool { true }
+    }
+}
diff --git a/src/test/rustdoc/issue-16265-2.rs b/src/test/rustdoc/issue-16265-2.rs
new file mode 100644
index 0000000..00453a3
--- /dev/null
+++ b/src/test/rustdoc/issue-16265-2.rs
@@ -0,0 +1,4 @@
+// @has issue_16265_2/index.html '[src]'
+
+trait Y {}
+impl Y for Option<u32>{}
diff --git a/src/test/rustdoc/issue-17476.rs b/src/test/rustdoc/issue-17476.rs
new file mode 100644
index 0000000..a5b484c
--- /dev/null
+++ b/src/test/rustdoc/issue-17476.rs
@@ -0,0 +1,11 @@
+// aux-build:issue-17476.rs
+// ignore-cross-compile
+
+extern crate issue_17476;
+
+pub struct Foo;
+
+// @has issue_17476/struct.Foo.html \
+//      '//*[@href="http://example.com/issue_17476/trait.Foo.html#method.foo"]' \
+//      'foo'
+impl issue_17476::Foo for Foo {}
diff --git a/src/test/rustdoc/issue-18199.rs b/src/test/rustdoc/issue-18199.rs
new file mode 100644
index 0000000..bc0c4a5
--- /dev/null
+++ b/src/test/rustdoc/issue-18199.rs
@@ -0,0 +1,9 @@
+// compile-flags:--test
+
+#![doc(test(attr(feature(staged_api))))]
+
+/// ```
+/// #![unstable(feature="test", issue="18199")]
+/// fn main() {}
+/// ```
+pub fn foo() {}
diff --git a/src/test/rustdoc/issue-19055.rs b/src/test/rustdoc/issue-19055.rs
new file mode 100644
index 0000000..dbaf744
--- /dev/null
+++ b/src/test/rustdoc/issue-19055.rs
@@ -0,0 +1,20 @@
+// @has issue_19055/trait.Any.html
+pub trait Any {}
+
+impl<'any> Any + 'any {
+    // @has - '//*[@id="method.is"]' 'fn is'
+    pub fn is<T: 'static>(&self) -> bool { loop {} }
+
+    // @has - '//*[@id="method.downcast_ref"]' 'fn downcast_ref'
+    pub fn downcast_ref<T: 'static>(&self) -> Option<&T> { loop {} }
+
+    // @has - '//*[@id="method.downcast_mut"]' 'fn downcast_mut'
+    pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T> { loop {} }
+}
+
+pub trait Foo {
+    fn foo(&self) {}
+}
+
+// @has - '//*[@id="method.foo"]' 'fn foo'
+impl Foo for Any {}
diff --git a/src/test/rustdoc/issue-19181.rs b/src/test/rustdoc/issue-19181.rs
new file mode 100644
index 0000000..3dea152
--- /dev/null
+++ b/src/test/rustdoc/issue-19181.rs
@@ -0,0 +1,5 @@
+// compile-flags:--test
+
+// rustdoc should not panic when target crate has compilation errors
+
+fn main() { 0 }
diff --git a/src/test/rustdoc/issue-19190-2.rs b/src/test/rustdoc/issue-19190-2.rs
new file mode 100644
index 0000000..b6416e2
--- /dev/null
+++ b/src/test/rustdoc/issue-19190-2.rs
@@ -0,0 +1,12 @@
+use std::ops::Deref;
+
+pub struct Bar;
+
+impl Deref for Bar {
+    type Target = String;
+    fn deref(&self) -> &String { loop {} }
+}
+
+// @has issue_19190_2/struct.Bar.html
+// @!has - '//*[@id="method.new"]' 'fn new() -> String'
+// @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str'
diff --git a/src/test/rustdoc/issue-19190-3.rs b/src/test/rustdoc/issue-19190-3.rs
new file mode 100644
index 0000000..f736630
--- /dev/null
+++ b/src/test/rustdoc/issue-19190-3.rs
@@ -0,0 +1,28 @@
+// aux-build:issue-19190-3.rs
+// ignore-cross-compile
+
+extern crate issue_19190_3;
+
+use std::ops::Deref;
+use issue_19190_3::Baz;
+
+// @has issue_19190_3/struct.Foo.html
+// @has - '//*[@id="method.as_str"]' 'fn as_str(&self) -> &str'
+// @!has - '//*[@id="method.new"]' 'fn new() -> String'
+pub use issue_19190_3::Foo;
+
+// @has issue_19190_3/struct.Bar.html
+// @has - '//*[@id="method.baz"]' 'fn baz(&self)'
+// @!has - '//*[@id="method.static_baz"]' 'fn static_baz()'
+pub use issue_19190_3::Bar;
+
+// @has issue_19190_3/struct.MyBar.html
+// @has - '//*[@id="method.baz"]' 'fn baz(&self)'
+// @!has - '//*[@id="method.static_baz"]' 'fn static_baz()'
+pub struct MyBar;
+
+impl Deref for MyBar {
+    type Target = Baz;
+    fn deref(&self) -> &Baz { loop {} }
+}
+
diff --git a/src/test/rustdoc/issue-19190.rs b/src/test/rustdoc/issue-19190.rs
new file mode 100644
index 0000000..c6bac51
--- /dev/null
+++ b/src/test/rustdoc/issue-19190.rs
@@ -0,0 +1,23 @@
+// compile-flags:-Z unstable-options --generate-redirect-pages
+
+use std::ops::Deref;
+
+pub struct Foo;
+pub struct Bar;
+
+impl Foo {
+    pub fn foo(&self) {}
+    pub fn static_foo() {}
+}
+
+impl Deref for Bar {
+    type Target = Foo;
+    fn deref(&self) -> &Foo { loop {} }
+}
+
+// @has issue_19190/Bar.t.html
+// @has issue_19190/struct.Bar.html
+// @has - '//*[@id="foo.v"]' 'fn foo(&self)'
+// @has - '//*[@id="method.foo"]' 'fn foo(&self)'
+// @!has - '//*[@id="static_foo.v"]' 'fn static_foo()'
+// @!has - '//*[@id="method.static_foo"]' 'fn static_foo()'
diff --git a/src/test/rustdoc/issue-20175.rs b/src/test/rustdoc/issue-20175.rs
new file mode 100644
index 0000000..6a42e2a
--- /dev/null
+++ b/src/test/rustdoc/issue-20175.rs
@@ -0,0 +1,10 @@
+pub trait Foo {
+    fn foo(&self) {}
+}
+
+pub struct Bar;
+
+// @has issue_20175/struct.Bar.html \
+//      '//*[@id="method.foo"]' \
+//      'fn foo'
+impl<'a> Foo for &'a Bar {}
diff --git a/src/test/rustdoc/issue-20646.rs b/src/test/rustdoc/issue-20646.rs
new file mode 100644
index 0000000..2589e27
--- /dev/null
+++ b/src/test/rustdoc/issue-20646.rs
@@ -0,0 +1,26 @@
+// aux-build:issue-20646.rs
+// ignore-cross-compile
+
+#![feature(associated_types)]
+
+extern crate issue_20646;
+
+// @has issue_20646/trait.Trait.html \
+//      '//*[@id="associatedtype.Output"]' \
+//      'type Output'
+pub trait Trait {
+    type Output;
+}
+
+// @has issue_20646/fn.fun.html \
+//      '//*[@class="rust fn"]' 'where T: Trait<Output = i32>'
+pub fn fun<T>(_: T) where T: Trait<Output=i32> {}
+
+pub mod reexport {
+    // @has issue_20646/reexport/trait.Trait.html \
+    //      '//*[@id="associatedtype.Output"]' \
+    //      'type Output'
+    // @has issue_20646/reexport/fn.fun.html \
+    //      '//*[@class="rust fn"]' 'where T: Trait<Output = i32>'
+    pub use issue_20646::{Trait, fun};
+}
diff --git a/src/test/rustdoc/issue-20727-2.rs b/src/test/rustdoc/issue-20727-2.rs
new file mode 100644
index 0000000..7c8b82f
--- /dev/null
+++ b/src/test/rustdoc/issue-20727-2.rs
@@ -0,0 +1,23 @@
+// aux-build:issue-20727.rs
+// ignore-cross-compile
+
+extern crate issue_20727;
+
+// @has issue_20727_2/trait.Add.html
+pub trait Add<RHS = Self> {
+    // @has - '//*[@class="rust trait"]' 'trait Add<RHS = Self> {'
+    // @has - '//*[@class="rust trait"]' 'type Output;'
+    type Output;
+
+    // @has - '//*[@class="rust trait"]' 'fn add(self, rhs: RHS) -> Self::Output;'
+    fn add(self, rhs: RHS) -> Self::Output;
+}
+
+// @has issue_20727_2/reexport/trait.Add.html
+pub mod reexport {
+    // @has - '//*[@class="rust trait"]' 'trait Add<RHS = Self> {'
+    // @has - '//*[@class="rust trait"]' 'type Output;'
+    // @has - '//*[@class="rust trait"]' 'fn add(self, rhs: RHS) -> Self::Output;'
+    pub use issue_20727::Add;
+}
+
diff --git a/src/test/rustdoc/issue-20727-3.rs b/src/test/rustdoc/issue-20727-3.rs
new file mode 100644
index 0000000..52032b7
--- /dev/null
+++ b/src/test/rustdoc/issue-20727-3.rs
@@ -0,0 +1,24 @@
+// aux-build:issue-20727.rs
+// ignore-cross-compile
+
+extern crate issue_20727;
+
+pub trait Bar {}
+
+// @has issue_20727_3/trait.Deref2.html
+pub trait Deref2 {
+    // @has - '//*[@class="rust trait"]' 'trait Deref2 {'
+    // @has - '//*[@class="rust trait"]' 'type Target: Bar;'
+    type Target: Bar;
+
+    // @has - '//*[@class="rust trait"]' 'fn deref(&self) -> Self::Target;'
+    fn deref(&self) -> Self::Target;
+}
+
+// @has issue_20727_3/reexport/trait.Deref2.html
+pub mod reexport {
+    // @has - '//*[@class="rust trait"]' 'trait Deref2 {'
+    // @has - '//*[@class="rust trait"]' 'type Target: Bar;'
+    // @has - '//*[@class="rust trait"]' 'fn deref(&self) -> Self::Target;'
+    pub use issue_20727::Deref2;
+}
diff --git a/src/test/rustdoc/issue-20727-4.rs b/src/test/rustdoc/issue-20727-4.rs
new file mode 100644
index 0000000..84fc6f9
--- /dev/null
+++ b/src/test/rustdoc/issue-20727-4.rs
@@ -0,0 +1,40 @@
+// aux-build:issue-20727.rs
+// ignore-cross-compile
+
+extern crate issue_20727;
+
+// @has issue_20727_4/trait.Index.html
+pub trait Index<Idx: ?Sized> {
+    // @has - '//*[@class="rust trait"]' 'trait Index<Idx: ?Sized> {'
+    // @has - '//*[@class="rust trait"]' 'type Output: ?Sized'
+    type Output: ?Sized;
+
+    // @has - '//*[@class="rust trait"]' \
+    //        'fn index(&self, index: Idx) -> &Self::Output'
+    fn index(&self, index: Idx) -> &Self::Output;
+}
+
+// @has issue_20727_4/trait.IndexMut.html
+pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
+    // @has - '//*[@class="rust trait"]' \
+    //        'trait IndexMut<Idx: ?Sized>: Index<Idx> {'
+    // @has - '//*[@class="rust trait"]' \
+    //        'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;'
+    fn index_mut(&mut self, index: Idx) -> &mut Self::Output;
+}
+
+pub mod reexport {
+    // @has issue_20727_4/reexport/trait.Index.html
+    // @has - '//*[@class="rust trait"]' 'trait Index<Idx> where Idx: ?Sized, {'
+    // @has - '//*[@class="rust trait"]' 'type Output: ?Sized'
+    // @has - '//*[@class="rust trait"]' \
+    //        'fn index(&self, index: Idx) -> &Self::Output'
+    pub use issue_20727::Index;
+
+    // @has issue_20727_4/reexport/trait.IndexMut.html
+    // @has - '//*[@class="rust trait"]' \
+    //        'trait IndexMut<Idx>: Index<Idx> where Idx: ?Sized, {'
+    // @has - '//*[@class="rust trait"]' \
+    //        'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;'
+    pub use issue_20727::IndexMut;
+}
diff --git a/src/test/rustdoc/issue-20727.rs b/src/test/rustdoc/issue-20727.rs
new file mode 100644
index 0000000..f7acffc
--- /dev/null
+++ b/src/test/rustdoc/issue-20727.rs
@@ -0,0 +1,24 @@
+// aux-build:issue-20727.rs
+// ignore-cross-compile
+
+extern crate issue_20727;
+
+// @has issue_20727/trait.Deref.html
+pub trait Deref {
+    // @has - '//*[@class="rust trait"]' 'trait Deref {'
+    // @has - '//*[@class="rust trait"]' 'type Target: ?Sized;'
+    type Target: ?Sized;
+
+    // @has - '//*[@class="rust trait"]' \
+    //        "fn deref<'a>(&'a self) -> &'a Self::Target;"
+    fn deref<'a>(&'a self) -> &'a Self::Target;
+}
+
+// @has issue_20727/reexport/trait.Deref.html
+pub mod reexport {
+    // @has - '//*[@class="rust trait"]' 'trait Deref {'
+    // @has - '//*[@class="rust trait"]' 'type Target: ?Sized;'
+    // @has - '//*[@class="rust trait"]' \
+    //      "fn deref(&'a self) -> &'a Self::Target;"
+    pub use issue_20727::Deref;
+}
diff --git a/src/test/rustdoc/issue-21092.rs b/src/test/rustdoc/issue-21092.rs
new file mode 100644
index 0000000..b054145
--- /dev/null
+++ b/src/test/rustdoc/issue-21092.rs
@@ -0,0 +1,8 @@
+// aux-build:issue-21092.rs
+// ignore-cross-compile
+
+extern crate issue_21092;
+
+// @has issue_21092/struct.Bar.html
+// @has - '//*[@id="associatedtype.Bar"]' 'type Bar = i32'
+pub use issue_21092::{Foo, Bar};
diff --git a/src/test/rustdoc/issue-21474.rs b/src/test/rustdoc/issue-21474.rs
new file mode 100644
index 0000000..4c530f7
--- /dev/null
+++ b/src/test/rustdoc/issue-21474.rs
@@ -0,0 +1,11 @@
+pub use inner::*;
+
+mod inner {
+    impl super::Blah for super::What { }
+}
+
+pub trait Blah { }
+
+// @count issue_21474/struct.What.html \
+//        '//*[@id="implementations-list"]/*[@class="impl"]' 1
+pub struct What;
diff --git a/src/test/rustdoc/issue-21801.rs b/src/test/rustdoc/issue-21801.rs
new file mode 100644
index 0000000..2a586b6
--- /dev/null
+++ b/src/test/rustdoc/issue-21801.rs
@@ -0,0 +1,9 @@
+// aux-build:issue-21801.rs
+// ignore-cross-compile
+
+extern crate issue_21801;
+
+// @has issue_21801/struct.Foo.html
+// @has - '//*[@id="method.new"]' \
+//        'fn new<F>(f: F) -> Foo where F: FnMut() -> i32'
+pub use issue_21801::Foo;
diff --git a/src/test/rustdoc/issue-22025.rs b/src/test/rustdoc/issue-22025.rs
new file mode 100644
index 0000000..a721a15
--- /dev/null
+++ b/src/test/rustdoc/issue-22025.rs
@@ -0,0 +1,6 @@
+// aux-build:issue-22025.rs
+// ignore-cross-compile
+
+extern crate issue_22025;
+
+pub use issue_22025::foo::{Foo, Bar};
diff --git a/src/test/rustdoc/issue-22038.rs b/src/test/rustdoc/issue-22038.rs
new file mode 100644
index 0000000..2db42b5
--- /dev/null
+++ b/src/test/rustdoc/issue-22038.rs
@@ -0,0 +1,19 @@
+extern {
+    // @has issue_22038/fn.foo1.html \
+    //      '//*[@class="rust fn"]' 'pub unsafe extern "C" fn foo1()'
+    pub fn foo1();
+}
+
+extern "system" {
+    // @has issue_22038/fn.foo2.html \
+    //      '//*[@class="rust fn"]' 'pub unsafe extern "system" fn foo2()'
+    pub fn foo2();
+}
+
+// @has issue_22038/fn.bar.html \
+//      '//*[@class="rust fn"]' 'pub extern "C" fn bar()'
+pub extern fn bar() {}
+
+// @has issue_22038/fn.baz.html \
+//      '//*[@class="rust fn"]' 'pub extern "system" fn baz()'
+pub extern "system" fn baz() {}
diff --git a/src/test/rustdoc/issue-23106.rs b/src/test/rustdoc/issue-23106.rs
new file mode 100644
index 0000000..8cda2fc
--- /dev/null
+++ b/src/test/rustdoc/issue-23106.rs
@@ -0,0 +1,7 @@
+// compile-flags:--test
+
+/// ```
+/// #
+/// ```
+pub fn main() {
+}
diff --git a/src/test/rustdoc/issue-23207.rs b/src/test/rustdoc/issue-23207.rs
new file mode 100644
index 0000000..747c59b
--- /dev/null
+++ b/src/test/rustdoc/issue-23207.rs
@@ -0,0 +1,10 @@
+// aux-build:issue-23207-1.rs
+// aux-build:issue-23207-2.rs
+// ignore-cross-compile
+
+extern crate issue_23207_2;
+
+// @has issue_23207/fmt/index.html
+// @count - '//*[@class="struct"]' 1
+pub use issue_23207_2::fmt;
+
diff --git a/src/test/rustdoc/issue-23511.rs b/src/test/rustdoc/issue-23511.rs
new file mode 100644
index 0000000..4972a9f
--- /dev/null
+++ b/src/test/rustdoc/issue-23511.rs
@@ -0,0 +1,12 @@
+#![feature(lang_items)]
+#![no_std]
+
+pub mod str {
+    #![doc(primitive = "str")]
+
+    #[lang = "str_alloc"]
+    impl str {
+        // @has search-index.js foo
+        pub fn foo(&self) {}
+    }
+}
diff --git a/src/test/rustdoc/issue-23744.rs b/src/test/rustdoc/issue-23744.rs
new file mode 100644
index 0000000..6428173
--- /dev/null
+++ b/src/test/rustdoc/issue-23744.rs
@@ -0,0 +1,12 @@
+// compile-flags:--test
+
+/// Example of rustdoc incorrectly parsing <code>```rust,should_panic</code>.
+///
+/// ```should_panic
+/// fn main() { panic!("fee"); }
+/// ```
+///
+/// ```rust,should_panic
+/// fn main() { panic!("fum"); }
+/// ```
+pub fn foo() {}
diff --git a/src/test/rustdoc/issue-23812.rs b/src/test/rustdoc/issue-23812.rs
new file mode 100644
index 0000000..5dac8d8
--- /dev/null
+++ b/src/test/rustdoc/issue-23812.rs
@@ -0,0 +1,36 @@
+macro_rules! doc {
+    (#[$outer:meta] mod $i:ident { #![$inner:meta] }) =>
+    (
+        #[$outer]
+        pub mod $i {
+            #![$inner]
+        }
+    )
+}
+
+doc! {
+    /// Outer comment
+    mod Foo {
+        //! Inner comment
+    }
+}
+
+// @has issue_23812/Foo/index.html
+// @has - 'Outer comment'
+// @!has - '/// Outer comment'
+// @has - 'Inner comment'
+// @!has - '//! Inner comment'
+
+
+doc! {
+    /** Outer block comment */
+    mod Bar {
+        /*! Inner block comment */
+    }
+}
+
+// @has issue_23812/Bar/index.html
+// @has - 'Outer block comment'
+// @!has - '/** Outer block comment */'
+// @has - 'Inner block comment'
+// @!has - '/*! Inner block comment */'
diff --git a/src/test/rustdoc/issue-25001.rs b/src/test/rustdoc/issue-25001.rs
new file mode 100644
index 0000000..55d8ee3
--- /dev/null
+++ b/src/test/rustdoc/issue-25001.rs
@@ -0,0 +1,46 @@
+// @has issue_25001/struct.Foo.html
+pub struct Foo<T>(T);
+
+pub trait Bar {
+    type Item;
+
+    fn quux(self);
+}
+
+impl Foo<u8> {
+    // @has - '//*[@id="method.pass"]//code' 'fn pass()'
+    // @has - '//code[@id="pass.v"]' 'fn pass()'
+    pub fn pass() {}
+}
+impl Foo<u16> {
+    // @has - '//*[@id="method.pass-1"]//code' 'fn pass() -> usize'
+    // @has - '//code[@id="pass.v-1"]' 'fn pass() -> usize'
+    pub fn pass() -> usize { 42 }
+}
+impl Foo<u32> {
+    // @has - '//*[@id="method.pass-2"]//code' 'fn pass() -> isize'
+    // @has - '//code[@id="pass.v-2"]' 'fn pass() -> isize'
+    pub fn pass() -> isize { 42 }
+}
+
+impl<T> Bar for Foo<T> {
+    // @has - '//*[@id="associatedtype.Item"]//code' 'type Item = T'
+    type Item=T;
+
+    // @has - '//*[@id="method.quux"]//code' 'fn quux(self)'
+    fn quux(self) {}
+}
+impl<'a, T> Bar for &'a Foo<T> {
+    // @has - '//*[@id="associatedtype.Item-1"]//code' "type Item = &'a T"
+    type Item=&'a T;
+
+    // @has - '//*[@id="method.quux-1"]//code' 'fn quux(self)'
+    fn quux(self) {}
+}
+impl<'a, T> Bar for &'a mut Foo<T> {
+    // @has - '//*[@id="associatedtype.Item-2"]//code' "type Item = &'a mut T"
+    type Item=&'a mut T;
+
+    // @has - '//*[@id="method.quux-2"]//code' 'fn quux(self)'
+    fn quux(self) {}
+}
diff --git a/src/test/rustdoc/issue-25944.rs b/src/test/rustdoc/issue-25944.rs
new file mode 100644
index 0000000..4962529
--- /dev/null
+++ b/src/test/rustdoc/issue-25944.rs
@@ -0,0 +1,11 @@
+// compile-flags:--test
+
+/// ```
+/// let a = r#"
+/// foo
+/// bar"#;
+/// let b = "\nfoo\nbar";
+/// assert_eq!(a, b);
+/// ```
+pub fn main() {
+}
diff --git a/src/test/rustdoc/issue-26606.rs b/src/test/rustdoc/issue-26606.rs
new file mode 100644
index 0000000..6de419e
--- /dev/null
+++ b/src/test/rustdoc/issue-26606.rs
@@ -0,0 +1,11 @@
+// aux-build:issue-26606-macro.rs
+// ignore-cross-compile
+// build-aux-docs
+
+// @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/'
+make_item!(FOO);
diff --git a/src/test/rustdoc/issue-26995.rs b/src/test/rustdoc/issue-26995.rs
new file mode 100644
index 0000000..fedc9f5
--- /dev/null
+++ b/src/test/rustdoc/issue-26995.rs
@@ -0,0 +1,7 @@
+// ignore-windows
+// compile-flags: --no-defaults
+
+// @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/src/test/rustdoc/issue-27104.rs b/src/test/rustdoc/issue-27104.rs
new file mode 100644
index 0000000..b74c3eb
--- /dev/null
+++ b/src/test/rustdoc/issue-27104.rs
@@ -0,0 +1,10 @@
+// compile-flags:--no-defaults --passes strip-priv-imports
+// aux-build:empty.rs
+// ignore-cross-compile
+
+// @has issue_27104/index.html
+// @!has - 'extern crate std'
+// @!has - 'use std::prelude::'
+
+// @has - 'pub extern crate empty'
+pub extern crate empty;
diff --git a/src/test/rustdoc/issue-27362.rs b/src/test/rustdoc/issue-27362.rs
new file mode 100644
index 0000000..3f38783
--- /dev/null
+++ b/src/test/rustdoc/issue-27362.rs
@@ -0,0 +1,10 @@
+// aux-build:issue-27362.rs
+// ignore-cross-compile
+// ignore-test This test fails on beta/stable #32019
+
+extern crate issue_27362;
+pub use issue_27362 as quux;
+
+// @matches issue_27362/quux/fn.foo.html '//pre' "pub const fn foo()"
+// @matches issue_27362/quux/fn.bar.html '//pre' "pub const unsafe fn bar()"
+// @matches issue_27362/quux/struct.Foo.html '//code' "const unsafe fn baz()"
diff --git a/src/test/rustdoc/issue-27759.rs b/src/test/rustdoc/issue-27759.rs
new file mode 100644
index 0000000..f3739da
--- /dev/null
+++ b/src/test/rustdoc/issue-27759.rs
@@ -0,0 +1,14 @@
+#![feature(staged_api)]
+#![doc(issue_tracker_base_url = "http://issue_url/")]
+
+#![unstable(feature="test", issue="27759")]
+
+// @has issue_27759/unstable/index.html
+// @has - '<code>test</code>&nbsp;<a href="http://issue_url/27759">#27759</a>'
+#[unstable(feature="test", issue="27759")]
+pub mod unstable {
+    // @has issue_27759/unstable/fn.issue.html
+    // @has - '<code>test_function</code>&nbsp;<a href="http://issue_url/12345">#12345</a>'
+    #[unstable(feature="test_function", issue="12345")]
+    pub fn issue() {}
+}
diff --git a/src/test/rustdoc/issue-27862.rs b/src/test/rustdoc/issue-27862.rs
new file mode 100644
index 0000000..77522f1
--- /dev/null
+++ b/src/test/rustdoc/issue-27862.rs
@@ -0,0 +1,4 @@
+/// Tests  | Table
+/// ------|-------------
+/// t = b | id = \|x\| x
+pub struct Foo; // @has issue_27862/struct.Foo.html //td 'id = |x| x'
diff --git a/src/test/rustdoc/issue-28478.rs b/src/test/rustdoc/issue-28478.rs
new file mode 100644
index 0000000..4cc4056
--- /dev/null
+++ b/src/test/rustdoc/issue-28478.rs
@@ -0,0 +1,31 @@
+#![feature(associated_type_defaults)]
+
+// @has issue_28478/trait.Bar.html
+pub trait Bar {
+    // @has - '//*[@id="associatedtype.Bar"]' 'type Bar = ()'
+    // @has - '//*[@href="#associatedtype.Bar"]' 'Bar'
+    type Bar = ();
+    // @has - '//*[@id="associatedconstant.Baz"]' 'const Baz: usize'
+    // @has - '//*[@href="#associatedconstant.Baz"]' 'Baz'
+    const Baz: usize = 7;
+    // @has - '//*[@id="tymethod.bar"]' 'fn bar'
+    fn bar();
+    // @has - '//*[@id="method.baz"]' 'fn baz'
+    fn baz() { }
+}
+
+// @has issue_28478/struct.Foo.html
+pub struct Foo;
+
+impl Foo {
+    // @has - '//*[@href="#method.foo"]' 'foo'
+    pub fn foo() {}
+}
+
+impl Bar for Foo {
+    // @has - '//*[@href="../issue_28478/trait.Bar.html#associatedtype.Bar"]' 'Bar'
+    // @has - '//*[@href="../issue_28478/trait.Bar.html#associatedconstant.Baz"]' 'Baz'
+    // @has - '//*[@href="../issue_28478/trait.Bar.html#tymethod.bar"]' 'bar'
+    fn bar() {}
+    // @has - '//*[@href="../issue_28478/trait.Bar.html#method.baz"]' 'baz'
+}
diff --git a/src/test/rustdoc/issue-28927.rs b/src/test/rustdoc/issue-28927.rs
new file mode 100644
index 0000000..7b535f3
--- /dev/null
+++ b/src/test/rustdoc/issue-28927.rs
@@ -0,0 +1,6 @@
+// aux-build:issue-28927-2.rs
+// aux-build:issue-28927-1.rs
+// ignore-cross-compile
+
+extern crate issue_28927_1 as inner1;
+pub use inner1 as foo;
diff --git a/src/test/rustdoc/issue-29449.rs b/src/test/rustdoc/issue-29449.rs
new file mode 100644
index 0000000..0d829cf
--- /dev/null
+++ b/src/test/rustdoc/issue-29449.rs
@@ -0,0 +1,20 @@
+// @has issue_29449/struct.Foo.html
+pub struct Foo;
+
+impl Foo {
+    // @has - '//*[@id="examples"]//a' 'Examples'
+    // @has - '//*[@id="panics"]//a' 'Panics'
+    /// # Examples
+    /// # Panics
+    pub fn bar() {}
+
+    // @has - '//*[@id="examples-1"]//a' 'Examples'
+    /// # Examples
+    pub fn bar_1() {}
+
+    // @has - '//*[@id="examples-2"]//a' 'Examples'
+    // @has - '//*[@id="panics-1"]//a' 'Panics'
+    /// # Examples
+    /// # Panics
+    pub fn bar_2() {}
+}
diff --git a/src/test/rustdoc/issue-29503.rs b/src/test/rustdoc/issue-29503.rs
new file mode 100644
index 0000000..d7e0f37
--- /dev/null
+++ b/src/test/rustdoc/issue-29503.rs
@@ -0,0 +1,18 @@
+// ignore-tidy-linelength
+
+use std::fmt;
+
+// @has issue_29503/trait.MyTrait.html
+pub trait MyTrait {
+    fn my_string(&self) -> String;
+}
+
+// @has - "//div[@id='implementors-list']/h3[@id='impl-MyTrait']//code" "impl<T> MyTrait for T where T: Debug"
+impl<T> MyTrait for T where T: fmt::Debug {
+    fn my_string(&self) -> String {
+        format!("{:?}", self)
+    }
+}
+
+pub fn main() {
+}
diff --git a/src/test/rustdoc/issue-29584.rs b/src/test/rustdoc/issue-29584.rs
new file mode 100644
index 0000000..28e1efe
--- /dev/null
+++ b/src/test/rustdoc/issue-29584.rs
@@ -0,0 +1,8 @@
+// aux-build:issue-29584.rs
+// ignore-cross-compile
+
+extern crate issue_29584;
+
+// @has issue_29584/struct.Foo.html
+// @!has - 'impl Bar for'
+pub use issue_29584::Foo;
diff --git a/src/test/rustdoc/issue-30109.rs b/src/test/rustdoc/issue-30109.rs
new file mode 100644
index 0000000..e944753
--- /dev/null
+++ b/src/test/rustdoc/issue-30109.rs
@@ -0,0 +1,14 @@
+// build-aux-docs
+// aux-build:issue-30109-1.rs
+// ignore-cross-compile
+
+pub mod quux {
+    extern crate issue_30109_1 as bar;
+    use self::bar::Bar;
+
+    pub trait Foo {}
+
+    // @has issue_30109/quux/trait.Foo.html \
+    //          '//a/@href' '../issue_30109_1/struct.Bar.html'
+    impl Foo for Bar {}
+}
diff --git a/src/test/rustdoc/issue-30252.rs b/src/test/rustdoc/issue-30252.rs
new file mode 100644
index 0000000..c377736
--- /dev/null
+++ b/src/test/rustdoc/issue-30252.rs
@@ -0,0 +1,6 @@
+// compile-flags:--test --cfg feature="bar"
+
+/// ```rust
+/// assert_eq!(cfg!(feature = "bar"), true);
+/// ```
+pub fn foo() {}
diff --git a/src/test/rustdoc/issue-30366.rs b/src/test/rustdoc/issue-30366.rs
new file mode 100644
index 0000000..c6274a0
--- /dev/null
+++ b/src/test/rustdoc/issue-30366.rs
@@ -0,0 +1,6 @@
+// @has issue_30366/index.html '//a/@href' 'http://www.rust-lang.org/'
+
+/// Describe it. [Link somewhere][1].
+///
+/// [1]: http://www.rust-lang.org/
+pub fn here_is_a_fn() { }
diff --git a/src/test/rustdoc/issue-31808.rs b/src/test/rustdoc/issue-31808.rs
new file mode 100644
index 0000000..e55c5bd
--- /dev/null
+++ b/src/test/rustdoc/issue-31808.rs
@@ -0,0 +1,11 @@
+// Test that associated item impls on primitive types don't crash rustdoc
+
+pub trait Foo {
+    const BAR: usize;
+    type BAZ;
+}
+
+impl Foo for () {
+    const BAR: usize = 0;
+    type BAZ = usize;
+}
diff --git a/src/test/rustdoc/issue-31899.rs b/src/test/rustdoc/issue-31899.rs
new file mode 100644
index 0000000..e7a8ee2
--- /dev/null
+++ b/src/test/rustdoc/issue-31899.rs
@@ -0,0 +1,59 @@
+// @has issue_31899/index.html
+// @has - 'Make this line a bit longer.'
+// @!has - 'rust rust-example-rendered'
+// @!has - 'use ndarray::arr2'
+// @!has - 'prohibited'
+
+/// A tuple or fixed size array that can be used to index an array.
+/// Make this line a bit longer.
+///
+/// ```
+/// use ndarray::arr2;
+///
+/// let mut a = arr2(&[[0, 1], [0, 0]]);
+/// a[[1, 1]] = 1;
+/// assert_eq!(a[[0, 1]], 1);
+/// assert_eq!(a[[1, 1]], 1);
+/// ```
+///
+/// **Note** the blanket implementation that's not visible in rustdoc:
+/// `impl<D> NdIndex for D where D: Dimension { ... }`
+pub fn bar() {}
+
+/// Some line
+///
+/// # prohibited
+pub fn foo() {}
+
+/// Some line
+///
+/// 1. prohibited
+/// 2. bar
+pub fn baz() {}
+
+/// Some line
+///
+/// - prohibited
+/// - bar
+pub fn qux() {}
+
+/// Some line
+///
+/// * prohibited
+/// * bar
+pub fn quz() {}
+
+/// Some line
+///
+/// > prohibited
+/// > bar
+pub fn qur() {}
+
+/// Some line
+///
+/// prohibited
+/// =====
+///
+/// Second
+/// ------
+pub fn qut() {}
diff --git a/src/test/rustdoc/issue-32374.rs b/src/test/rustdoc/issue-32374.rs
new file mode 100644
index 0000000..7babfaf
--- /dev/null
+++ b/src/test/rustdoc/issue-32374.rs
@@ -0,0 +1,34 @@
+#![feature(staged_api)]
+#![doc(issue_tracker_base_url = "http://issue_url/")]
+
+#![unstable(feature="test", issue = "32374")]
+
+// @matches issue_32374/index.html '//*[@class="docblock-short"]/span[@class="stab deprecated"]' \
+//      'Deprecated'
+// @matches issue_32374/index.html '//*[@class="docblock-short"]/span[@class="stab unstable"]' \
+//      'Experimental'
+// @matches issue_32374/index.html '//*[@class="docblock-short"]/text()' 'Docs'
+
+// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]' \
+//      'Deprecated since 1.0.0: text'
+// @has - '<code>test</code>&nbsp;<a href="http://issue_url/32374">#32374</a>'
+// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \
+//      '🔬 This is a nightly-only experimental API. \(test\s#32374\)$'
+/// Docs
+#[rustc_deprecated(since = "1.0.0", reason = "text")]
+#[unstable(feature = "test", issue = "32374")]
+pub struct T;
+
+// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' \
+//      'Deprecated since 1.0.0: deprecated'
+// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' \
+//      '🔬 This is a nightly-only experimental API. (test #32374)'
+// @has issue_32374/struct.U.html '//details' \
+//      '🔬 This is a nightly-only experimental API. (test #32374)'
+// @has issue_32374/struct.U.html '//summary' \
+//      '🔬 This is a nightly-only experimental API. (test #32374)'
+// @has issue_32374/struct.U.html '//details/p' \
+//      'unstable'
+#[rustc_deprecated(since = "1.0.0", reason = "deprecated")]
+#[unstable(feature = "test", issue = "32374", reason = "unstable")]
+pub struct U;
diff --git a/src/test/rustdoc/issue-32395.rs b/src/test/rustdoc/issue-32395.rs
new file mode 100644
index 0000000..91d1857
--- /dev/null
+++ b/src/test/rustdoc/issue-32395.rs
@@ -0,0 +1,13 @@
+// aux-build:variant-struct.rs
+// build-aux-docs
+// ignore-cross-compile
+
+// @has variant_struct/enum.Foo.html
+// @!has - 'pub qux'
+// @!has - 'pub Bar'
+extern crate variant_struct;
+
+// @has issue_32395/enum.Foo.html
+// @!has - 'pub qux'
+// @!has - 'pub Bar'
+pub use variant_struct::Foo;
diff --git a/src/test/rustdoc/issue-32556.rs b/src/test/rustdoc/issue-32556.rs
new file mode 100644
index 0000000..e1cf115
--- /dev/null
+++ b/src/test/rustdoc/issue-32556.rs
@@ -0,0 +1,5 @@
+/// Blah blah blah
+/// ```ignore (testing rustdoc's handling of ignore)
+/// bad_assert!();
+/// ```
+pub fn foo() {}
diff --git a/src/test/rustdoc/issue-32890.rs b/src/test/rustdoc/issue-32890.rs
new file mode 100644
index 0000000..9709544
--- /dev/null
+++ b/src/test/rustdoc/issue-32890.rs
@@ -0,0 +1,17 @@
+// @has issue_32890/struct.Foo.html
+pub struct Foo<T>(T);
+
+impl Foo<u8> {
+    // @has - '//a[@href="#method.pass"]' 'pass'
+    pub fn pass() {}
+}
+
+impl Foo<u16> {
+    // @has - '//a[@href="#method.pass-1"]' 'pass'
+    pub fn pass() {}
+}
+
+impl Foo<u32> {
+    // @has - '//a[@href="#method.pass-2"]' 'pass'
+    pub fn pass() {}
+}
diff --git a/src/test/rustdoc/issue-33069.rs b/src/test/rustdoc/issue-33069.rs
new file mode 100644
index 0000000..0213a53
--- /dev/null
+++ b/src/test/rustdoc/issue-33069.rs
@@ -0,0 +1,10 @@
+pub trait Bar {}
+
+#[doc(hidden)]
+pub mod hidden {
+    pub struct Foo;
+}
+
+// @has issue_33069/trait.Bar.html
+// @!has - '//code' 'impl Bar for Foo'
+impl Bar for hidden::Foo {}
diff --git a/src/test/rustdoc/issue-33178-1.rs b/src/test/rustdoc/issue-33178-1.rs
new file mode 100644
index 0000000..4dc4253
--- /dev/null
+++ b/src/test/rustdoc/issue-33178-1.rs
@@ -0,0 +1,10 @@
+// aux-build:empty.rs
+// aux-build:variant-struct.rs
+// ignore-cross-compile
+
+// @has issue_33178_1/index.html
+// @!has - //a/@title empty
+pub extern crate empty;
+
+// @!has - //a/@title variant_struct
+pub extern crate variant_struct as foo;
diff --git a/src/test/rustdoc/issue-33178.rs b/src/test/rustdoc/issue-33178.rs
new file mode 100644
index 0000000..1f45fe7
--- /dev/null
+++ b/src/test/rustdoc/issue-33178.rs
@@ -0,0 +1,13 @@
+// aux-build:empty.rs
+// aux-build:variant-struct.rs
+// build-aux-docs
+// ignore-cross-compile
+
+// @has issue_33178/index.html
+// @has - //a/@title empty
+// @has - //a/@href ../empty/index.html
+pub extern crate empty;
+
+// @has - //a/@title variant_struct
+// @has - //a/@href ../variant_struct/index.html
+pub extern crate variant_struct as foo;
diff --git a/src/test/rustdoc/issue-33302.rs b/src/test/rustdoc/issue-33302.rs
new file mode 100644
index 0000000..21356b5
--- /dev/null
+++ b/src/test/rustdoc/issue-33302.rs
@@ -0,0 +1,52 @@
+// Ensure constant and array length values are not taken from source
+// code, which wreaks havoc with macros.
+
+
+macro_rules! make {
+    ($n:expr) => {
+        pub struct S;
+
+        // @has issue_33302/constant.CST.html \
+        //        '//pre[@class="rust const"]' 'pub const CST: i32'
+        pub const CST: i32 = ($n * $n);
+        // @has issue_33302/static.ST.html \
+        //        '//pre[@class="rust static"]' 'pub static ST: i32'
+        pub static ST: i32 = ($n * $n);
+
+        pub trait T<X> {
+            fn ignore(_: &X) {}
+            const C: X;
+            // @has issue_33302/trait.T.html \
+            //        '//*[@class="rust trait"]' 'const D: i32'
+            // @has - '//*[@id="associatedconstant.D"]' 'const D: i32'
+            const D: i32 = ($n * $n);
+        }
+
+        // @has issue_33302/struct.S.html \
+        //        '//h3[@class="impl"]' 'impl T<[i32; 16]> for S'
+        // @has - '//*[@id="associatedconstant.C"]' 'const C: [i32; 16]'
+        // @has - '//*[@id="associatedconstant.D"]' 'const D: i32'
+        impl T<[i32; ($n * $n)]> for S {
+            const C: [i32; ($n * $n)] = [0; ($n * $n)];
+        }
+
+        // @has issue_33302/struct.S.html \
+        //        '//h3[@class="impl"]' 'impl T<[i32; 16]> for S'
+        // @has - '//*[@id="associatedconstant.C-1"]' 'const C: (i32,)'
+        // @has - '//*[@id="associatedconstant.D-1"]' 'const D: i32'
+        impl T<(i32,)> for S {
+            const C: (i32,) = ($n,);
+        }
+
+        // @has issue_33302/struct.S.html \
+        //        '//h3[@class="impl"]' 'impl T<(i32, i32)> for S'
+        // @has - '//*[@id="associatedconstant.C-2"]' 'const C: (i32, i32)'
+        // @has - '//*[@id="associatedconstant.D-2"]' 'const D: i32'
+        impl T<(i32, i32)> for S {
+            const C: (i32, i32) = ($n, $n);
+            const D: i32 = ($n / $n);
+        }
+    }
+}
+
+make!(4);
diff --git a/src/test/rustdoc/issue-33592.rs b/src/test/rustdoc/issue-33592.rs
new file mode 100644
index 0000000..81450f1
--- /dev/null
+++ b/src/test/rustdoc/issue-33592.rs
@@ -0,0 +1,13 @@
+#![crate_name = "foo"]
+
+pub trait Foo<T> {}
+
+pub struct Bar;
+
+pub struct Baz;
+
+// @has foo/trait.Foo.html '//code' 'impl Foo<i32> for Bar'
+impl Foo<i32> for Bar {}
+
+// @has foo/trait.Foo.html '//code' 'impl<T> Foo<T> for Baz'
+impl<T> Foo<T> for Baz {}
diff --git a/src/test/rustdoc/issue-34025.rs b/src/test/rustdoc/issue-34025.rs
new file mode 100644
index 0000000..9b9f21c
--- /dev/null
+++ b/src/test/rustdoc/issue-34025.rs
@@ -0,0 +1,12 @@
+#![crate_name = "foo"]
+
+// @!has 'foo/sys/index.html'
+// @!has 'foo/sys/sidebar-items.js'
+#[doc(hidden)]
+pub mod sys {
+    extern "C" {
+        // @!has 'foo/sys/fn.foo.html'
+        #[doc(hidden)]
+        pub fn foo();
+    }
+}
diff --git a/src/test/rustdoc/issue-34274.rs b/src/test/rustdoc/issue-34274.rs
new file mode 100644
index 0000000..ce5be84
--- /dev/null
+++ b/src/test/rustdoc/issue-34274.rs
@@ -0,0 +1,10 @@
+// aux-build:issue-34274.rs
+// build-aux-docs
+// ignore-cross-compile
+
+#![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/src/test/rustdoc/issue-34423.rs b/src/test/rustdoc/issue-34423.rs
new file mode 100644
index 0000000..b429bf8
--- /dev/null
+++ b/src/test/rustdoc/issue-34423.rs
@@ -0,0 +1,10 @@
+pub struct Foo;
+
+pub trait Bar {
+    #[doc(hidden)]
+    fn bar() {}
+}
+
+impl Bar for Foo {
+    fn bar() {}
+}
diff --git a/src/test/rustdoc/issue-34473.rs b/src/test/rustdoc/issue-34473.rs
new file mode 100644
index 0000000..3f824e6
--- /dev/null
+++ b/src/test/rustdoc/issue-34473.rs
@@ -0,0 +1,12 @@
+#![crate_name = "foo"]
+
+mod second {
+    pub struct SomeTypeWithLongName;
+}
+
+// @has foo/index.html
+// @!has - SomeTypeWithLongName
+// @has foo/struct.SomeType.html
+// @!has - SomeTypeWithLongName
+// @!has foo/struct.SomeTypeWithLongName.html
+pub use second::{SomeTypeWithLongName as SomeType};
diff --git a/src/test/rustdoc/issue-34928.rs b/src/test/rustdoc/issue-34928.rs
new file mode 100644
index 0000000..4184086
--- /dev/null
+++ b/src/test/rustdoc/issue-34928.rs
@@ -0,0 +1,6 @@
+#![crate_name = "foo"]
+
+pub trait Bar {}
+
+// @has foo/struct.Foo.html '//pre' 'pub struct Foo<T>(pub T) where T: Bar;'
+pub struct Foo<T>(pub T) where T: Bar;
diff --git a/src/test/rustdoc/issue-35169-2.rs b/src/test/rustdoc/issue-35169-2.rs
new file mode 100644
index 0000000..33f7646
--- /dev/null
+++ b/src/test/rustdoc/issue-35169-2.rs
@@ -0,0 +1,40 @@
+use std::ops::Deref;
+use std::ops::DerefMut;
+
+pub struct Foo;
+pub struct Bar;
+
+impl Foo {
+    pub fn by_ref(&self) {}
+    pub fn by_explicit_ref(self: &Foo) {}
+    pub fn by_mut_ref(&mut self) {}
+    pub fn by_explicit_mut_ref(self: &mut Foo) {}
+    pub fn by_explicit_box(self: Box<Foo>) {}
+    pub fn by_explicit_self_box(self: Box<Self>) {}
+    pub fn static_foo() {}
+}
+
+impl Deref for Bar {
+    type Target = Foo;
+    fn deref(&self) -> &Foo { loop {} }
+}
+
+impl DerefMut for Bar {
+    fn deref_mut(&mut self) -> &mut Foo { loop {} }
+}
+
+// @has issue_35169_2/struct.Bar.html
+// @has - '//*[@id="by_ref.v"]' 'fn by_ref(&self)'
+// @has - '//*[@id="method.by_ref"]' 'fn by_ref(&self)'
+// @has - '//*[@id="by_explicit_ref.v"]' 'fn by_explicit_ref(self: &Foo)'
+// @has - '//*[@id="method.by_explicit_ref"]' 'fn by_explicit_ref(self: &Foo)'
+// @has - '//*[@id="by_mut_ref.v"]' 'fn by_mut_ref(&mut self)'
+// @has - '//*[@id="method.by_mut_ref"]' 'fn by_mut_ref(&mut self)'
+// @has - '//*[@id="by_explicit_mut_ref.v"]' 'fn by_explicit_mut_ref(self: &mut Foo)'
+// @has - '//*[@id="method.by_explicit_mut_ref"]' 'fn by_explicit_mut_ref(self: &mut Foo)'
+// @!has - '//*[@id="by_explicit_box.v"]' 'fn by_explicit_box(self: Box<Foo>)'
+// @!has - '//*[@id="method.by_explicit_box"]' 'fn by_explicit_box(self: Box<Foo>)'
+// @!has - '//*[@id="by_explicit_self_box.v"]' 'fn by_explicit_self_box(self: Box<Self>)'
+// @!has - '//*[@id="method.by_explicit_self_box"]' 'fn by_explicit_self_box(self: Box<Self>)'
+// @!has - '//*[@id="static_foo.v"]' 'fn static_foo()'
+// @!has - '//*[@id="method.static_foo"]' 'fn static_foo()'
diff --git a/src/test/rustdoc/issue-35169.rs b/src/test/rustdoc/issue-35169.rs
new file mode 100644
index 0000000..04fffc4
--- /dev/null
+++ b/src/test/rustdoc/issue-35169.rs
@@ -0,0 +1,35 @@
+use std::ops::Deref;
+
+pub struct Foo;
+pub struct Bar;
+
+impl Foo {
+    pub fn by_ref(&self) {}
+    pub fn by_explicit_ref(self: &Foo) {}
+    pub fn by_mut_ref(&mut self) {}
+    pub fn by_explicit_mut_ref(self: &mut Foo) {}
+    pub fn by_explicit_box(self: Box<Foo>) {}
+    pub fn by_explicit_self_box(self: Box<Self>) {}
+    pub fn static_foo() {}
+}
+
+impl Deref for Bar {
+    type Target = Foo;
+    fn deref(&self) -> &Foo { loop {} }
+}
+
+// @has issue_35169/struct.Bar.html
+// @has - '//*[@id="by_ref.v"]' 'fn by_ref(&self)'
+// @has - '//*[@id="method.by_ref"]' 'fn by_ref(&self)'
+// @has - '//*[@id="by_explicit_ref.v"]' 'fn by_explicit_ref(self: &Foo)'
+// @has - '//*[@id="method.by_explicit_ref"]' 'fn by_explicit_ref(self: &Foo)'
+// @!has - '//*[@id="by_mut_ref.v"]' 'fn by_mut_ref(&mut self)'
+// @!has - '//*[@id="method.by_mut_ref"]' 'fn by_mut_ref(&mut self)'
+// @!has - '//*[@id="by_explicit_mut_ref.v"]' 'fn by_explicit_mut_ref(self: &mut Foo)'
+// @!has - '//*[@id="method.by_explicit_mut_ref"]' 'fn by_explicit_mut_ref(self: &mut Foo)'
+// @!has - '//*[@id="by_explicit_box.v"]' 'fn by_explicit_box(self: Box<Foo>)'
+// @!has - '//*[@id="method.by_explicit_box"]' 'fn by_explicit_box(self: Box<Foo>)'
+// @!has - '//*[@id="by_explicit_self_box.v"]' 'fn by_explicit_self_box(self: Box<Self>)'
+// @!has - '//*[@id="method.by_explicit_self_box"]' 'fn by_explicit_self_box(self: Box<Self>)'
+// @!has - '//*[@id="static_foo.v"]' 'fn static_foo()'
+// @!has - '//*[@id="method.static_foo"]' 'fn static_foo()'
diff --git a/src/test/rustdoc/issue-35488.rs b/src/test/rustdoc/issue-35488.rs
new file mode 100644
index 0000000..c1bf9ce
--- /dev/null
+++ b/src/test/rustdoc/issue-35488.rs
@@ -0,0 +1,13 @@
+mod foo {
+    pub enum Foo {
+        Bar,
+    }
+    pub use self::Foo::*;
+}
+
+// @has 'issue_35488/index.html' '//code' 'pub use self::Foo::*;'
+// @has 'issue_35488/enum.Foo.html'
+pub use self::foo::*;
+
+// @has 'issue_35488/index.html' '//code' 'pub use std::option::Option::None;'
+pub use std::option::Option::None;
diff --git a/src/test/rustdoc/issue-36031.rs b/src/test/rustdoc/issue-36031.rs
new file mode 100644
index 0000000..af1b32f
--- /dev/null
+++ b/src/test/rustdoc/issue-36031.rs
@@ -0,0 +1,9 @@
+// aux-build:issue-36031.rs
+// build-aux-docs
+// ignore-cross-compile
+
+#![crate_name = "foo"]
+
+extern crate issue_36031;
+
+pub use issue_36031::Foo;
diff --git a/src/test/rustdoc/issue-38129.rs b/src/test/rustdoc/issue-38129.rs
new file mode 100644
index 0000000..bf9d5e4
--- /dev/null
+++ b/src/test/rustdoc/issue-38129.rs
@@ -0,0 +1,100 @@
+// compile-flags:--test
+
+// This file tests the source-partitioning behavior of rustdoc.
+// Each test contains some code that should be put into the generated
+// `fn main` and some attributes should be left outside (except the first
+// one, which has no attributes).
+// If the #![recursion_limit] attribute is incorrectly left inside,
+// then the tests will fail because the macro recurses 128 times.
+
+/// ```
+/// assert_eq!(1 + 1, 2);
+/// ```
+pub fn simple() {}
+
+/// ```
+/// #![recursion_limit = "1024"]
+/// macro_rules! recurse {
+///     (()) => {};
+///     (() $($rest:tt)*) => { recurse!($($rest)*); }
+/// }
+/// recurse!(() () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ());
+/// assert_eq!(1 + 1, 2);
+/// ```
+pub fn non_feature_attr() {}
+
+/// ```
+/// #![feature(core_intrinsics)]
+/// assert_eq!(1 + 1, 2);
+/// ```
+pub fn feature_attr() {}
+
+/// ```
+/// #![feature(core_intrinsics)]
+/// #![recursion_limit = "1024"]
+/// macro_rules! recurse {
+///     (()) => {};
+///     (() $($rest:tt)*) => { recurse!($($rest)*); }
+/// }
+/// recurse!(() () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ());
+/// assert_eq!(1 + 1, 2);
+/// ```
+pub fn both_attrs() {}
+
+/// ```
+/// #![recursion_limit = "1024"]
+/// #![feature(core_intrinsics)]
+/// macro_rules! recurse {
+///     (()) => {};
+///     (() $($rest:tt)*) => { recurse!($($rest)*); }
+/// }
+/// recurse!(() () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ()
+///          () () () () () () () ());
+/// assert_eq!(1 + 1, 2);
+/// ```
+pub fn both_attrs_reverse() {}
+
diff --git a/src/test/rustdoc/issue-38219.rs b/src/test/rustdoc/issue-38219.rs
new file mode 100644
index 0000000..fa57c58
--- /dev/null
+++ b/src/test/rustdoc/issue-38219.rs
@@ -0,0 +1,8 @@
+// compile-flags:--test
+// should-fail
+
+/// ```
+/// fail
+/// ```
+#[macro_export]
+macro_rules! foo { () => {} }
diff --git a/src/test/rustdoc/issue-40936.rs b/src/test/rustdoc/issue-40936.rs
new file mode 100644
index 0000000..4d2e4c1
--- /dev/null
+++ b/src/test/rustdoc/issue-40936.rs
@@ -0,0 +1,6 @@
+// aux-build:issue-40936.rs
+// build-aux-docs
+
+#![crate_name = "foo"]
+
+extern crate issue_40936;
diff --git a/src/test/rustdoc/issue-41783.rs b/src/test/rustdoc/issue-41783.rs
new file mode 100644
index 0000000..cb9b9b1
--- /dev/null
+++ b/src/test/rustdoc/issue-41783.rs
@@ -0,0 +1,19 @@
+// @has issue_41783/struct.Foo.html
+// @!has - 'space'
+// @!has - 'comment'
+// @has - '# <span class="ident">single'
+// @has - '## <span class="ident">double</span>'
+// @has - '### <span class="ident">triple</span>'
+// @has - '<span class="attribute">#[<span class="ident">outer</span>]</span>'
+// @has - '<span class="attribute">#![<span class="ident">inner</span>]</span>'
+
+/// ```no_run
+/// # # space
+/// # comment
+/// ## single
+/// ### double
+/// #### triple
+/// ##[outer]
+/// ##![inner]
+/// ```
+pub struct Foo;
diff --git a/src/test/rustdoc/issue-42760.rs b/src/test/rustdoc/issue-42760.rs
new file mode 100644
index 0000000..b07dc3f
--- /dev/null
+++ b/src/test/rustdoc/issue-42760.rs
@@ -0,0 +1,13 @@
+// @has issue_42760/struct.NonGen.html
+// @has - '//h1' 'Example'
+
+/// Item docs.
+///
+#[doc="Hello there!"]
+///
+/// # Example
+///
+/// ```rust
+/// // some code here
+/// ```
+pub struct NonGen;
diff --git a/src/test/rustdoc/issue-42875.rs b/src/test/rustdoc/issue-42875.rs
new file mode 100644
index 0000000..292c207
--- /dev/null
+++ b/src/test/rustdoc/issue-42875.rs
@@ -0,0 +1,13 @@
+// compile-flags: --no-defaults
+
+#![crate_name = "foo"]
+
+// @has foo/a/index.html '//code' 'use *;'
+mod a {
+    use *;
+}
+
+// @has foo/b/index.html '//code' 'pub use *;'
+pub mod b {
+    pub use *;
+}
diff --git a/src/test/rustdoc/issue-43153.rs b/src/test/rustdoc/issue-43153.rs
new file mode 100644
index 0000000..0fe680f
--- /dev/null
+++ b/src/test/rustdoc/issue-43153.rs
@@ -0,0 +1,10 @@
+// Test that `include!` in a doc test searches relative to the directory in
+// which the test is declared.
+
+// compile-flags:--test
+
+/// ```rust
+/// include!("auxiliary/empty.rs");
+/// fn main() {}
+/// ```
+pub struct Foo;
diff --git a/src/test/rustdoc/issue-43701.rs b/src/test/rustdoc/issue-43701.rs
new file mode 100644
index 0000000..44335e9
--- /dev/null
+++ b/src/test/rustdoc/issue-43701.rs
@@ -0,0 +1,5 @@
+#![crate_name = "foo"]
+
+pub use std::vec::Vec;
+
+// @!has implementors/core/clone/trait.Clone.js
diff --git a/src/test/rustdoc/issue-43869.rs b/src/test/rustdoc/issue-43869.rs
new file mode 100644
index 0000000..4435684
--- /dev/null
+++ b/src/test/rustdoc/issue-43869.rs
@@ -0,0 +1,71 @@
+pub fn g() -> impl Iterator<Item=u8> {
+    Some(1u8).into_iter()
+}
+
+pub fn h() -> (impl Iterator<Item=u8>) {
+    Some(1u8).into_iter()
+}
+
+pub fn i() -> impl Iterator<Item=u8> + 'static {
+    Some(1u8).into_iter()
+}
+
+pub fn j() -> impl Iterator<Item=u8> + Clone {
+    Some(1u8).into_iter()
+}
+
+pub fn k() -> [impl Clone; 2] {
+    [123u32, 456u32]
+}
+
+pub fn l() -> (impl Clone, impl Default) {
+    (789u32, -123i32)
+}
+
+pub fn m() -> &'static impl Clone {
+    &1u8
+}
+
+pub fn n() -> *const impl Clone {
+    &1u8
+}
+
+pub fn o() -> &'static [impl Clone] {
+    b":)"
+}
+
+// issue #44731
+pub fn test_44731_0() -> Box<impl Iterator<Item=u8>> {
+    Box::new(g())
+}
+
+pub fn test_44731_1() -> Result<Box<impl Clone>, ()> {
+    Ok(Box::new(j()))
+}
+
+// NOTE these involve Fn sugar, where impl Trait is disallowed for now, see issue #45994
+//
+//pub fn test_44731_2() -> Box<Fn(impl Clone)> {
+//    Box::new(|_: u32| {})
+//}
+//
+//pub fn test_44731_3() -> Box<Fn() -> impl Clone> {
+//    Box::new(|| 0u32)
+//}
+
+pub fn test_44731_4() -> Box<Iterator<Item=impl Clone>> {
+    Box::new(g())
+}
+
+// @has issue_43869/fn.g.html
+// @has issue_43869/fn.h.html
+// @has issue_43869/fn.i.html
+// @has issue_43869/fn.j.html
+// @has issue_43869/fn.k.html
+// @has issue_43869/fn.l.html
+// @has issue_43869/fn.m.html
+// @has issue_43869/fn.n.html
+// @has issue_43869/fn.o.html
+// @has issue_43869/fn.test_44731_0.html
+// @has issue_43869/fn.test_44731_1.html
+// @has issue_43869/fn.test_44731_4.html
diff --git a/src/test/rustdoc/issue-43893.rs b/src/test/rustdoc/issue-43893.rs
new file mode 100644
index 0000000..95d5519
--- /dev/null
+++ b/src/test/rustdoc/issue-43893.rs
@@ -0,0 +1,19 @@
+// ignore-cross-compile
+
+#![crate_name = "foo"]
+
+pub trait SomeTrait {}
+pub struct SomeStruct;
+
+// @has foo/trait.SomeTrait.html '//a/@href' '../src/foo/issue-43893.rs.html#9'
+impl SomeTrait for usize {}
+
+// @has foo/trait.SomeTrait.html '//a/@href' '../src/foo/issue-43893.rs.html#12-14'
+impl SomeTrait for SomeStruct {
+    // deliberately multi-line impl
+}
+
+pub trait AnotherTrait {}
+
+// @has foo/trait.AnotherTrait.html '//a/@href' '../src/foo/issue-43893.rs.html#19'
+impl<T> AnotherTrait for T {}
diff --git a/src/test/rustdoc/issue-45584.rs b/src/test/rustdoc/issue-45584.rs
new file mode 100644
index 0000000..cd8c275
--- /dev/null
+++ b/src/test/rustdoc/issue-45584.rs
@@ -0,0 +1,15 @@
+#![crate_name = "foo"]
+
+pub trait Bar<T, U> {}
+
+// @has 'foo/struct.Foo1.html'
+pub struct Foo1;
+// @count - '//*[@id="implementations-list"]/*[@class="impl"]' 1
+// @has - '//*[@class="impl"]' "impl Bar<Foo1, &'static Foo1> for Foo1"
+impl Bar<Foo1, &'static Foo1> for Foo1 {}
+
+// @has 'foo/struct.Foo2.html'
+pub struct Foo2;
+// @count - '//*[@id="implementations-list"]/*[@class="impl"]' 1
+// @has - '//*[@class="impl"]' "impl Bar<&'static Foo2, Foo2> for u8"
+impl Bar<&'static Foo2, Foo2> for u8 {}
diff --git a/src/test/rustdoc/issue-46271.rs b/src/test/rustdoc/issue-46271.rs
new file mode 100644
index 0000000..b38ef20
--- /dev/null
+++ b/src/test/rustdoc/issue-46271.rs
@@ -0,0 +1,5 @@
+// hopefully this doesn't cause an ICE
+
+pub fn foo() {
+    extern crate std;
+}
diff --git a/src/test/rustdoc/issue-46377.rs b/src/test/rustdoc/issue-46377.rs
new file mode 100644
index 0000000..236afb2
--- /dev/null
+++ b/src/test/rustdoc/issue-46377.rs
@@ -0,0 +1,3 @@
+// @has 'issue_46377/index.html' '//*[@class="docblock-short"]' 'Check out this struct!'
+/// # Check out this struct!
+pub struct SomeStruct;
diff --git a/src/test/rustdoc/issue-46380-2.rs b/src/test/rustdoc/issue-46380-2.rs
new file mode 100644
index 0000000..7004d18
--- /dev/null
+++ b/src/test/rustdoc/issue-46380-2.rs
@@ -0,0 +1,9 @@
+pub trait PublicTrait<T> {}
+
+// @has issue_46380_2/struct.PublicStruct.html
+pub struct PublicStruct;
+
+// @!has - '//*[@class="impl"]' 'impl PublicTrait<PrivateStruct> for PublicStruct'
+impl PublicTrait<PrivateStruct> for PublicStruct {}
+
+struct PrivateStruct;
diff --git a/src/test/rustdoc/issue-46380.rs b/src/test/rustdoc/issue-46380.rs
new file mode 100644
index 0000000..8837a6b
--- /dev/null
+++ b/src/test/rustdoc/issue-46380.rs
@@ -0,0 +1,5 @@
+// compile-flags: --document-private-items
+
+// @has issue_46380/struct.Hidden.html
+#[doc(hidden)]
+pub struct Hidden;
diff --git a/src/test/rustdoc/issue-46727.rs b/src/test/rustdoc/issue-46727.rs
new file mode 100644
index 0000000..0f991cf
--- /dev/null
+++ b/src/test/rustdoc/issue-46727.rs
@@ -0,0 +1,7 @@
+// aux-build:issue-46727.rs
+
+extern crate issue_46727;
+
+// @has issue_46727/trait.Foo.html
+// @has - '//code' 'impl<T> Foo for Bar<[T; 3]>'
+pub use issue_46727::{Foo, Bar};
diff --git a/src/test/rustdoc/issue-46766.rs b/src/test/rustdoc/issue-46766.rs
new file mode 100644
index 0000000..36ab739
--- /dev/null
+++ b/src/test/rustdoc/issue-46766.rs
@@ -0,0 +1,6 @@
+#![crate_name = "foo"]
+
+pub enum Enum{Variant}
+pub use self::Enum::Variant;
+
+// @!has foo/index.html '//a/@href' './Enum/index.html'
diff --git a/src/test/rustdoc/issue-46767.rs b/src/test/rustdoc/issue-46767.rs
new file mode 100644
index 0000000..ef6ed10
--- /dev/null
+++ b/src/test/rustdoc/issue-46767.rs
@@ -0,0 +1,9 @@
+#![crate_name = "foo"]
+
+mod private {
+    pub enum Enum{Variant}
+}
+pub use self::private::Enum::*;
+
+// @!has-dir foo/private
+// @!has foo/index.html '//a/@href' 'private/index.html'
diff --git a/src/test/rustdoc/issue-46976.rs b/src/test/rustdoc/issue-46976.rs
new file mode 100644
index 0000000..c59f8c7
--- /dev/null
+++ b/src/test/rustdoc/issue-46976.rs
@@ -0,0 +1 @@
+pub fn ice(f: impl Fn()) {}
diff --git a/src/test/rustdoc/issue-47038.rs b/src/test/rustdoc/issue-47038.rs
new file mode 100644
index 0000000..810ddca
--- /dev/null
+++ b/src/test/rustdoc/issue-47038.rs
@@ -0,0 +1,10 @@
+#![feature(decl_macro)]
+
+#![crate_name = "foo"]
+
+use std::vec;
+
+// @has 'foo/index.html'
+// @!has - '//*[@id="macros"]' 'Macros'
+// @!has - '//a/@href' 'macro.vec.html'
+// @!has 'foo/macro.vec.html'
diff --git a/src/test/rustdoc/issue-47197-blank-line-in-doc-block.rs b/src/test/rustdoc/issue-47197-blank-line-in-doc-block.rs
new file mode 100644
index 0000000..1999447
--- /dev/null
+++ b/src/test/rustdoc/issue-47197-blank-line-in-doc-block.rs
@@ -0,0 +1,8 @@
+// @has issue_47197_blank_line_in_doc_block/fn.whose_woods_these_are_i_think_i_know.html
+
+/**
+* snow
+
+* ice
+*/
+pub fn whose_woods_these_are_i_think_i_know() {}
diff --git a/src/test/rustdoc/issue-47639.rs b/src/test/rustdoc/issue-47639.rs
new file mode 100644
index 0000000..4b3456b
--- /dev/null
+++ b/src/test/rustdoc/issue-47639.rs
@@ -0,0 +1,6 @@
+// This should not ICE
+pub fn test() {
+    macro_rules! foo {
+        () => ()
+    }
+}
diff --git a/src/test/rustdoc/issue-48377.rs b/src/test/rustdoc/issue-48377.rs
new file mode 100644
index 0000000..c32bcf3
--- /dev/null
+++ b/src/test/rustdoc/issue-48377.rs
@@ -0,0 +1,13 @@
+// compile-flags:--test
+
+//! This is a doc comment
+//!
+//! ```rust
+//! fn main() {}
+//! ```
+//!
+//! With a trailing code fence
+//! ```
+
+/// Some foo function
+pub fn foo() {}
diff --git a/src/test/rustdoc/issue-48414.rs b/src/test/rustdoc/issue-48414.rs
new file mode 100644
index 0000000..b35743d
--- /dev/null
+++ b/src/test/rustdoc/issue-48414.rs
@@ -0,0 +1,11 @@
+// aux-build:issue-48414.rs
+
+// ICE when resolving paths for a trait that linked to another trait, when both were in an external
+// crate
+
+#![crate_name = "base"]
+
+extern crate issue_48414;
+
+#[doc(inline)]
+pub use issue_48414::{SomeTrait, OtherTrait};
diff --git a/src/test/rustdoc/issue-50159.rs b/src/test/rustdoc/issue-50159.rs
new file mode 100644
index 0000000..d175c82
--- /dev/null
+++ b/src/test/rustdoc/issue-50159.rs
@@ -0,0 +1,20 @@
+pub trait Signal {
+    type Item;
+}
+
+pub trait Signal2 {
+    type Item2;
+}
+
+impl<B, C> Signal2 for B where B: Signal<Item = C> {
+    type Item2 = C;
+}
+
+// @has issue_50159/struct.Switch.html
+// @has - '//code' 'impl<B> Send for Switch<B> where <B as Signal>::Item: Send'
+// @has - '//code' 'impl<B> Sync for Switch<B> where <B as Signal>::Item: Sync'
+// @count - '//*[@id="implementations-list"]/*[@class="impl"]' 0
+// @count - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]' 2
+pub struct Switch<B: Signal> {
+    pub inner: <B as Signal2>::Item2,
+}
diff --git a/src/test/rustdoc/issue-51236.rs b/src/test/rustdoc/issue-51236.rs
new file mode 100644
index 0000000..d9accf9
--- /dev/null
+++ b/src/test/rustdoc/issue-51236.rs
@@ -0,0 +1,14 @@
+use std::marker::PhantomData;
+
+pub mod traits {
+    pub trait Owned<'a> {
+        type Reader;
+    }
+}
+
+// @has issue_51236/struct.Owned.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<T> Send for \
+// Owned<T> where <T as Owned<'static>>::Reader: Send"
+pub struct Owned<T> where T: for<'a> ::traits::Owned<'a> {
+    marker: PhantomData<<T as ::traits::Owned<'static>>::Reader>,
+}
diff --git a/src/test/rustdoc/issue-52873.rs b/src/test/rustdoc/issue-52873.rs
new file mode 100644
index 0000000..9138dd5
--- /dev/null
+++ b/src/test/rustdoc/issue-52873.rs
@@ -0,0 +1,171 @@
+// Regression test for #52873. We used to ICE due to unexpected
+// overflows when checking for "blanket impl inclusion".
+
+use std::marker::PhantomData;
+use std::cmp::Ordering;
+use std::ops::{Add, Mul};
+
+pub type True = B1;
+pub type False = B0;
+pub type U0 = UTerm;
+pub type U1 = UInt<UTerm, B1>;
+
+pub trait NonZero {}
+
+pub trait Bit {
+}
+
+pub trait Unsigned {
+}
+
+#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+pub struct B0;
+
+impl B0 {
+    #[inline]
+    pub fn new() -> B0 {
+        B0
+    }
+}
+
+#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+pub struct B1;
+
+impl B1 {
+    #[inline]
+    pub fn new() -> B1 {
+        B1
+    }
+}
+
+impl Bit for B0 {
+}
+
+impl Bit for B1 {
+}
+
+impl NonZero for B1 {}
+
+pub trait PrivatePow<Y, N> {
+    type Output;
+}
+pub type PrivatePowOut<A, Y, N> = <A as PrivatePow<Y, N>>::Output;
+
+pub type Add1<A> = <A as Add<::B1>>::Output;
+pub type Prod<A, B> = <A as Mul<B>>::Output;
+pub type Square<A> = <A as Mul>::Output;
+pub type Sum<A, B> = <A as Add<B>>::Output;
+
+#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+pub struct UTerm;
+
+impl UTerm {
+    #[inline]
+    pub fn new() -> UTerm {
+        UTerm
+    }
+}
+
+impl Unsigned for UTerm {
+}
+
+#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+pub struct UInt<U, B> {
+    _marker: PhantomData<(U, B)>,
+}
+
+impl<U: Unsigned, B: Bit> UInt<U, B> {
+    #[inline]
+    pub fn new() -> UInt<U, B> {
+        UInt {
+            _marker: PhantomData,
+        }
+    }
+}
+
+impl<U: Unsigned, B: Bit> Unsigned for UInt<U, B> {
+}
+
+impl<U: Unsigned, B: Bit> NonZero for UInt<U, B> {}
+
+impl Add<B0> for UTerm {
+    type Output = UTerm;
+    fn add(self, _: B0) -> Self::Output {
+        UTerm
+    }
+}
+
+impl<U: Unsigned, B: Bit> Add<B0> for UInt<U, B> {
+    type Output = UInt<U, B>;
+    fn add(self, _: B0) -> Self::Output {
+        UInt::new()
+    }
+}
+
+impl<U: Unsigned> Add<U> for UTerm {
+    type Output = U;
+    fn add(self, _: U) -> Self::Output {
+        unsafe { ::std::mem::uninitialized() }
+    }
+}
+
+impl<U: Unsigned, B: Bit> Mul<B0> for UInt<U, B> {
+    type Output = UTerm;
+    fn mul(self, _: B0) -> Self::Output {
+        UTerm
+    }
+}
+
+impl<U: Unsigned, B: Bit> Mul<B1> for UInt<U, B> {
+    type Output = UInt<U, B>;
+    fn mul(self, _: B1) -> Self::Output {
+        UInt::new()
+    }
+}
+
+impl<U: Unsigned> Mul<U> for UTerm {
+    type Output = UTerm;
+    fn mul(self, _: U) -> Self::Output {
+        UTerm
+    }
+}
+
+impl<Ul: Unsigned, B: Bit, Ur: Unsigned> Mul<UInt<Ur, B>> for UInt<Ul, B0>
+where
+    Ul: Mul<UInt<Ur, B>>,
+{
+    type Output = UInt<Prod<Ul, UInt<Ur, B>>, B0>;
+    fn mul(self, _: UInt<Ur, B>) -> Self::Output {
+        unsafe { ::std::mem::uninitialized() }
+    }
+}
+
+pub trait Pow<Exp> {
+    type Output;
+}
+
+impl<X: Unsigned, N: Unsigned> Pow<N> for X
+where
+    X: PrivatePow<U1, N>,
+{
+    type Output = PrivatePowOut<X, U1, N>;
+}
+
+impl<Y: Unsigned, X: Unsigned> PrivatePow<Y, U0> for X {
+    type Output = Y;
+}
+
+impl<Y: Unsigned, X: Unsigned> PrivatePow<Y, U1> for X
+where
+    X: Mul<Y>,
+{
+    type Output = Prod<X, Y>;
+}
+
+impl<Y: Unsigned, U: Unsigned, B: Bit, X: Unsigned> PrivatePow<Y, UInt<UInt<U, B>, B0>> for X
+where
+    X: Mul,
+    Square<X>: PrivatePow<Y, UInt<U, B>>,
+{
+    type Output = PrivatePowOut<Square<X>, Y, UInt<U, B>>;
+}
diff --git a/src/test/rustdoc/issue-53689.rs b/src/test/rustdoc/issue-53689.rs
new file mode 100644
index 0000000..7fe962c
--- /dev/null
+++ b/src/test/rustdoc/issue-53689.rs
@@ -0,0 +1,16 @@
+// aux-build:issue-53689.rs
+
+#![crate_name = "foo"]
+
+extern crate issue_53689;
+
+// @has foo/trait.MyTrait.html
+// @!has - 'MyStruct'
+// @count - '//*[code="impl<T> MyTrait for T"]' 1
+pub trait MyTrait {}
+
+impl<T> MyTrait for T {}
+
+mod a {
+    pub use issue_53689::MyStruct;
+}
diff --git a/src/test/rustdoc/issue-53812.rs b/src/test/rustdoc/issue-53812.rs
new file mode 100644
index 0000000..3ebf154
--- /dev/null
+++ b/src/test/rustdoc/issue-53812.rs
@@ -0,0 +1,20 @@
+pub trait MyIterator {
+}
+
+pub struct MyStruct<T>(T);
+
+macro_rules! array_impls {
+    ($($N:expr)+) => {
+        $(
+            impl<'a, T> MyIterator for &'a MyStruct<[T; $N]> {
+            }
+        )+
+    }
+}
+
+// @has issue_53812/trait.MyIterator.html '//*[@id="implementors-list"]//h3[1]' 'MyStruct<[T; 0]>'
+// @has - '//*[@id="implementors-list"]//h3[2]' 'MyStruct<[T; 1]>'
+// @has - '//*[@id="implementors-list"]//h3[3]' 'MyStruct<[T; 2]>'
+// @has - '//*[@id="implementors-list"]//h3[4]' 'MyStruct<[T; 3]>'
+// @has - '//*[@id="implementors-list"]//h3[5]' 'MyStruct<[T; 10]>'
+array_impls! { 10 3 2 1 0 }
diff --git a/src/test/rustdoc/issue-54478-demo-allocator.rs b/src/test/rustdoc/issue-54478-demo-allocator.rs
new file mode 100644
index 0000000..4811f36
--- /dev/null
+++ b/src/test/rustdoc/issue-54478-demo-allocator.rs
@@ -0,0 +1,42 @@
+// Issue #54478: regression test showing that we can demonstrate
+// `#[global_allocator]` in code blocks built by `rustdoc`.
+//
+// ## Background
+//
+// Changes in lang-item visibility injected failures that were only
+// exposed when compiling with `-C prefer-dynamic`. But `rustdoc` used
+// `-C prefer-dynamic` (and had done so for years, for reasons we did
+// not document at that time).
+//
+// Rather than try to revise the visbility semanics, we instead
+// decided to change `rustdoc` to behave more like the compiler's
+// default setting, by leaving off `-C prefer-dynamic`.
+
+// compile-flags:--test
+
+//! This is a doc comment
+//!
+//! ```rust
+//! use std::alloc::*;
+//!
+//! #[global_allocator]
+//! static ALLOC: A = A;
+//!
+//! static mut HIT: bool = false;
+//!
+//! struct A;
+//!
+//! unsafe impl GlobalAlloc for A {
+//!     unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
+//!         HIT = true;
+//!         System.alloc(layout)
+//!     }
+//!     unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
+//!         System.dealloc(ptr, layout);
+//!     }
+//! }
+//!
+//! fn main() {
+//!     assert!(unsafe { HIT });
+//! }
+//! ```
diff --git a/src/test/rustdoc/issue-54705.rs b/src/test/rustdoc/issue-54705.rs
new file mode 100644
index 0000000..263b1eb
--- /dev/null
+++ b/src/test/rustdoc/issue-54705.rs
@@ -0,0 +1,29 @@
+pub trait ScopeHandle<'scope> {}
+
+
+
+// @has issue_54705/struct.ScopeFutureContents.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'scope, S> \
+// Send for ScopeFutureContents<'scope, S> where S: Sync"
+//
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'scope, S> \
+// Sync for ScopeFutureContents<'scope, S> where S: Sync"
+pub struct ScopeFutureContents<'scope, S>
+    where S: ScopeHandle<'scope>,
+{
+    dummy: &'scope S,
+    this: Box<ScopeFuture<'scope, S>>,
+}
+
+struct ScopeFuture<'scope, S>
+    where S: ScopeHandle<'scope>,
+{
+    contents: ScopeFutureContents<'scope, S>,
+}
+
+unsafe impl<'scope, S> Send for ScopeFuture<'scope, S>
+    where S: ScopeHandle<'scope>,
+{}
+unsafe impl<'scope, S> Sync for ScopeFuture<'scope, S>
+    where S: ScopeHandle<'scope>,
+{}
diff --git a/src/test/rustdoc/issue-55001.rs b/src/test/rustdoc/issue-55001.rs
new file mode 100644
index 0000000..f6c7f9a
--- /dev/null
+++ b/src/test/rustdoc/issue-55001.rs
@@ -0,0 +1,31 @@
+// Regression test for issue #55001. Previously, we would incorrectly
+// cache certain trait selection results when checking for blanket impls,
+// resulting in an ICE when we tried to confirm the cached ParamCandidate
+// against an obligation.
+
+pub struct DefaultAllocator;
+pub struct Standard;
+pub struct Inner;
+
+pub trait Rand {}
+
+pub trait Distribution<T> {}
+pub trait Allocator<N> {}
+
+impl<T> Rand for T where Standard: Distribution<T> {}
+
+impl<A> Distribution<Point<A>> for Standard
+where
+DefaultAllocator: Allocator<A>,
+Standard: Distribution<A> {}
+
+impl Distribution<Inner> for Standard {}
+
+
+pub struct Point<N>
+where DefaultAllocator: Allocator<N>
+{
+    field: N
+}
+
+fn main() {}
diff --git a/src/test/rustdoc/issue-55321.rs b/src/test/rustdoc/issue-55321.rs
new file mode 100644
index 0000000..257cb32
--- /dev/null
+++ b/src/test/rustdoc/issue-55321.rs
@@ -0,0 +1,16 @@
+#![feature(optin_builtin_traits)]
+
+// @has issue_55321/struct.A.html
+// @has - '//*[@id="implementations-list"]/*[@class="impl"]//code' "impl !Send for A"
+// @has - '//*[@id="implementations-list"]/*[@class="impl"]//code' "impl !Sync for A"
+pub struct A();
+
+impl !Send for A {}
+impl !Sync for A {}
+
+// @has issue_55321/struct.B.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<T> !Send for \
+// B<T>"
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<T> !Sync for \
+// B<T>"
+pub struct B<T: ?Sized>(A, Box<T>);
diff --git a/src/test/rustdoc/issue-56701.rs b/src/test/rustdoc/issue-56701.rs
new file mode 100644
index 0000000..6fb30a4
--- /dev/null
+++ b/src/test/rustdoc/issue-56701.rs
@@ -0,0 +1,34 @@
+// This shouldn't cause a stack overflow when rustdoc is run
+
+use std::ops::Deref;
+use std::ops::DerefMut;
+
+pub trait SimpleTrait {
+    type SimpleT;
+}
+
+impl<Inner: SimpleTrait, Outer: Deref<Target = Inner>> SimpleTrait for Outer {
+    type SimpleT = Inner::SimpleT;
+}
+
+pub trait AnotherTrait {
+    type AnotherT;
+}
+
+impl<T, Simple: SimpleTrait<SimpleT = Vec<T>>> AnotherTrait for Simple {
+    type AnotherT = T;
+}
+
+pub struct Unrelated<Inner, UnrelatedT: DerefMut<Target = Vec<Inner>>>(UnrelatedT);
+
+impl<Inner, UnrelatedT: DerefMut<Target = Vec<Inner>>> Deref for Unrelated<Inner, UnrelatedT> {
+    type Target = Vec<Inner>;
+
+    fn deref(&self) -> &Self::Target {
+        &self.0
+    }
+}
+
+
+pub fn main() { }
+
diff --git a/src/test/rustdoc/issue-56822.rs b/src/test/rustdoc/issue-56822.rs
new file mode 100644
index 0000000..5b67817
--- /dev/null
+++ b/src/test/rustdoc/issue-56822.rs
@@ -0,0 +1,24 @@
+struct Wrapper<T>(T);
+
+trait MyTrait {
+    type Output;
+}
+
+impl<'a, I, T: 'a> MyTrait for Wrapper<I>
+    where I: MyTrait<Output=&'a T>
+{
+    type Output = T;
+}
+
+struct Inner<'a, T>(&'a T);
+
+impl<'a, T> MyTrait for Inner<'a, T> {
+    type Output = &'a T;
+}
+
+// @has issue_56822/struct.Parser.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'a> Send for \
+// Parser<'a>"
+pub struct Parser<'a> {
+    field: <Wrapper<Inner<'a, u8>> as MyTrait>::Output
+}
diff --git a/src/test/rustdoc/keyword.rs b/src/test/rustdoc/keyword.rs
new file mode 100644
index 0000000..c721c02
--- /dev/null
+++ b/src/test/rustdoc/keyword.rs
@@ -0,0 +1,15 @@
+#![crate_name = "foo"]
+
+#![feature(doc_keyword)]
+
+// @has foo/index.html '//h2[@id="keywords"]' 'Keywords'
+// @has foo/index.html '//a[@href="keyword.match.html"]' 'match'
+// @has foo/keyword.match.html '//a[@class="keyword"]' 'match'
+// @has foo/keyword.match.html '//span[@class="in-band"]' 'Keyword match'
+// @has foo/keyword.match.html '//section[@id="main"]//div[@class="docblock"]//p' 'this is a test!'
+// @has foo/index.html '//a/@href' '../foo/index.html'
+// @!has foo/foo/index.html
+// @!has-dir foo/foo
+#[doc(keyword = "match")]
+/// this is a test!
+mod foo{}
diff --git a/src/test/rustdoc/line-breaks.rs b/src/test/rustdoc/line-breaks.rs
new file mode 100644
index 0000000..29c16fc
--- /dev/null
+++ b/src/test/rustdoc/line-breaks.rs
@@ -0,0 +1,30 @@
+#![crate_name = "foo"]
+
+use std::ops::Add;
+use std::fmt::Display;
+
+//@count foo/fn.function_with_a_really_long_name.html //pre/br 2
+pub fn function_with_a_really_long_name(parameter_one: i32,
+                                        parameter_two: i32)
+                                        -> Option<i32> {
+    Some(parameter_one + parameter_two)
+}
+
+//@count foo/fn.short_name.html //pre/br 0
+pub fn short_name(param: i32) -> i32 { param + 1 }
+
+//@count foo/fn.where_clause.html //pre/br 4
+pub fn where_clause<T, U>(param_one: T,
+                          param_two: U)
+    where T: Add<U> + Display + Copy,
+          U: Add<T> + Display + Copy,
+          T::Output: Display + Add<U::Output> + Copy,
+          <T::Output as Add<U::Output>>::Output: Display,
+          U::Output: Display + Copy
+{
+    let x = param_one + param_two;
+    println!("{} + {} = {}", param_one, param_two, x);
+    let y = param_two + param_one;
+    println!("{} + {} = {}", param_two, param_one, y);
+    println!("{} + {} = {}", x, y, x + y);
+}
diff --git a/src/test/rustdoc/link-assoc-const.rs b/src/test/rustdoc/link-assoc-const.rs
new file mode 100644
index 0000000..f9eb2b7
--- /dev/null
+++ b/src/test/rustdoc/link-assoc-const.rs
@@ -0,0 +1,16 @@
+#![crate_name = "foo"]
+
+// @has foo/index.html '//a[@href="../foo/foo/constant.FIRSTCONST.html"]' 'foo::FIRSTCONST'
+// @has foo/index.html '//a[@href="../foo/struct.Bar.html#associatedconstant.CONST"]' 'Bar::CONST'
+
+//! We have here [`foo::FIRSTCONST`] and [`Bar::CONST`].
+
+pub mod foo {
+    pub const FIRSTCONST: u32 = 42;
+}
+
+pub struct Bar;
+
+impl Bar {
+    pub const CONST: u32 = 42;
+}
diff --git a/src/test/rustdoc/link-title-escape.rs b/src/test/rustdoc/link-title-escape.rs
new file mode 100644
index 0000000..29e82cb
--- /dev/null
+++ b/src/test/rustdoc/link-title-escape.rs
@@ -0,0 +1,7 @@
+#![crate_name = "foo"]
+
+//! hello [foo]
+//!
+//! [foo]: url 'title & <stuff> & "things"'
+
+// @has 'foo/index.html' 'title &amp; &lt;stuff&gt; &amp; &quot;things&quot;'
diff --git a/src/test/rustdoc/macros.rs b/src/test/rustdoc/macros.rs
new file mode 100644
index 0000000..fb4f02a
--- /dev/null
+++ b/src/test/rustdoc/macros.rs
@@ -0,0 +1,10 @@
+// @has macros/macro.my_macro.html //pre 'macro_rules! my_macro {'
+// @has - //pre '() => { ... };'
+// @has - //pre '($a:tt) => { ... };'
+// @has - //pre '($e:expr) => { ... };'
+#[macro_export]
+macro_rules! my_macro {
+    () => [];
+    ($a:tt) => ();
+    ($e:expr) => {};
+}
diff --git a/src/test/rustdoc/manual_impl.rs b/src/test/rustdoc/manual_impl.rs
new file mode 100644
index 0000000..c9e4f4e
--- /dev/null
+++ b/src/test/rustdoc/manual_impl.rs
@@ -0,0 +1,79 @@
+// @has manual_impl/trait.T.html
+// @has  - '//*[@class="docblock"]' 'Docs associated with the trait definition.'
+// @has  - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
+// @has  - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
+/// Docs associated with the trait definition.
+pub trait T {
+    /// Docs associated with the trait a_method definition.
+    fn a_method(&self) -> usize;
+
+    /// Docs associated with the trait b_method definition.
+    fn b_method(&self) -> usize {
+        self.a_method()
+    }
+
+    /// Docs associated with the trait c_method definition.
+    ///
+    /// There is another line
+    fn c_method(&self) -> usize {
+        self.a_method()
+    }
+}
+
+// @has manual_impl/struct.S1.html '//*[@class="trait"]' 'T'
+// @has  - '//*[@class="docblock"]' 'Docs associated with the S1 trait implementation.'
+// @has  - '//*[@class="docblock"]' 'Docs associated with the S1 trait a_method implementation.'
+// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
+// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
+// @has - '//*[@class="docblock"]' 'Docs associated with the trait c_method definition.'
+// @!has - '//*[@class="docblock"]' 'There is another line'
+// @has - '//*[@class="docblock"]' 'Read more'
+pub struct S1(usize);
+
+/// Docs associated with the S1 trait implementation.
+impl T for S1 {
+    /// Docs associated with the S1 trait a_method implementation.
+    fn a_method(&self) -> usize {
+        self.0
+    }
+}
+
+// @has manual_impl/struct.S2.html '//*[@class="trait"]' 'T'
+// @has  - '//*[@class="docblock"]' 'Docs associated with the S2 trait implementation.'
+// @has  - '//*[@class="docblock"]' 'Docs associated with the S2 trait a_method implementation.'
+// @has  - '//*[@class="docblock"]' 'Docs associated with the S2 trait c_method implementation.'
+// @!has - '//*[@class="docblock"]' 'Docs associated with the trait a_method definition.'
+// @!has - '//*[@class="docblock"]' 'Docs associated with the trait c_method definition.'
+// @has - '//*[@class="docblock"]' 'Docs associated with the trait b_method definition.'
+pub struct S2(usize);
+
+/// Docs associated with the S2 trait implementation.
+impl T for S2 {
+    /// Docs associated with the S2 trait a_method implementation.
+    fn a_method(&self) -> usize {
+        self.0
+    }
+
+    /// Docs associated with the S2 trait c_method implementation.
+    fn c_method(&self) -> usize {
+        5
+    }
+}
+
+// @has manual_impl/struct.S3.html '//*[@class="trait"]' 'T'
+// @has  - '//*[@class="docblock"]' 'Docs associated with the S3 trait implementation.'
+// @has  - '//*[@class="docblock"]' 'Docs associated with the S3 trait b_method implementation.'
+// @has - '//*[@class="docblock hidden"]' 'Docs associated with the trait a_method definition.'
+pub struct S3(usize);
+
+/// Docs associated with the S3 trait implementation.
+impl T for S3 {
+    fn a_method(&self) -> usize {
+        self.0
+    }
+
+    /// Docs associated with the S3 trait b_method implementation.
+    fn b_method(&self) -> usize {
+        5
+    }
+}
diff --git a/src/test/rustdoc/masked.rs b/src/test/rustdoc/masked.rs
new file mode 100644
index 0000000..c7ad690
--- /dev/null
+++ b/src/test/rustdoc/masked.rs
@@ -0,0 +1,30 @@
+// aux-build:masked.rs
+
+#![feature(doc_masked)]
+
+#![crate_name = "foo"]
+
+#[doc(masked)]
+extern crate masked;
+
+// @!has 'search-index.js' 'masked_method'
+
+// @!has 'foo/struct.String.html' 'MaskedTrait'
+// @!has 'foo/struct.String.html' 'masked_method'
+pub use std::string::String;
+
+// @!has 'foo/trait.Clone.html' 'MaskedStruct'
+pub use std::clone::Clone;
+
+// @!has 'foo/struct.MyStruct.html' 'MaskedTrait'
+// @!has 'foo/struct.MyStruct.html' 'masked_method'
+pub struct MyStruct;
+
+impl masked::MaskedTrait for MyStruct {
+    fn masked_method() {}
+}
+
+// @!has 'foo/trait.MyTrait.html' 'MaskedStruct'
+pub trait MyTrait {}
+
+impl MyTrait for masked::MaskedStruct {}
diff --git a/src/test/rustdoc/method-list.rs b/src/test/rustdoc/method-list.rs
new file mode 100644
index 0000000..f84be3e
--- /dev/null
+++ b/src/test/rustdoc/method-list.rs
@@ -0,0 +1,20 @@
+// ignore-tidy-linelength
+
+#![crate_name = "foo"]
+
+// @has foo/struct.Foo.html
+// @has - '//*[@class="sidebar-links"]/a' 'super_long_name'
+// @has - '//*[@class="sidebar-links"]/a' 'Disp'
+pub struct Foo(usize);
+
+impl Foo {
+    pub fn super_long_name() {}
+}
+
+pub trait Disp {
+    fn disp_trait_method();
+}
+
+impl Disp for Foo {
+    fn disp_trait_method() {}
+}
diff --git a/src/test/rustdoc/mod-stackoverflow.rs b/src/test/rustdoc/mod-stackoverflow.rs
new file mode 100644
index 0000000..45b1de2
--- /dev/null
+++ b/src/test/rustdoc/mod-stackoverflow.rs
@@ -0,0 +1,6 @@
+// aux-build:mod-stackoverflow.rs
+// ignore-cross-compile
+
+extern crate mod_stackoverflow;
+pub use mod_stackoverflow::tree;
+pub use mod_stackoverflow::tree2;
diff --git a/src/test/rustdoc/module-impls.rs b/src/test/rustdoc/module-impls.rs
new file mode 100644
index 0000000..198b344
--- /dev/null
+++ b/src/test/rustdoc/module-impls.rs
@@ -0,0 +1,5 @@
+#![crate_name = "foo"]
+
+pub use std::marker::Send;
+
+// @!has foo/index.html 'Implementations'
diff --git a/src/test/rustdoc/must-use.rs b/src/test/rustdoc/must-use.rs
new file mode 100644
index 0000000..b52557f
--- /dev/null
+++ b/src/test/rustdoc/must-use.rs
@@ -0,0 +1,11 @@
+// @has must_use/struct.Struct.html //pre '#[must_use]'
+#[must_use]
+pub struct Struct {
+    field: i32,
+}
+
+// @has must_use/enum.Enum.html //pre '#[must_use = "message"]'
+#[must_use = "message"]
+pub enum Enum {
+    Variant(i32),
+}
diff --git a/src/test/rustdoc/namespaces.rs b/src/test/rustdoc/namespaces.rs
new file mode 100644
index 0000000..ad828e5
--- /dev/null
+++ b/src/test/rustdoc/namespaces.rs
@@ -0,0 +1,16 @@
+// issue #34843: rustdoc prioritises documenting reexports from the type namespace
+
+mod inner {
+    pub mod sync {
+        pub struct SomeStruct;
+    }
+
+    pub fn sync() {}
+}
+
+// @has namespaces/sync/index.html
+// @has namespaces/fn.sync.html
+// @has namespaces/index.html '//a/@href' 'sync/index.html'
+// @has - '//a/@href' 'fn.sync.html'
+#[doc(inline)]
+pub use inner::sync;
diff --git a/src/test/rustdoc/negative-impl-sidebar.rs b/src/test/rustdoc/negative-impl-sidebar.rs
new file mode 100644
index 0000000..838ca04
--- /dev/null
+++ b/src/test/rustdoc/negative-impl-sidebar.rs
@@ -0,0 +1,9 @@
+#![feature(optin_builtin_traits)]
+#![crate_name = "foo"]
+
+pub struct Foo;
+
+// @has foo/struct.Foo.html
+// @has - '//*[@class="sidebar-title"][@href="#implementations"]' 'Trait Implementations'
+// @has - '//*[@class="sidebar-links"]/a' '!Sync'
+impl !Sync for Foo {}
diff --git a/src/test/rustdoc/negative-impl.rs b/src/test/rustdoc/negative-impl.rs
new file mode 100644
index 0000000..8ac87f4
--- /dev/null
+++ b/src/test/rustdoc/negative-impl.rs
@@ -0,0 +1,12 @@
+#![feature(optin_builtin_traits)]
+
+// @matches negative_impl/struct.Alpha.html '//pre' "pub struct Alpha"
+pub struct Alpha;
+// @matches negative_impl/struct.Bravo.html '//pre' "pub struct Bravo<B>"
+pub struct Bravo<B>(B);
+
+// @matches negative_impl/struct.Alpha.html '//*[@class="impl"]//code' "impl !Send for Alpha"
+impl !Send for Alpha {}
+
+// @matches negative_impl/struct.Bravo.html '//*[@class="impl"]//code' "impl<B> !Send for Bravo<B>"
+impl<B> !Send for Bravo<B> {}
diff --git a/src/test/rustdoc/no-crate-filter.rs b/src/test/rustdoc/no-crate-filter.rs
new file mode 100644
index 0000000..c694d14
--- /dev/null
+++ b/src/test/rustdoc/no-crate-filter.rs
@@ -0,0 +1,6 @@
+#![crate_name = "foo"]
+
+// compile-flags: -Z unstable-options --disable-per-crate-search
+
+// @!has 'foo/struct.Foo.html' '//*[id="crate-search"]'
+pub struct Foo;
diff --git a/src/test/rustdoc/no-run-still-checks-lints.rs b/src/test/rustdoc/no-run-still-checks-lints.rs
new file mode 100644
index 0000000..9f7d1c8
--- /dev/null
+++ b/src/test/rustdoc/no-run-still-checks-lints.rs
@@ -0,0 +1,9 @@
+// compile-flags:--test
+// should-fail
+
+#![doc(test(attr(deny(warnings))))]
+
+/// ```no_run
+/// let a = 3;
+/// ```
+pub fn foo() {}
diff --git a/src/test/rustdoc/no-stack-overflow-25295.rs b/src/test/rustdoc/no-stack-overflow-25295.rs
new file mode 100644
index 0000000..dd79f1e
--- /dev/null
+++ b/src/test/rustdoc/no-stack-overflow-25295.rs
@@ -0,0 +1,35 @@
+// Ensure this code doesn't stack overflow.
+// aux-build:enum-primitive.rs
+
+#[macro_use] extern crate enum_primitive;
+
+enum_from_primitive! {
+    pub enum Test {
+        A1,A2,A3,A4,A5,A6,
+        B1,B2,B3,B4,B5,B6,
+        C1,C2,C3,C4,C5,C6,
+        D1,D2,D3,D4,D5,D6,
+        E1,E2,E3,E4,E5,E6,
+        F1,F2,F3,F4,F5,F6,
+        G1,G2,G3,G4,G5,G6,
+        H1,H2,H3,H4,H5,H6,
+        I1,I2,I3,I4,I5,I6,
+        J1,J2,J3,J4,J5,J6,
+        K1,K2,K3,K4,K5,K6,
+        L1,L2,L3,L4,L5,L6,
+        M1,M2,M3,M4,M5,M6,
+        N1,N2,N3,N4,N5,N6,
+        O1,O2,O3,O4,O5,O6,
+        P1,P2,P3,P4,P5,P6,
+        Q1,Q2,Q3,Q4,Q5,Q6,
+        R1,R2,R3,R4,R5,R6,
+        S1,S2,S3,S4,S5,S6,
+        T1,T2,T3,T4,T5,T6,
+        U1,U2,U3,U4,U5,U6,
+        V1,V2,V3,V4,V5,V6,
+        W1,W2,W3,W4,W5,W6,
+        X1,X2,X3,X4,X5,X6,
+        Y1,Y2,Y3,Y4,Y5,Y6,
+        Z1,Z2,Z3,Z4,Z5,Z6,
+    }
+}
diff --git a/src/test/rustdoc/nul-error.rs b/src/test/rustdoc/nul-error.rs
new file mode 100644
index 0000000..3d30f5f
--- /dev/null
+++ b/src/test/rustdoc/nul-error.rs
@@ -0,0 +1,8 @@
+// build-aux-docs
+// ignore-cross-compile
+
+#![crate_name = "foo"]
+
+// @has foo/fn.foo.html '//code' ''
+#[doc = "Attempted to pass a string containing `\0`"]
+pub fn foo() {}
diff --git a/src/test/rustdoc/playground-arg.rs b/src/test/rustdoc/playground-arg.rs
new file mode 100644
index 0000000..fb1be73
--- /dev/null
+++ b/src/test/rustdoc/playground-arg.rs
@@ -0,0 +1,14 @@
+// compile-flags: --playground-url=https://example.com/ -Z unstable-options
+// ignore-tidy-linelength
+
+#![crate_name = "foo"]
+
+//! ```
+//! use foo::dummy;
+//! dummy();
+//! ```
+
+pub fn dummy() {}
+
+// ensure that `extern crate foo;` was inserted into code snips automatically:
+// @matches foo/index.html '//a[@class="test-arrow"][@href="https://example.com/?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20foo%3B%0Afn%20main()%20%7B%0Ause%20foo%3A%3Adummy%3B%0Adummy()%3B%0A%7D"]' "Run"
diff --git a/src/test/rustdoc/playground-empty.rs b/src/test/rustdoc/playground-empty.rs
new file mode 100644
index 0000000..7d8bd3f
--- /dev/null
+++ b/src/test/rustdoc/playground-empty.rs
@@ -0,0 +1,13 @@
+#![crate_name = "foo"]
+
+#![doc(html_playground_url = "")]
+
+// compile-flags:-Z unstable-options --playground-url https://play.rust-lang.org/
+
+//! module docs
+//!
+//! ```
+//! println!("Hello, world!");
+//! ```
+
+// @!has foo/index.html '//a[@class="test-arrow"]' "Run"
diff --git a/src/test/rustdoc/playground-none.rs b/src/test/rustdoc/playground-none.rs
new file mode 100644
index 0000000..ff51c68
--- /dev/null
+++ b/src/test/rustdoc/playground-none.rs
@@ -0,0 +1,9 @@
+#![crate_name = "foo"]
+
+//! module docs
+//!
+//! ```
+//! println!("Hello, world!");
+//! ```
+
+// @!has foo/index.html '//a[@class="test-arrow"]' "Run"
diff --git a/src/test/rustdoc/playground.rs b/src/test/rustdoc/playground.rs
new file mode 100644
index 0000000..1b76e6c
--- /dev/null
+++ b/src/test/rustdoc/playground.rs
@@ -0,0 +1,29 @@
+// ignore-tidy-linelength
+
+#![crate_name = "foo"]
+
+#![doc(html_playground_url = "https://www.example.com/")]
+
+//! module docs
+//!
+//! ```
+//! println!("Hello, world!");
+//! ```
+//!
+//! ```
+//! fn main() {
+//!     println!("Hello, world!");
+//! }
+//! ```
+//!
+//! ```
+//! #![feature(something)]
+//!
+//! fn main() {
+//!     println!("Hello, world!");
+//! }
+//! ```
+
+// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22Hello%2C%20world!%22)%3B%0A%7D"]' "Run"
+// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Aprintln!(%22Hello%2C%20world!%22)%3B%0A%7D"]' "Run"
+// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0A%23!%5Bfeature(something)%5D%0A%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22Hello%2C%20world!%22)%3B%0A%7D&version=nightly"]' "Run"
diff --git a/src/test/rustdoc/prim-title.rs b/src/test/rustdoc/prim-title.rs
new file mode 100644
index 0000000..fa3fd51
--- /dev/null
+++ b/src/test/rustdoc/prim-title.rs
@@ -0,0 +1,7 @@
+#![crate_name = "foo"]
+
+// @has foo/primitive.u8.html '//head/title' 'u8 - Rust'
+// @!has - '//head/title' 'foo'
+#[doc(primitive = "u8")]
+/// `u8` docs
+mod u8 {}
diff --git a/src/test/rustdoc/primitive-generic-impl.rs b/src/test/rustdoc/primitive-generic-impl.rs
new file mode 100644
index 0000000..5794322
--- /dev/null
+++ b/src/test/rustdoc/primitive-generic-impl.rs
@@ -0,0 +1,5 @@
+#![crate_name = "foo"]
+
+include!("primitive/primitive-generic-impl.rs");
+
+// @has foo/primitive.i32.html '//h3[@id="impl-ToString"]//code' 'impl<T> ToString for T'
diff --git a/src/test/rustdoc/primitive-link.rs b/src/test/rustdoc/primitive-link.rs
new file mode 100644
index 0000000..819ef05
--- /dev/null
+++ b/src/test/rustdoc/primitive-link.rs
@@ -0,0 +1,9 @@
+#![crate_name = "foo"]
+
+// ignore-tidy-linelength
+
+// @has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="https://doc.rust-lang.org/nightly/std/primitive.u32.html"]' 'u32'
+// @has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="https://doc.rust-lang.org/nightly/std/primitive.i64.html"]' 'i64'
+
+/// It contains [`u32`] and [i64].
+pub struct Foo;
diff --git a/src/test/rustdoc/primitive/primitive-generic-impl.rs b/src/test/rustdoc/primitive/primitive-generic-impl.rs
new file mode 100644
index 0000000..b9c56be
--- /dev/null
+++ b/src/test/rustdoc/primitive/primitive-generic-impl.rs
@@ -0,0 +1,3 @@
+#[doc(primitive = "i32")]
+/// Some useless docs, wouhou!
+mod i32 {}
diff --git a/src/test/rustdoc/private-type-alias.rs b/src/test/rustdoc/private-type-alias.rs
new file mode 100644
index 0000000..ec73854
--- /dev/null
+++ b/src/test/rustdoc/private-type-alias.rs
@@ -0,0 +1,31 @@
+type MyResultPriv<T> = Result<T, u16>;
+pub type MyResultPub<T> = Result<T, u64>;
+
+// @has private_type_alias/fn.get_result_priv.html '//pre' 'Result<u8, u16>'
+pub fn get_result_priv() -> MyResultPriv<u8> {
+    panic!();
+}
+
+// @has private_type_alias/fn.get_result_pub.html '//pre' 'MyResultPub<u32>'
+pub fn get_result_pub() -> MyResultPub<u32> {
+    panic!();
+}
+
+pub type PubRecursive = u16;
+type PrivRecursive3 = u8;
+type PrivRecursive2 = PubRecursive;
+type PrivRecursive1 = PrivRecursive3;
+
+// PrivRecursive1 is expanded twice and stops at u8
+// PrivRecursive2 is expanded once and stops at public type alias PubRecursive
+// @has private_type_alias/fn.get_result_recursive.html '//pre' '(u8, PubRecursive)'
+pub fn get_result_recursive() -> (PrivRecursive1, PrivRecursive2) {
+    panic!();
+}
+
+type MyLifetimePriv<'a> = &'a isize;
+
+// @has private_type_alias/fn.get_lifetime_priv.html '//pre' "&'static isize"
+pub fn get_lifetime_priv() -> MyLifetimePriv<'static> {
+    panic!();
+}
diff --git a/src/test/rustdoc/proc-macro.rs b/src/test/rustdoc/proc-macro.rs
new file mode 100644
index 0000000..1e396f1
--- /dev/null
+++ b/src/test/rustdoc/proc-macro.rs
@@ -0,0 +1,71 @@
+// force-host
+// no-prefer-dynamic
+
+#![crate_type="proc-macro"]
+#![crate_name="some_macros"]
+
+// @has some_macros/index.html
+// @has - '//a/[@href="attr.some_proc_attr.html"]' 'some_proc_attr'
+
+//! include a link to [some_proc_attr] to make sure it works.
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+// @has some_macros/index.html
+// @has - '//h2' 'Macros'
+// @has - '//h2' 'Attribute Macros'
+// @has - '//h2' 'Derive Macros'
+// @!has - '//h2' 'Functions'
+
+// @has some_macros/all.html
+// @has - '//a[@href="macro.some_proc_macro.html"]' 'some_proc_macro'
+// @has - '//a[@href="attr.some_proc_attr.html"]' 'some_proc_attr'
+// @has - '//a[@href="derive.SomeDerive.html"]' 'SomeDerive'
+// @!has - '//a/@href' 'fn.some_proc_macro.html'
+// @!has - '//a/@href' 'fn.some_proc_attr.html'
+// @!has - '//a/@href' 'fn.some_derive.html'
+
+// @has some_macros/index.html '//a/@href' 'macro.some_proc_macro.html'
+// @!has - '//a/@href' 'fn.some_proc_macro.html'
+// @has some_macros/macro.some_proc_macro.html
+// @!has some_macros/fn.some_proc_macro.html
+/// a proc-macro that swallows its input and does nothing.
+#[proc_macro]
+pub fn some_proc_macro(_input: TokenStream) -> TokenStream {
+    TokenStream::new()
+}
+
+// @has some_macros/index.html '//a/@href' 'attr.some_proc_attr.html'
+// @!has - '//a/@href' 'fn.some_proc_attr.html'
+// @has some_macros/attr.some_proc_attr.html
+// @!has some_macros/fn.some_proc_attr.html
+/// a proc-macro attribute that passes its item through verbatim.
+#[proc_macro_attribute]
+pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream {
+    item
+}
+
+// @has some_macros/index.html '//a/@href' 'derive.SomeDerive.html'
+// @!has - '//a/@href' 'fn.some_derive.html'
+// @has some_macros/derive.SomeDerive.html
+// @!has some_macros/fn.some_derive.html
+/// a derive attribute that adds nothing to its input.
+#[proc_macro_derive(SomeDerive)]
+pub fn some_derive(_item: TokenStream) -> TokenStream {
+    TokenStream::new()
+}
+
+// @has some_macros/foo/index.html
+pub mod foo {
+    // @has - '//code' 'pub use some_proc_macro;'
+    // @has - '//a/@href' '../../some_macros/macro.some_proc_macro.html'
+    pub use some_proc_macro;
+    // @has - '//code' 'pub use some_proc_attr;'
+    // @has - '//a/@href' '../../some_macros/attr.some_proc_attr.html'
+    pub use some_proc_attr;
+    // @has - '//code' 'pub use some_derive;'
+    // @has - '//a/@href' '../../some_macros/derive.SomeDerive.html'
+    pub use some_derive;
+}
diff --git a/src/test/rustdoc/process-termination.rs b/src/test/rustdoc/process-termination.rs
new file mode 100644
index 0000000..3225879
--- /dev/null
+++ b/src/test/rustdoc/process-termination.rs
@@ -0,0 +1,24 @@
+// compile-flags:--test
+
+/// A check of using various process termination strategies
+///
+/// # Examples
+///
+/// ```rust
+/// assert!(true); // this returns `()`, all is well
+/// ```
+///
+/// You can also simply return `Ok(())`, but you'll need to disambiguate the
+/// type using turbofish, because we cannot infer the type:
+///
+/// ```rust
+/// Ok::<(), &'static str>(())
+/// ```
+///
+/// You can err with anything that implements `Debug`:
+///
+/// ```rust,should_panic
+/// Err("This is returned from `main`, leading to panic")?;
+/// Ok::<(), &'static str>(())
+/// ```
+pub fn check_process_termination() {}
diff --git a/src/test/rustdoc/pub-extern-crate.rs b/src/test/rustdoc/pub-extern-crate.rs
new file mode 100644
index 0000000..26747a4
--- /dev/null
+++ b/src/test/rustdoc/pub-extern-crate.rs
@@ -0,0 +1,9 @@
+// aux-build:pub-extern-crate.rs
+
+// @has pub_extern_crate/index.html
+// @!has - '//code' 'pub extern crate inner'
+// @has - '//a/@href' 'inner/index.html'
+// @has pub_extern_crate/inner/index.html
+// @has pub_extern_crate/inner/struct.SomeStruct.html
+#[doc(inline)]
+pub extern crate inner;
diff --git a/src/test/rustdoc/pub-method.rs b/src/test/rustdoc/pub-method.rs
new file mode 100644
index 0000000..01e5141
--- /dev/null
+++ b/src/test/rustdoc/pub-method.rs
@@ -0,0 +1,21 @@
+// ignore-tidy-linelength
+// compile-flags: --document-private-items
+
+#![crate_name = "foo"]
+
+// @has foo/fn.bar.html
+// @has - '//*[@class="rust fn"]' 'pub fn bar() -> '
+/// foo
+pub fn bar() -> usize {
+    2
+}
+
+// @has foo/struct.Foo.html
+// @has - '//*[@class="method"]' 'pub fn new()'
+// @has - '//*[@class="method"]' 'fn not_pub()'
+pub struct Foo(usize);
+
+impl Foo {
+    pub fn new() -> Foo { Foo(0) }
+    fn not_pub() {}
+}
diff --git a/src/test/rustdoc/pub-restricted.rs b/src/test/rustdoc/pub-restricted.rs
new file mode 100644
index 0000000..f75dcc2
--- /dev/null
+++ b/src/test/rustdoc/pub-restricted.rs
@@ -0,0 +1,34 @@
+// ignore-tidy-linelength
+
+// compile-flags: --document-private-items
+
+#![feature(crate_visibility_modifier)]
+
+#![crate_name = "foo"]
+
+// @has 'foo/struct.FooPublic.html' '//pre' 'pub struct FooPublic'
+pub struct FooPublic;
+// @has 'foo/struct.FooJustCrate.html' '//pre' 'pub(crate) struct FooJustCrate'
+crate struct FooJustCrate;
+// @has 'foo/struct.FooPubCrate.html' '//pre' 'pub(crate) struct FooPubCrate'
+pub(crate) struct FooPubCrate;
+// @has 'foo/struct.FooSelf.html' '//pre' 'pub(self) struct FooSelf'
+pub(self) struct FooSelf;
+// @has 'foo/struct.FooInSelf.html' '//pre' 'pub(self) struct FooInSelf'
+pub(in self) struct FooInSelf;
+mod a {
+    // @has 'foo/a/struct.FooSuper.html' '//pre' 'pub(super) struct FooSuper'
+    pub(super) struct FooSuper;
+    // @has 'foo/a/struct.FooInSuper.html' '//pre' 'pub(super) struct FooInSuper'
+    pub(in super) struct FooInSuper;
+    // @has 'foo/a/struct.FooInA.html' '//pre' 'pub(in a) struct FooInA'
+    pub(in a) struct FooInA;
+    mod b {
+        // @has 'foo/a/b/struct.FooInSelfSuperB.html' '//pre' 'pub(in self::super::b) struct FooInSelfSuperB'
+        pub(in self::super::b) struct FooInSelfSuperB;
+        // @has 'foo/a/b/struct.FooInSuperSuper.html' '//pre' 'pub(in super::super) struct FooInSuperSuper'
+        pub(in super::super) struct FooInSuperSuper;
+        // @has 'foo/a/b/struct.FooInAB.html' '//pre' 'pub(in a::b) struct FooInAB'
+        pub(in a::b) struct FooInAB;
+    }
+}
diff --git a/src/test/rustdoc/pub-use-extern-macros.rs b/src/test/rustdoc/pub-use-extern-macros.rs
new file mode 100644
index 0000000..eefe6b4
--- /dev/null
+++ b/src/test/rustdoc/pub-use-extern-macros.rs
@@ -0,0 +1,17 @@
+// aux-build:pub-use-extern-macros.rs
+
+extern crate macros;
+
+// @has pub_use_extern_macros/macro.bar.html
+// @!has pub_use_extern_macros/index.html '//code' 'pub use macros::bar;'
+pub use macros::bar;
+
+// @has pub_use_extern_macros/macro.baz.html
+// @!has pub_use_extern_macros/index.html '//code' 'pub use macros::baz;'
+#[doc(inline)]
+pub use macros::baz;
+
+// @!has pub_use_extern_macros/macro.quux.html
+// @!has pub_use_extern_macros/index.html '//code' 'pub use macros::quux;'
+#[doc(hidden)]
+pub use macros::quux;
diff --git a/src/test/rustdoc/recursion1.rs b/src/test/rustdoc/recursion1.rs
new file mode 100644
index 0000000..edf7e44
--- /dev/null
+++ b/src/test/rustdoc/recursion1.rs
@@ -0,0 +1,13 @@
+#![crate_type = "lib"]
+
+mod m {
+    pub use self::a::Foo;
+
+    mod a {
+        pub struct Foo;
+    }
+
+    mod b {
+        pub use super::*;
+    }
+}
diff --git a/src/test/rustdoc/recursion2.rs b/src/test/rustdoc/recursion2.rs
new file mode 100644
index 0000000..edf7e44
--- /dev/null
+++ b/src/test/rustdoc/recursion2.rs
@@ -0,0 +1,13 @@
+#![crate_type = "lib"]
+
+mod m {
+    pub use self::a::Foo;
+
+    mod a {
+        pub struct Foo;
+    }
+
+    mod b {
+        pub use super::*;
+    }
+}
diff --git a/src/test/rustdoc/recursion3.rs b/src/test/rustdoc/recursion3.rs
new file mode 100644
index 0000000..e69b430
--- /dev/null
+++ b/src/test/rustdoc/recursion3.rs
@@ -0,0 +1,13 @@
+pub mod longhands {
+    pub use super::*;
+
+    pub use super::common_types::computed::compute_CSSColor as to_computed_value;
+
+    pub fn computed_as_specified() {}
+}
+
+pub mod common_types {
+    pub mod computed {
+        pub use super::super::longhands::computed_as_specified as compute_CSSColor;
+    }
+}
diff --git a/src/test/rustdoc/redirect-const.rs b/src/test/rustdoc/redirect-const.rs
new file mode 100644
index 0000000..453da838
--- /dev/null
+++ b/src/test/rustdoc/redirect-const.rs
@@ -0,0 +1,13 @@
+#![crate_name="foo"]
+
+pub use hidden::STATIC_FOO;
+pub use hidden::CONST_FOO;
+
+mod hidden {
+    // @has foo/hidden/static.STATIC_FOO.html
+    // @has - '//p/a' '../../foo/static.STATIC_FOO.html'
+    pub static STATIC_FOO: u64 = 0;
+    // @has foo/hidden/constant.CONST_FOO.html
+    // @has - '//p/a' '../../foo/constant.CONST_FOO.html'
+    pub const CONST_FOO: u64 = 0;
+}
diff --git a/src/test/rustdoc/redirect-rename.rs b/src/test/rustdoc/redirect-rename.rs
new file mode 100644
index 0000000..7de5608
--- /dev/null
+++ b/src/test/rustdoc/redirect-rename.rs
@@ -0,0 +1,22 @@
+#![crate_name = "foo"]
+
+mod hidden {
+    // @has foo/hidden/struct.Foo.html
+    // @has - '//p/a' '../../foo/struct.FooBar.html'
+    pub struct Foo {}
+
+    // @has foo/hidden/bar/index.html
+    // @has - '//p/a' '../../foo/baz/index.html'
+    pub mod bar {
+        // @has foo/hidden/bar/struct.Thing.html
+        // @has - '//p/a' '../../foo/baz/struct.Thing.html'
+        pub struct Thing {}
+    }
+}
+
+// @has foo/struct.FooBar.html
+pub use hidden::Foo as FooBar;
+
+// @has foo/baz/index.html
+// @has foo/baz/struct.Thing.html
+pub use hidden::bar as baz;
diff --git a/src/test/rustdoc/redirect.rs b/src/test/rustdoc/redirect.rs
new file mode 100644
index 0000000..e3a14c7
--- /dev/null
+++ b/src/test/rustdoc/redirect.rs
@@ -0,0 +1,39 @@
+// aux-build:reexp-stripped.rs
+// build-aux-docs
+// ignore-cross-compile
+
+extern crate reexp_stripped;
+
+pub trait Foo {}
+
+// @has redirect/index.html
+// @has - '//code' 'pub use reexp_stripped::Bar'
+// @has - '//code/a' 'Bar'
+// @has reexp_stripped/hidden/struct.Bar.html
+// @has - '//p/a' '../../reexp_stripped/struct.Bar.html'
+// @has 'reexp_stripped/struct.Bar.html'
+#[doc(no_inline)]
+pub use reexp_stripped::Bar;
+impl Foo for Bar {}
+
+// @has redirect/index.html
+// @has - '//code' 'pub use reexp_stripped::Quz'
+// @has - '//code/a' 'Quz'
+// @has reexp_stripped/private/struct.Quz.html
+// @has - '//p/a' '../../reexp_stripped/struct.Quz.html'
+// @has 'reexp_stripped/struct.Quz.html'
+#[doc(no_inline)]
+pub use reexp_stripped::Quz;
+impl Foo for Quz {}
+
+mod private_no_inline {
+    pub struct Qux;
+    impl ::Foo for Qux {}
+}
+
+// @has redirect/index.html
+// @has - '//code' 'pub use private_no_inline::Qux'
+// @!has - '//a' 'Qux'
+// @!has redirect/struct.Qux.html
+#[doc(no_inline)]
+pub use private_no_inline::Qux;
diff --git a/src/test/rustdoc/remove-duplicates.rs b/src/test/rustdoc/remove-duplicates.rs
new file mode 100644
index 0000000..759bf84
--- /dev/null
+++ b/src/test/rustdoc/remove-duplicates.rs
@@ -0,0 +1,14 @@
+#![crate_name = "foo"]
+
+mod foo {
+    pub use bar::*;
+    pub mod bar {
+        pub trait Foo {
+            fn foo();
+        }
+    }
+}
+
+// @count foo/index.html '//*[@class="trait"]' 1
+pub use foo::bar::*;
+pub use foo::*;
diff --git a/src/test/rustdoc/rustc-macro-crate.rs b/src/test/rustdoc/rustc-macro-crate.rs
new file mode 100644
index 0000000..2f6308b
--- /dev/null
+++ b/src/test/rustdoc/rustc-macro-crate.rs
@@ -0,0 +1,13 @@
+// force-host
+// no-prefer-dynamic
+
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+use proc_macro::TokenStream;
+
+#[proc_macro_derive(Foo)]
+pub fn foo(input: TokenStream) -> TokenStream {
+    input
+}
diff --git a/src/test/rustdoc/rustc_deprecated-future.rs b/src/test/rustdoc/rustc_deprecated-future.rs
new file mode 100644
index 0000000..3133775
--- /dev/null
+++ b/src/test/rustdoc/rustc_deprecated-future.rs
@@ -0,0 +1,11 @@
+#![feature(staged_api)]
+
+#![stable(feature = "rustc_deprecated-future-test", since = "1.0.0")]
+
+// @has rustc_deprecated_future/index.html '//*[@class="stab deprecated"]' \
+//      'Deprecation planned'
+// @has rustc_deprecated_future/struct.S.html '//*[@class="stab deprecated"]' \
+//      'Deprecating in 99.99.99: effectively never'
+#[rustc_deprecated(since = "99.99.99", reason = "effectively never")]
+#[stable(feature = "rustc_deprecated-future-test", since = "1.0.0")]
+pub struct S;
diff --git a/src/test/rustdoc/search-index-summaries.rs b/src/test/rustdoc/search-index-summaries.rs
new file mode 100644
index 0000000..dd9c1a0
--- /dev/null
+++ b/src/test/rustdoc/search-index-summaries.rs
@@ -0,0 +1,10 @@
+#![crate_name = "foo"]
+
+// @has 'search-index.js' 'Foo short link.'
+// @!has - 'www.example.com'
+// @!has - 'More Foo.'
+
+/// Foo short [link](https://www.example.com/).
+///
+/// More Foo.
+pub struct Foo;
diff --git a/src/test/rustdoc/search-index.rs b/src/test/rustdoc/search-index.rs
new file mode 100644
index 0000000..f1b78f1
--- /dev/null
+++ b/src/test/rustdoc/search-index.rs
@@ -0,0 +1,26 @@
+#![crate_name = "rustdoc_test"]
+
+use std::ops::Deref;
+
+// @has search-index.js Foo
+pub use private::Foo;
+
+mod private {
+    pub struct Foo;
+    impl Foo {
+        pub fn test_method() {} // @has - test_method
+        fn priv_method() {} // @!has - priv_method
+    }
+
+    pub trait PrivateTrait {
+        fn trait_method(&self) {} // @!has - priv_method
+    }
+}
+
+pub struct Bar;
+
+impl Deref for Bar {
+    // @!has search-index.js Target
+    type Target = Bar;
+    fn deref(&self) -> &Bar { self }
+}
diff --git a/src/test/rustdoc/short-docblock-codeblock.rs b/src/test/rustdoc/short-docblock-codeblock.rs
new file mode 100644
index 0000000..fc8d53c
--- /dev/null
+++ b/src/test/rustdoc/short-docblock-codeblock.rs
@@ -0,0 +1,12 @@
+#![crate_name = "foo"]
+
+// @has foo/index.html '//*[@class="module-item"]//td[@class="docblock-short"]' ""
+// @!has foo/index.html '//*[@id="module-item"]//td[@class="docblock-short"]' "Some text."
+// @!has foo/index.html '//*[@id="module-item"]//td[@class="docblock-short"]' "let x = 12;"
+
+/// ```
+/// let x = 12;
+/// ```
+///
+/// Some text.
+pub fn foo() {}
diff --git a/src/test/rustdoc/short-dockblock.rs b/src/test/rustdoc/short-dockblock.rs
new file mode 100644
index 0000000..5493bca
--- /dev/null
+++ b/src/test/rustdoc/short-dockblock.rs
@@ -0,0 +1,25 @@
+#![crate_name = "foo"]
+
+// @has foo/index.html '//*[@class="docblock-short"]/p' 'fooo'
+// @!has foo/index.html '//*[@class="docblock-short"]/p/h1' 'fooo'
+// @has foo/fn.foo.html '//h1[@id="fooo"]/a[@href="#fooo"]' 'fooo'
+
+/// # fooo
+///
+/// foo
+pub fn foo() {}
+
+// @has foo/index.html '//*[@class="docblock-short"]/p' 'mooood'
+// @!has foo/index.html '//*[@class="docblock-short"]/p/h2' 'mooood'
+// @has foo/foo/index.html '//h2[@id="mooood"]/a[@href="#mooood"]' 'mooood'
+
+/// ## mooood
+///
+/// foo mod
+pub mod foo {}
+
+// @has foo/index.html '//*[@class="docblock-short"]/p/a[@href=\
+//                      "https://nougat.world"]/code' 'nougat'
+
+/// [`nougat`](https://nougat.world)
+pub struct Bar;
diff --git a/src/test/rustdoc/sidebar-items.rs b/src/test/rustdoc/sidebar-items.rs
new file mode 100644
index 0000000..3ba6dba
--- /dev/null
+++ b/src/test/rustdoc/sidebar-items.rs
@@ -0,0 +1,49 @@
+#![crate_name = "foo"]
+
+// @has foo/trait.Foo.html
+// @has - '//*[@class="sidebar-title"][@href="#required-methods"]' 'Required Methods'
+// @has - '//*[@class="sidebar-links"]/a' 'bar'
+// @has - '//*[@class="sidebar-title"][@href="#provided-methods"]' 'Provided Methods'
+// @has - '//*[@class="sidebar-links"]/a' 'foo'
+// @has - '//*[@class="sidebar-title"][@href="#associated-const"]' 'Associated Constants'
+// @has - '//*[@class="sidebar-links"]/a' 'BAR'
+// @has - '//*[@class="sidebar-title"][@href="#associated-types"]' 'Associated Types'
+// @has - '//*[@class="sidebar-links"]/a' 'Output'
+pub trait Foo {
+    const BAR: u32 = 0;
+    type Output: ?Sized;
+
+    fn foo() {}
+    fn bar() -> Self::Output;
+}
+
+// @has foo/struct.Bar.html
+// @has - '//*[@class="sidebar-title"][@href="#fields"]' 'Fields'
+// @has - '//*[@class="sidebar-links"]/a[@href="#structfield.f"]' 'f'
+// @has - '//*[@class="sidebar-links"]/a[@href="#structfield.u"]' 'u'
+// @!has - '//*[@class="sidebar-links"]/a' 'waza'
+pub struct Bar {
+    pub f: u32,
+    pub u: u32,
+    waza: u32,
+}
+
+// @has foo/enum.En.html
+// @has - '//*[@class="sidebar-title"][@href="#variants"]' 'Variants'
+// @has - '//*[@class="sidebar-links"]/a' 'foo'
+// @has - '//*[@class="sidebar-links"]/a' 'bar'
+pub enum En {
+    foo,
+    bar,
+}
+
+// @has foo/union.MyUnion.html
+// @has - '//*[@class="sidebar-title"][@href="#fields"]' 'Fields'
+// @has - '//*[@class="sidebar-links"]/a[@href="#structfield.f1"]' 'f1'
+// @has - '//*[@class="sidebar-links"]/a[@href="#structfield.f2"]' 'f2'
+// @!has - '//*[@class="sidebar-links"]/a' 'waza'
+pub union MyUnion {
+    pub f1: u32,
+    pub f2: f32,
+    waza: u32,
+}
diff --git a/src/test/rustdoc/sidebar-link-generation.rs b/src/test/rustdoc/sidebar-link-generation.rs
new file mode 100644
index 0000000..76b77b9
--- /dev/null
+++ b/src/test/rustdoc/sidebar-link-generation.rs
@@ -0,0 +1,13 @@
+#![crate_name = "foo"]
+
+// @has foo/struct.SomeStruct.html '//*[@class="sidebar-links"]/a[@href="#method.some_fn-1"]' \
+//          "some_fn"
+pub struct SomeStruct<T> { _inner: T }
+
+impl SomeStruct<()> {
+    pub fn some_fn(&self) {}
+}
+
+impl SomeStruct<usize> {
+    pub fn some_fn(&self) {}
+}
diff --git a/src/test/rustdoc/smoke.rs b/src/test/rustdoc/smoke.rs
new file mode 100644
index 0000000..c1ed3a0
--- /dev/null
+++ b/src/test/rustdoc/smoke.rs
@@ -0,0 +1,25 @@
+// @has smoke/index.html
+
+//! Very docs
+
+// @has smoke/bar/index.html
+pub mod bar {
+
+    /// So correct
+    // @has smoke/bar/baz/index.html
+    pub mod baz {
+        /// Much detail
+        // @has smoke/bar/baz/fn.baz.html
+        pub fn baz() { }
+    }
+
+    /// *wow*
+    // @has smoke/bar/trait.Doge.html
+    pub trait Doge { fn dummy(&self) { } }
+
+    // @has smoke/bar/struct.Foo.html
+    pub struct Foo { x: isize, y: usize }
+
+    // @has smoke/bar/fn.prawns.html
+    pub fn prawns((a, b): (isize, usize), Foo { x, y }: Foo) { }
+}
diff --git a/src/test/rustdoc/sort-modules-by-appearance.rs b/src/test/rustdoc/sort-modules-by-appearance.rs
new file mode 100644
index 0000000..5be6b98
--- /dev/null
+++ b/src/test/rustdoc/sort-modules-by-appearance.rs
@@ -0,0 +1,13 @@
+// Tests the rustdoc --sort-modules-by-appearance option, that allows module declarations to appear
+// in the order they are declared in the source code, rather than only alphabetically.
+
+// compile-flags: -Z unstable-options --sort-modules-by-appearance
+
+pub mod module_b {}
+
+pub mod module_c {}
+
+pub mod module_a {}
+
+// @matches 'sort_modules_by_appearance/index.html' '(?s)module_b.*module_c.*module_a'
+// @matches 'sort_modules_by_appearance/sidebar-items.js' '"module_b".*"module_c".*"module_a"'
diff --git a/src/test/rustdoc/source-file.rs b/src/test/rustdoc/source-file.rs
new file mode 100644
index 0000000..968899d
--- /dev/null
+++ b/src/test/rustdoc/source-file.rs
@@ -0,0 +1,5 @@
+#![crate_name = "foo"]
+
+// @has source-files.js source-file.rs
+
+pub struct Foo;
diff --git a/src/test/rustdoc/src-links-external.rs b/src/test/rustdoc/src-links-external.rs
new file mode 100644
index 0000000..0469e4a
--- /dev/null
+++ b/src/test/rustdoc/src-links-external.rs
@@ -0,0 +1,14 @@
+// aux-build:src-links-external.rs
+// build-aux-docs
+// ignore-cross-compile
+// ignore-tidy-linelength
+
+#![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/src/test/rustdoc/src-links.rs b/src/test/rustdoc/src-links.rs
new file mode 100644
index 0000000..353ce10
--- /dev/null
+++ b/src/test/rustdoc/src-links.rs
@@ -0,0 +1,46 @@
+#![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 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/src/test/rustdoc/src-links/compiletest-ignore-dir b/src/test/rustdoc/src-links/compiletest-ignore-dir
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/test/rustdoc/src-links/compiletest-ignore-dir
diff --git a/src/test/rustdoc/src-links/mod.rs b/src/test/rustdoc/src-links/mod.rs
new file mode 100644
index 0000000..27b2396
--- /dev/null
+++ b/src/test/rustdoc/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/src/test/rustdoc/stability.rs b/src/test/rustdoc/stability.rs
new file mode 100644
index 0000000..18a2160
--- /dev/null
+++ b/src/test/rustdoc/stability.rs
@@ -0,0 +1,12 @@
+#![feature(staged_api)]
+
+#![unstable(feature = "test", issue = "0")]
+
+pub struct Unstable {
+    // @has stability/struct.Unstable.html \
+    //      '//div[@class="stability"]//div[@class="stab unstable"]' \
+    //      'This is a nightly-only experimental API'
+    // @count stability/struct.Unstable.html '//span[@class="stab unstable"]' 0
+    pub foo: u32,
+    pub bar: u32,
+}
diff --git a/src/test/rustdoc/static-root-path.rs b/src/test/rustdoc/static-root-path.rs
new file mode 100644
index 0000000..84b32f9
--- /dev/null
+++ b/src/test/rustdoc/static-root-path.rs
@@ -0,0 +1,14 @@
+// compile-flags:-Z unstable-options --static-root-path /cache/
+
+// @has static_root_path/struct.SomeStruct.html
+// @matches - '"/cache/main\.js"'
+// @!matches - '"\.\./main\.js"'
+// @matches - '"\.\./search-index\.js"'
+// @!matches - '"/cache/search-index\.js"'
+pub struct SomeStruct;
+
+// @has src/static_root_path/static-root-path.rs.html
+// @matches - '"/cache/source-script\.js"'
+// @!matches - '"\.\./\.\./source-script\.js"'
+// @matches - '"\.\./\.\./source-files.js"'
+// @!matches - '"/cache/source-files\.js"'
diff --git a/src/test/rustdoc/struct-field.rs b/src/test/rustdoc/struct-field.rs
new file mode 100644
index 0000000..c99169f
--- /dev/null
+++ b/src/test/rustdoc/struct-field.rs
@@ -0,0 +1,23 @@
+#![crate_name = "foo"]
+
+// ignore-tidy-linelength
+
+// @has foo/index.html '//*[@class="docblock"]/p/a[@href="../foo/struct.Foo.html#structfield.bar"]' 'Foo::bar'
+// @has foo/index.html '//*[@class="docblock"]/p/a[@href="../foo/union.Bar.html#structfield.foo"]' 'Bar::foo'
+// @has foo/index.html '//*[@class="docblock"]/p/a[@href="../foo/enum.Uniooon.html#X.v"]' 'Uniooon::X'
+
+//! Test with [Foo::bar], [Bar::foo], [Uniooon::X]
+
+pub struct Foo {
+    pub bar: usize,
+}
+
+pub union Bar {
+    pub foo: u32,
+}
+
+pub enum Uniooon {
+    F,
+    X,
+    Y,
+}
diff --git a/src/test/rustdoc/structfields.rs b/src/test/rustdoc/structfields.rs
new file mode 100644
index 0000000..235f0e8
--- /dev/null
+++ b/src/test/rustdoc/structfields.rs
@@ -0,0 +1,52 @@
+// compile-flags:-Z unstable-options --generate-redirect-pages
+
+// @has structfields/Foo.t.html
+// @has - struct.Foo.html
+// @has structfields/struct.Foo.html
+pub struct Foo {
+    // @has - //pre "pub a: ()"
+    pub a: (),
+    // @has - //pre "// some fields omitted"
+    // @!has - //pre "b: ()"
+    b: (),
+    // @!has - //pre "c: usize"
+    #[doc(hidden)]
+    c: usize,
+    // @has - //pre "pub d: usize"
+    pub d: usize,
+}
+
+// @has structfields/Bar.t.html
+// @has - struct.Bar.html
+// @has structfields/struct.Bar.html
+pub struct Bar {
+    // @has - //pre "pub a: ()"
+    pub a: (),
+    // @!has - //pre "// some fields omitted"
+}
+
+// @has structfields/Qux.t.html
+// @has - enum.Qux.html
+// @has structfields/enum.Qux.html
+pub enum Qux {
+    Quz {
+        // @has - //pre "a: ()"
+        a: (),
+        // @!has - //pre "b: ()"
+        #[doc(hidden)]
+        b: (),
+        // @has - //pre "c: usize"
+        c: usize,
+        // @has - //pre "// some fields omitted"
+    },
+}
+
+// @has structfields/struct.Baz.html //pre "pub struct Baz { /* fields omitted */ }"
+pub struct Baz {
+    x: u8,
+    #[doc(hidden)]
+    pub y: u8,
+}
+
+// @has structfields/struct.Quux.html //pre "pub struct Quux {}"
+pub struct Quux {}
diff --git a/src/test/rustdoc/synthetic_auto/basic.rs b/src/test/rustdoc/synthetic_auto/basic.rs
new file mode 100644
index 0000000..d5f1269
--- /dev/null
+++ b/src/test/rustdoc/synthetic_auto/basic.rs
@@ -0,0 +1,8 @@
+// @has basic/struct.Foo.html
+// @has - '//code' 'impl<T> Send for Foo<T> where T: Send'
+// @has - '//code' 'impl<T> Sync for Foo<T> where T: Sync'
+// @count - '//*[@id="implementations-list"]/*[@class="impl"]' 0
+// @count - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]' 2
+pub struct Foo<T> {
+    field: T,
+}
diff --git a/src/test/rustdoc/synthetic_auto/complex.rs b/src/test/rustdoc/synthetic_auto/complex.rs
new file mode 100644
index 0000000..609cefc
--- /dev/null
+++ b/src/test/rustdoc/synthetic_auto/complex.rs
@@ -0,0 +1,42 @@
+mod foo {
+    pub trait MyTrait<'a> {
+        type MyItem: ?Sized;
+    }
+
+    pub struct Inner<'a, Q, R: ?Sized> {
+        field: Q,
+        field3: &'a u8,
+        my_foo: Foo<Q>,
+        field2: R,
+    }
+
+    pub struct Outer<'a, T, K: ?Sized> {
+        my_inner: Inner<'a, T, K>,
+    }
+
+    pub struct Foo<T> {
+        myfield: T,
+    }
+}
+
+// @has complex/struct.NotOuter.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'a, T, K: \
+// ?Sized> Send for NotOuter<'a, T, K> where K: for<'b> Fn((&'b bool, &'a u8)) \
+// -> &'b i8, T: MyTrait<'a>, <T as MyTrait<'a>>::MyItem: Copy, 'a: 'static"
+
+pub use foo::{Foo, Inner as NotInner, MyTrait as NotMyTrait, Outer as NotOuter};
+
+unsafe impl<T> Send for Foo<T>
+where
+    T: NotMyTrait<'static>,
+{
+}
+
+unsafe impl<'a, Q, R: ?Sized> Send for NotInner<'a, Q, R>
+where
+    Q: NotMyTrait<'a>,
+    <Q as NotMyTrait<'a>>::MyItem: Copy,
+    R: for<'b> Fn((&'b bool, &'a u8)) -> &'b i8,
+    Foo<Q>: Send,
+{
+}
diff --git a/src/test/rustdoc/synthetic_auto/lifetimes.rs b/src/test/rustdoc/synthetic_auto/lifetimes.rs
new file mode 100644
index 0000000..6d0a68f
--- /dev/null
+++ b/src/test/rustdoc/synthetic_auto/lifetimes.rs
@@ -0,0 +1,19 @@
+pub struct Inner<'a, T: 'a> {
+    field: &'a T,
+}
+
+unsafe impl<'a, T> Send for Inner<'a, T>
+where
+    'a: 'static,
+    T: for<'b> Fn(&'b bool) -> &'a u8,
+{}
+
+// @has lifetimes/struct.Foo.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'c, K> Send \
+// for Foo<'c, K> where K: for<'b> Fn(&'b bool) -> &'c u8, 'c: 'static"
+//
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'c, K> Sync \
+// for Foo<'c, K> where K: Sync"
+pub struct Foo<'c, K: 'c> {
+    inner_field: Inner<'c, K>,
+}
diff --git a/src/test/rustdoc/synthetic_auto/manual.rs b/src/test/rustdoc/synthetic_auto/manual.rs
new file mode 100644
index 0000000..413ba18
--- /dev/null
+++ b/src/test/rustdoc/synthetic_auto/manual.rs
@@ -0,0 +1,14 @@
+// @has manual/struct.Foo.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' 'impl<T> Sync for \
+// Foo<T> where T: Sync'
+//
+// @has - '//*[@id="implementations-list"]/*[@class="impl"]//code' \
+// 'impl<T> Send for Foo<T>'
+//
+// @count - '//*[@id="implementations-list"]/*[@class="impl"]' 1
+// @count - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]' 1
+pub struct Foo<T> {
+    field: T,
+}
+
+unsafe impl<T> Send for Foo<T> {}
diff --git a/src/test/rustdoc/synthetic_auto/negative.rs b/src/test/rustdoc/synthetic_auto/negative.rs
new file mode 100644
index 0000000..3071384
--- /dev/null
+++ b/src/test/rustdoc/synthetic_auto/negative.rs
@@ -0,0 +1,13 @@
+pub struct Inner<T: Copy> {
+    field: *mut T,
+}
+
+// @has negative/struct.Outer.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<T> !Send for \
+// Outer<T>"
+//
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<T> \
+// !Sync for Outer<T>"
+pub struct Outer<T: Copy> {
+    inner_field: Inner<T>,
+}
diff --git a/src/test/rustdoc/synthetic_auto/nested.rs b/src/test/rustdoc/synthetic_auto/nested.rs
new file mode 100644
index 0000000..e710ce1
--- /dev/null
+++ b/src/test/rustdoc/synthetic_auto/nested.rs
@@ -0,0 +1,19 @@
+pub struct Inner<T> {
+    field: T,
+}
+
+unsafe impl<T> Send for Inner<T>
+where
+    T: Copy,
+{
+}
+
+// @has nested/struct.Foo.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' 'impl<T> Send for \
+// Foo<T> where T: Copy'
+//
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' \
+// 'impl<T> Sync for Foo<T> where T: Sync'
+pub struct Foo<T> {
+    inner_field: Inner<T>,
+}
diff --git a/src/test/rustdoc/synthetic_auto/no-redundancy.rs b/src/test/rustdoc/synthetic_auto/no-redundancy.rs
new file mode 100644
index 0000000..cf17311
--- /dev/null
+++ b/src/test/rustdoc/synthetic_auto/no-redundancy.rs
@@ -0,0 +1,16 @@
+pub struct Inner<T> {
+    field: T,
+}
+
+unsafe impl<T> Send for Inner<T>
+where
+    T: Copy + Send,
+{
+}
+
+// @has no_redundancy/struct.Outer.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<T> Send for \
+// Outer<T> where T: Copy + Send"
+pub struct Outer<T> {
+    inner_field: Inner<T>,
+}
diff --git a/src/test/rustdoc/synthetic_auto/project.rs b/src/test/rustdoc/synthetic_auto/project.rs
new file mode 100644
index 0000000..5346521
--- /dev/null
+++ b/src/test/rustdoc/synthetic_auto/project.rs
@@ -0,0 +1,33 @@
+pub struct Inner<'a, T: 'a> {
+    field: &'a T,
+}
+
+trait MyTrait {
+    type MyItem;
+}
+
+trait OtherTrait {}
+
+unsafe impl<'a, T> Send for Inner<'a, T>
+where
+    'a: 'static,
+    T: MyTrait<MyItem = bool>,
+{
+}
+unsafe impl<'a, T> Sync for Inner<'a, T>
+where
+    'a: 'static,
+    T: MyTrait,
+    <T as MyTrait>::MyItem: OtherTrait,
+{
+}
+
+// @has project/struct.Foo.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'c, K> Send \
+// for Foo<'c, K> where K: MyTrait<MyItem = bool>, 'c: 'static"
+//
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<'c, K> Sync \
+// for Foo<'c, K> where K: MyTrait, <K as MyTrait>::MyItem: OtherTrait, 'c: 'static,"
+pub struct Foo<'c, K: 'c> {
+    inner_field: Inner<'c, K>,
+}
diff --git a/src/test/rustdoc/synthetic_auto/self-referential.rs b/src/test/rustdoc/synthetic_auto/self-referential.rs
new file mode 100644
index 0000000..7d15434
--- /dev/null
+++ b/src/test/rustdoc/synthetic_auto/self-referential.rs
@@ -0,0 +1,30 @@
+// Some unusual code minimized from
+// https://github.com/sile/handy_async/tree/7b619b762c06544fc67792c8ff8ebc24a88fdb98
+
+pub trait Pattern {
+    type Value;
+}
+
+pub struct Constrain<A, B = A, C = A>(A, B, C);
+
+impl<A, B, C> Pattern for Constrain<A, B, C>
+    where A: Pattern,
+          B: Pattern<Value = A::Value>,
+          C: Pattern<Value = A::Value>,
+{
+    type Value = A::Value;
+}
+
+pub struct Wrapper<T>(T);
+
+impl<T> Pattern for Wrapper<T> {
+    type Value = T;
+}
+
+
+// @has self_referential/struct.WriteAndThen.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<P1> Send for \
+// WriteAndThen<P1>  where  <P1 as Pattern>::Value: Send"
+pub struct WriteAndThen<P1>(pub P1::Value,pub <Constrain<P1, Wrapper<P1::Value>> as Pattern>::Value)
+    where P1: Pattern;
+
diff --git a/src/test/rustdoc/synthetic_auto/static-region.rs b/src/test/rustdoc/synthetic_auto/static-region.rs
new file mode 100644
index 0000000..5949374
--- /dev/null
+++ b/src/test/rustdoc/synthetic_auto/static-region.rs
@@ -0,0 +1,10 @@
+pub trait OwnedTrait<'a> {
+    type Reader;
+}
+
+// @has static_region/struct.Owned.html
+// @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//code' "impl<T> Send for \
+// Owned<T> where <T as OwnedTrait<'static>>::Reader: Send"
+pub struct Owned<T> where T: OwnedTrait<'static> {
+    marker: <T as OwnedTrait<'static>>::Reader,
+}
diff --git a/src/test/rustdoc/test-lists.rs b/src/test/rustdoc/test-lists.rs
new file mode 100644
index 0000000..6a510b9
--- /dev/null
+++ b/src/test/rustdoc/test-lists.rs
@@ -0,0 +1,26 @@
+#![crate_name = "foo"]
+
+// @has foo/fn.f.html
+// @has - //ol/li "list"
+// @has - //ol/li/ol/li "fooooo"
+// @has - //ol/li/ol/li "x"
+// @has - //ol/li "foo"
+/// 1. list
+///     1. fooooo
+///     2. x
+/// 2. foo
+pub fn f() {}
+
+// @has foo/fn.foo2.html
+// @has - //ul/li "normal list"
+// @has - //ul/li/ul/li "sub list"
+// @has - //ul/li/ul/li "new elem still same elem and again same elem!"
+// @has - //ul/li "new big elem"
+/// * normal list
+///     * sub list
+///     * new elem
+///       still same elem
+///
+///       and again same elem!
+/// * new big elem
+pub fn foo2() {}
diff --git a/src/test/rustdoc/test-parens.rs b/src/test/rustdoc/test-parens.rs
new file mode 100644
index 0000000..d9b9c79
--- /dev/null
+++ b/src/test/rustdoc/test-parens.rs
@@ -0,0 +1,5 @@
+#![crate_name = "foo"]
+
+// @has foo/fn.foo.html
+// @has - '//*[@class="rust fn"]' "_: &(dyn ToString + 'static)"
+pub fn foo(_: &(ToString + 'static)) {}
diff --git a/src/test/rustdoc/test_option_check/bar.rs b/src/test/rustdoc/test_option_check/bar.rs
new file mode 100644
index 0000000..50a182c
--- /dev/null
+++ b/src/test/rustdoc/test_option_check/bar.rs
@@ -0,0 +1,9 @@
+// compile-flags: --test
+// check-test-line-numbers-match
+
+/// This looks like another awesome test!
+///
+/// ```
+/// println!("foo?");
+/// ```
+pub fn foooo() {}
diff --git a/src/test/rustdoc/test_option_check/test.rs b/src/test/rustdoc/test_option_check/test.rs
new file mode 100644
index 0000000..964e8e3
--- /dev/null
+++ b/src/test/rustdoc/test_option_check/test.rs
@@ -0,0 +1,18 @@
+// compile-flags: --test
+// check-test-line-numbers-match
+
+pub mod bar;
+
+/// This is a Foo;
+///
+/// ```
+/// println!("baaaaaar");
+/// ```
+pub struct Foo;
+
+/// This is a Bar;
+///
+/// ```
+/// println!("fooooo");
+/// ```
+pub struct Bar;
diff --git a/src/test/rustdoc/titles.rs b/src/test/rustdoc/titles.rs
new file mode 100644
index 0000000..3b4c42d
--- /dev/null
+++ b/src/test/rustdoc/titles.rs
@@ -0,0 +1,49 @@
+#![crate_name = "foo"]
+
+// @matches 'foo/index.html' '//h1' 'Crate foo'
+
+// @matches 'foo/foo_mod/index.html' '//h1' 'Module foo::foo_mod'
+pub mod foo_mod {
+    pub struct __Thing {}
+}
+
+extern {
+    // @matches 'foo/fn.foo_ffn.html' '//h1' 'Function foo::foo_ffn'
+    pub fn foo_ffn();
+}
+
+// @matches 'foo/fn.foo_fn.html' '//h1' 'Function foo::foo_fn'
+pub fn foo_fn() {}
+
+// @matches 'foo/trait.FooTrait.html' '//h1' 'Trait foo::FooTrait'
+pub trait FooTrait {}
+
+// @matches 'foo/struct.FooStruct.html' '//h1' 'Struct foo::FooStruct'
+pub struct FooStruct;
+
+// @matches 'foo/enum.FooEnum.html' '//h1' 'Enum foo::FooEnum'
+pub enum FooEnum {}
+
+// @matches 'foo/type.FooType.html' '//h1' 'Type Definition foo::FooType'
+pub type FooType = FooStruct;
+
+// @matches 'foo/macro.foo_macro.html' '//h1' 'Macro foo::foo_macro'
+#[macro_export]
+macro_rules! foo_macro {
+    () => ();
+}
+
+// @matches 'foo/primitive.bool.html' '//h1' 'Primitive Type bool'
+#[doc(primitive = "bool")]
+mod bool {}
+
+// @matches 'foo/static.FOO_STATIC.html' '//h1' 'Static foo::FOO_STATIC'
+pub static FOO_STATIC: FooStruct = FooStruct;
+
+extern {
+    // @matches 'foo/static.FOO_FSTATIC.html' '//h1' 'Static foo::FOO_FSTATIC'
+    pub static FOO_FSTATIC: FooStruct;
+}
+
+// @matches 'foo/constant.FOO_CONSTANT.html' '//h1' 'Constant foo::FOO_CONSTANT'
+pub const FOO_CONSTANT: FooStruct = FooStruct;
diff --git a/src/test/rustdoc/trait-attributes.rs b/src/test/rustdoc/trait-attributes.rs
new file mode 100644
index 0000000..971e6b5
--- /dev/null
+++ b/src/test/rustdoc/trait-attributes.rs
@@ -0,0 +1,22 @@
+#![crate_name = "foo"]
+
+// ignore-tidy-linelength
+
+pub trait Foo {
+    // @has foo/trait.Foo.html '//h3[@id="tymethod.foo"]//div[@class="docblock attributes"]' '#[must_use]'
+    #[must_use]
+    fn foo();
+}
+
+#[must_use]
+pub struct Bar;
+
+impl Bar {
+    // @has foo/struct.Bar.html '//h4[@id="method.bar"]//div[@class="docblock attributes"]' '#[must_use]'
+    #[must_use]
+    pub fn bar() {}
+
+    // @has foo/struct.Bar.html '//h4[@id="method.bar2"]//div[@class="docblock attributes"]' '#[must_use]'
+    #[must_use]
+    pub fn bar2() {}
+}
diff --git a/src/test/rustdoc/trait-self-link.rs b/src/test/rustdoc/trait-self-link.rs
new file mode 100644
index 0000000..51e1fe9
--- /dev/null
+++ b/src/test/rustdoc/trait-self-link.rs
@@ -0,0 +1,6 @@
+// @!has trait_self_link/trait.Foo.html //a/@href ../trait_self_link/trait.Foo.html
+pub trait Foo {}
+
+pub struct Bar;
+
+impl Foo for Bar {}
diff --git a/src/test/rustdoc/trait_alias.rs b/src/test/rustdoc/trait_alias.rs
new file mode 100644
index 0000000..98b8d87
--- /dev/null
+++ b/src/test/rustdoc/trait_alias.rs
@@ -0,0 +1,21 @@
+#![feature(trait_alias)]
+
+#![crate_name = "foo"]
+
+use std::fmt::Debug;
+
+// @has foo/all.html '//a[@href="traitalias.CopyAlias.html"]' 'CopyAlias'
+// @has foo/all.html '//a[@href="traitalias.Alias2.html"]' 'Alias2'
+// @has foo/all.html '//a[@href="traitalias.Foo.html"]' 'Foo'
+
+// @has foo/index.html '//h2[@id="trait-aliases"]' 'Trait aliases'
+// @has foo/index.html '//a[@class="traitalias"]' 'CopyAlias'
+// @has foo/index.html '//a[@class="traitalias"]' 'Alias2'
+// @has foo/index.html '//a[@class="traitalias"]' 'Foo'
+
+// @has foo/traitalias.CopyAlias.html '//section[@id="main"]/pre' 'trait CopyAlias = Copy;'
+pub trait CopyAlias = Copy;
+// @has foo/traitalias.Alias2.html '//section[@id="main"]/pre' 'trait Alias2 = Copy + Debug;'
+pub trait Alias2 = Copy + Debug;
+// @has foo/traitalias.Foo.html '//section[@id="main"]/pre' 'trait Foo<T> = Into<T> + Debug;'
+pub trait Foo<T> = Into<T> + Debug;
diff --git a/src/test/rustdoc/traits-in-bodies-private.rs b/src/test/rustdoc/traits-in-bodies-private.rs
new file mode 100644
index 0000000..96b7c4f
--- /dev/null
+++ b/src/test/rustdoc/traits-in-bodies-private.rs
@@ -0,0 +1,13 @@
+// when implementing the fix for traits-in-bodies, there was an ICE when documenting private items
+// and a trait was defined in non-module scope
+
+// compile-flags:--document-private-items
+
+// @has traits_in_bodies_private/struct.SomeStruct.html
+// @!has - '//code' 'impl HiddenTrait for SomeStruct'
+pub struct SomeStruct;
+
+fn __implementation_details() {
+    trait HiddenTrait {}
+    impl HiddenTrait for SomeStruct {}
+}
diff --git a/src/test/rustdoc/traits-in-bodies.rs b/src/test/rustdoc/traits-in-bodies.rs
new file mode 100644
index 0000000..1c3727a
--- /dev/null
+++ b/src/test/rustdoc/traits-in-bodies.rs
@@ -0,0 +1,52 @@
+//prior to fixing `everybody_loops` to preserve items, rustdoc would crash on this file, as it
+//didn't see that `SomeStruct` implemented `Clone`
+
+pub struct Bounded<T: Clone>(T);
+
+// @has traits_in_bodies/struct.SomeStruct.html
+// @has - '//code' 'impl Clone for SomeStruct'
+pub struct SomeStruct;
+
+fn asdf() -> Bounded<SomeStruct> {
+    impl Clone for SomeStruct {
+        fn clone(&self) -> SomeStruct {
+            SomeStruct
+        }
+    }
+
+    Bounded(SomeStruct)
+}
+
+// @has traits_in_bodies/struct.Point.html
+// @has - '//code' 'impl Copy for Point'
+#[derive(Clone)]
+pub struct Point {
+    x: i32,
+    y: i32,
+}
+
+const _FOO: () = {
+    impl Copy for Point {}
+    ()
+};
+
+// @has traits_in_bodies/struct.Inception.html
+// @has - '//code' 'impl Clone for Inception'
+pub struct Inception;
+
+static _BAR: usize = {
+    trait HiddenTrait {
+        fn hidden_fn(&self) {
+            for _ in 0..5 {
+                impl Clone for Inception {
+                    fn clone(&self) -> Self {
+                        // we need to go deeper
+                        Inception
+                    }
+                }
+            }
+        }
+    }
+
+    5
+};
diff --git a/src/test/rustdoc/tuples.rs b/src/test/rustdoc/tuples.rs
new file mode 100644
index 0000000..53654ab
--- /dev/null
+++ b/src/test/rustdoc/tuples.rs
@@ -0,0 +1,8 @@
+#![crate_name = "foo"]
+
+// @has foo/fn.tuple0.html //pre 'pub fn tuple0(x: ())'
+pub fn tuple0(x: ()) -> () { x }
+// @has foo/fn.tuple1.html //pre 'pub fn tuple1(x: (i32,)) -> (i32,)'
+pub fn tuple1(x: (i32,)) -> (i32,) { x }
+// @has foo/fn.tuple2.html //pre 'pub fn tuple2(x: (i32, i32)) -> (i32, i32)'
+pub fn tuple2(x: (i32, i32)) -> (i32, i32) { x }
diff --git a/src/test/rustdoc/typedef.rs b/src/test/rustdoc/typedef.rs
new file mode 100644
index 0000000..80351ff
--- /dev/null
+++ b/src/test/rustdoc/typedef.rs
@@ -0,0 +1,25 @@
+pub trait MyTrait {
+    fn method_on_mytrait() {}
+}
+
+pub struct MyStruct;
+
+impl MyStruct {
+    pub fn method_on_mystruct() {}
+}
+
+// @has typedef/type.MyAlias.html
+// @has - '//*[@class="impl"]//code' 'impl MyAlias'
+// @has - '//*[@class="impl"]//code' 'impl MyTrait for MyAlias'
+// @has - 'Alias docstring'
+// @has - '//*[@class="sidebar"]//p[@class="location"]' 'Type Definition MyAlias'
+// @has - '//*[@class="sidebar"]//a[@href="#methods"]' 'Methods'
+// @has - '//*[@class="sidebar"]//a[@href="#implementations"]' 'Trait Implementations'
+/// Alias docstring
+pub type MyAlias = MyStruct;
+
+impl MyAlias {
+    pub fn method_on_myalias() {}
+}
+
+impl MyTrait for MyAlias {}
diff --git a/src/test/rustdoc/union.rs b/src/test/rustdoc/union.rs
new file mode 100644
index 0000000..8918622
--- /dev/null
+++ b/src/test/rustdoc/union.rs
@@ -0,0 +1,8 @@
+// @has union/union.U.html
+pub union U {
+    // @has - //pre "pub a: u8"
+    pub a: u8,
+    // @has - //pre "// some fields omitted"
+    // @!has - //pre "b: u16"
+    b: u16,
+}
diff --git a/src/test/rustdoc/unit-return.rs b/src/test/rustdoc/unit-return.rs
new file mode 100644
index 0000000..ae3a603
--- /dev/null
+++ b/src/test/rustdoc/unit-return.rs
@@ -0,0 +1,17 @@
+// aux-build:unit-return.rs
+
+#![crate_name = "foo"]
+
+extern crate unit_return;
+
+// @has 'foo/fn.f0.html' '//*[@class="rust fn"]' 'F: FnMut(u8) + Clone'
+pub fn f0<F: FnMut(u8) + Clone>(f: F) {}
+
+// @has 'foo/fn.f1.html' '//*[@class="rust fn"]' 'F: FnMut(u16) + Clone'
+pub fn f1<F: FnMut(u16) -> () + Clone>(f: F) {}
+
+// @has 'foo/fn.f2.html' '//*[@class="rust fn"]' 'F: FnMut(u32) + Clone'
+pub use unit_return::f2;
+
+// @has 'foo/fn.f3.html' '//*[@class="rust fn"]' 'F: FnMut(u64) + Clone'
+pub use unit_return::f3;
diff --git a/src/test/rustdoc/universal-impl-trait.rs b/src/test/rustdoc/universal-impl-trait.rs
new file mode 100644
index 0000000..b10b1b8
--- /dev/null
+++ b/src/test/rustdoc/universal-impl-trait.rs
@@ -0,0 +1,55 @@
+#![crate_name = "foo"]
+
+use std::io::Read;
+use std::borrow::Borrow;
+
+// @has foo/fn.foo.html
+// @has - //pre 'foo('
+// @matches - '_x: impl <a class="trait" href="[^"]+/trait\.Clone\.html"'
+// @matches - '_z: .+impl.+trait\.Copy\.html.+, impl.+trait\.Clone\.html'
+pub fn foo(_x: impl Clone, _y: i32, _z: (impl Copy, impl Clone)) {
+}
+
+pub trait Trait {
+    // @has foo/trait.Trait.html
+    // @has - 'method</a>('
+    // @matches - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"'
+    fn method(&self, _x: impl std::fmt::Debug) {
+    }
+}
+
+pub struct S<T>(T);
+
+impl<T> S<T> {
+    // @has foo/struct.S.html
+    // @has - 'bar</a>('
+    // @matches - '_bar: impl <a class="trait" href="[^"]+/trait\.Copy\.html"'
+    pub fn bar(_bar: impl Copy) {
+    }
+
+    // @has - 'baz</a>('
+    // @matches - '_baz:.+struct\.S\.html.+impl .+trait\.Clone\.html'
+    pub fn baz(_baz: S<impl Clone>) {
+    }
+
+    // @has - 'qux</a>('
+    // @matches - 'trait\.Read\.html'
+    pub fn qux(_qux: impl IntoIterator<Item = S<impl Read>>) {
+    }
+}
+
+// @has - 'method</a>('
+// @matches - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"'
+impl<T> Trait for S<T> {}
+
+// @has foo/fn.much_universe.html
+// @matches - 'T:.+Borrow.+impl .+trait\.Trait\.html'
+// @matches - 'U:.+IntoIterator.+= impl.+Iterator\.html.+= impl.+Clone\.html'
+// @matches - '_: impl .+trait\.Read\.html.+ \+ .+trait\.Clone\.html'
+pub fn much_universe<
+    T: Borrow<impl Trait>,
+    U: IntoIterator<Item = impl Iterator<Item = impl Clone>>,
+>(
+    _: impl Read + Clone,
+) {
+}
diff --git a/src/test/rustdoc/unneeded-trait-implementations-title.rs b/src/test/rustdoc/unneeded-trait-implementations-title.rs
new file mode 100644
index 0000000..e1bcfd3
--- /dev/null
+++ b/src/test/rustdoc/unneeded-trait-implementations-title.rs
@@ -0,0 +1,5 @@
+#![crate_name = "foo"]
+
+pub struct Bar;
+
+// @count foo/struct.Bar.html '//*[@id="implementations"]' 0
diff --git a/src/test/rustdoc/use-attr.rs b/src/test/rustdoc/use-attr.rs
new file mode 100644
index 0000000..996b7bb
--- /dev/null
+++ b/src/test/rustdoc/use-attr.rs
@@ -0,0 +1,8 @@
+// edition:2018
+
+// ICE when rustdoc encountered a use statement of a non-macro attribute (see #58054)
+
+// @has use_attr/index.html
+// @has - '//code' 'pub use proc_macro_attribute'
+pub use proc_macro_attribute;
+use proc_macro_derive;
diff --git a/src/test/rustdoc/useless_lifetime_bound.rs b/src/test/rustdoc/useless_lifetime_bound.rs
new file mode 100644
index 0000000..f530d8a
--- /dev/null
+++ b/src/test/rustdoc/useless_lifetime_bound.rs
@@ -0,0 +1,13 @@
+use std::marker::PhantomData;
+
+// @has useless_lifetime_bound/struct.Scope.html
+// @!has - '//*[@class="rust struct"]' "'env: 'env"
+pub struct Scope<'env> {
+    _marker: PhantomData<&'env mut &'env ()>,
+}
+
+// @has useless_lifetime_bound/struct.Scope.html
+// @!has - '//*[@class="rust struct"]' "T: 'a + 'a"
+pub struct SomeStruct<'a, T: 'a> {
+    _marker: PhantomData<&'a T>,
+}
diff --git a/src/test/rustdoc/variadic.rs b/src/test/rustdoc/variadic.rs
new file mode 100644
index 0000000..5af2aea
--- /dev/null
+++ b/src/test/rustdoc/variadic.rs
@@ -0,0 +1,4 @@
+extern "C" {
+    // @has variadic/fn.foo.html //pre 'pub unsafe extern "C" fn foo(x: i32, _: ...)'
+    pub fn foo(x: i32, ...);
+}
diff --git a/src/test/rustdoc/viewpath-rename.rs b/src/test/rustdoc/viewpath-rename.rs
new file mode 100644
index 0000000..5461276
--- /dev/null
+++ b/src/test/rustdoc/viewpath-rename.rs
@@ -0,0 +1,21 @@
+#![crate_name = "foo"]
+
+pub mod io {
+    pub trait Reader { fn dummy(&self) { } }
+}
+
+pub enum Maybe<A> {
+    Just(A),
+    Nothing
+}
+
+// @has foo/prelude/index.html
+pub mod prelude {
+    // @has foo/prelude/index.html '//code' 'pub use io as FooIo;'
+    // @has foo/prelude/index.html '//code' 'pub use io::Reader as FooReader;'
+    #[doc(no_inline)] pub use io::{self as FooIo, Reader as FooReader};
+    // @has foo/prelude/index.html '//code' 'pub use Maybe;'
+    // @has foo/prelude/index.html '//code' 'pub use Maybe::Just as MaybeJust;'
+    // @has foo/prelude/index.html '//code' 'pub use Maybe::Nothing;'
+    #[doc(no_inline)] pub use Maybe::{self, Just as MaybeJust, Nothing};
+}
diff --git a/src/test/rustdoc/viewpath-self.rs b/src/test/rustdoc/viewpath-self.rs
new file mode 100644
index 0000000..a6b6592
--- /dev/null
+++ b/src/test/rustdoc/viewpath-self.rs
@@ -0,0 +1,21 @@
+#![crate_name = "foo"]
+
+pub mod io {
+    pub trait Reader { fn dummy(&self) { } }
+}
+
+pub enum Maybe<A> {
+    Just(A),
+    Nothing
+}
+
+// @has foo/prelude/index.html
+pub mod prelude {
+    // @has foo/prelude/index.html '//code' 'pub use io;'
+    // @has foo/prelude/index.html '//code' 'pub use io::Reader;'
+    #[doc(no_inline)] pub use io::{self, Reader};
+    // @has foo/prelude/index.html '//code' 'pub use Maybe;'
+    // @has foo/prelude/index.html '//code' 'pub use Maybe::Just;'
+    // @has foo/prelude/index.html '//code' 'pub use Maybe::Nothing;'
+    #[doc(no_inline)] pub use Maybe::{self, Just, Nothing};
+}
diff --git a/src/test/rustdoc/where-sized.rs b/src/test/rustdoc/where-sized.rs
new file mode 100644
index 0000000..fe7cad8
--- /dev/null
+++ b/src/test/rustdoc/where-sized.rs
@@ -0,0 +1,6 @@
+#![crate_name = "foo"]
+
+// @has foo/fn.foo.html
+// @has - '//*[@class="rust fn"]' 'pub fn foo<X, Y: ?Sized>(_: &X)'
+// @has - '//*[@class="rust fn"]' 'where X: ?Sized,'
+pub fn foo<X, Y: ?Sized>(_: &X) where X: ?Sized {}
diff --git a/src/test/rustdoc/where.rs b/src/test/rustdoc/where.rs
new file mode 100644
index 0000000..992cddf
--- /dev/null
+++ b/src/test/rustdoc/where.rs
@@ -0,0 +1,38 @@
+#![crate_name = "foo"]
+
+pub trait MyTrait { fn dummy(&self) { } }
+
+// @has foo/struct.Alpha.html '//pre' "pub struct Alpha<A>(_) where A: MyTrait"
+pub struct Alpha<A>(A) where A: MyTrait;
+// @has foo/trait.Bravo.html '//pre' "pub trait Bravo<B> where B: MyTrait"
+pub trait Bravo<B> where B: MyTrait { fn get(&self, B: B); }
+// @has foo/fn.charlie.html '//pre' "pub fn charlie<C>() where C: MyTrait"
+pub fn charlie<C>() where C: MyTrait {}
+
+pub struct Delta<D>(D);
+
+// @has foo/struct.Delta.html '//*[@class="impl"]//code' \
+//          "impl<D> Delta<D> where D: MyTrait"
+impl<D> Delta<D> where D: MyTrait {
+    pub fn delta() {}
+}
+
+pub struct Echo<E>(E);
+
+// @has foo/struct.Echo.html '//*[@class="impl"]//code' \
+//          "impl<E> MyTrait for Echo<E> where E: MyTrait"
+// @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \
+//          "impl<E> MyTrait for Echo<E> where E: MyTrait"
+impl<E> MyTrait for Echo<E> where E: MyTrait {}
+
+pub enum Foxtrot<F> { Foxtrot1(F) }
+
+// @has foo/enum.Foxtrot.html '//*[@class="impl"]//code' \
+//          "impl<F> MyTrait for Foxtrot<F> where F: MyTrait"
+// @has foo/trait.MyTrait.html '//*[@id="implementors-list"]//code' \
+//          "impl<F> MyTrait for Foxtrot<F> where F: MyTrait"
+impl<F> MyTrait for Foxtrot<F> where F: MyTrait {}
+
+// @has foo/type.Golf.html '//pre[@class="rust typedef"]' \
+//          "type Golf<T> where T: Clone, = (T, T)"
+pub type Golf<T> where T: Clone = (T, T);
diff --git a/src/test/rustdoc/without-redirect.rs b/src/test/rustdoc/without-redirect.rs
new file mode 100644
index 0000000..a076f8a
--- /dev/null
+++ b/src/test/rustdoc/without-redirect.rs
@@ -0,0 +1,13 @@
+#![crate_name = "foo"]
+
+// @has foo/macro.bar.html
+// @has foo/macro.bar!.html
+// @!has foo/bar.m.html
+#[macro_export]
+macro_rules! bar {
+    () => {}
+}
+
+// @has foo/struct.Bar.html
+// @!has foo/Bar.t.html
+pub struct Bar;
diff --git a/src/test/rustdoc/wrapping.rs b/src/test/rustdoc/wrapping.rs
new file mode 100644
index 0000000..8d8221b
--- /dev/null
+++ b/src/test/rustdoc/wrapping.rs
@@ -0,0 +1,5 @@
+use std::fmt::Debug;
+
+// @has 'wrapping/fn.foo.html' '//pre[@class="rust fn"]' 'pub fn foo() -> impl Debug'
+// @count - '//pre[@class="rust fn"]/br' 0
+pub fn foo() -> impl Debug {}