diff --git a/tests/rustdoc/issue-21092.rs b/tests/rustdoc/issue-21092.rs
index b054145a4831a..214be755e94f5 100644
--- a/tests/rustdoc/issue-21092.rs
+++ b/tests/rustdoc/issue-21092.rs
@@ -1,6 +1,8 @@
// aux-build:issue-21092.rs
// ignore-cross-compile
+#![crate_name="issue_21092"]
+
extern crate issue_21092;
// @has issue_21092/struct.Bar.html
diff --git a/tests/rustdoc/issue-21474.rs b/tests/rustdoc/issue-21474.rs
index 5de26abace6fa..bedf89236aae2 100644
--- a/tests/rustdoc/issue-21474.rs
+++ b/tests/rustdoc/issue-21474.rs
@@ -1,3 +1,5 @@
+#![crate_name="issue_21474"]
+
pub use inner::*;
mod inner {
diff --git a/tests/rustdoc/issue-21801.rs b/tests/rustdoc/issue-21801.rs
index 29d2ec64c206d..131bf38c3cb75 100644
--- a/tests/rustdoc/issue-21801.rs
+++ b/tests/rustdoc/issue-21801.rs
@@ -1,6 +1,8 @@
// aux-build:issue-21801.rs
// ignore-cross-compile
+#![crate_name="issue_21801"]
+
extern crate issue_21801;
// @has issue_21801/struct.Foo.html
diff --git a/tests/rustdoc/issue-22025.rs b/tests/rustdoc/issue-22025.rs
index a721a15f463b4..d01c1f5c427b9 100644
--- a/tests/rustdoc/issue-22025.rs
+++ b/tests/rustdoc/issue-22025.rs
@@ -1,6 +1,8 @@
// aux-build:issue-22025.rs
// ignore-cross-compile
+#![crate_name="issue_22025"]
+
extern crate issue_22025;
pub use issue_22025::foo::{Foo, Bar};
diff --git a/tests/rustdoc/issue-22038.rs b/tests/rustdoc/issue-22038.rs
index de6cc78707c6d..52c9280f82676 100644
--- a/tests/rustdoc/issue-22038.rs
+++ b/tests/rustdoc/issue-22038.rs
@@ -1,3 +1,5 @@
+#![crate_name="issue_22038"]
+
extern "C" {
// @has issue_22038/fn.foo1.html \
// '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn foo1()'
diff --git a/tests/rustdoc/issue-23106.rs b/tests/rustdoc/issue-23106.rs
index 8cda2fc33805d..27c0bd0913045 100644
--- a/tests/rustdoc/issue-23106.rs
+++ b/tests/rustdoc/issue-23106.rs
@@ -1,5 +1,7 @@
// compile-flags:--test
+#![crate_name="issue_23106"]
+
/// ```
/// #
/// ```
diff --git a/tests/rustdoc/issue-23207.rs b/tests/rustdoc/issue-23207.rs
index 1a4b849ee8209..24cba4ad2942b 100644
--- a/tests/rustdoc/issue-23207.rs
+++ b/tests/rustdoc/issue-23207.rs
@@ -2,6 +2,8 @@
// aux-build:issue-23207-2.rs
// ignore-cross-compile
+#![crate_name="issue_23207"]
+
extern crate issue_23207_2;
// @has issue_23207/fmt/index.html
diff --git a/tests/rustdoc/issue-23511.rs b/tests/rustdoc/issue-23511.rs
index 21d02842431d0..d6b931850e2b5 100644
--- a/tests/rustdoc/issue-23511.rs
+++ b/tests/rustdoc/issue-23511.rs
@@ -2,6 +2,8 @@
#![feature(rustdoc_internals)]
#![no_std]
+#![crate_name="issue_23511"]
+
pub mod str {
#![rustc_doc_primitive = "str"]
diff --git a/tests/rustdoc/issue-23744.rs b/tests/rustdoc/issue-23744.rs
index 642817396b2a0..45cc1bf3f4142 100644
--- a/tests/rustdoc/issue-23744.rs
+++ b/tests/rustdoc/issue-23744.rs
@@ -1,5 +1,7 @@
// compile-flags:--test
+#![crate_name="issue_23744"]
+
/// Example of rustdoc incorrectly parsing ```rust,should_panic
.
///
/// ```should_panic
diff --git a/tests/rustdoc/issue-23812.rs b/tests/rustdoc/issue-23812.rs
index 08fd1833bcef3..43b422fc9928e 100644
--- a/tests/rustdoc/issue-23812.rs
+++ b/tests/rustdoc/issue-23812.rs
@@ -1,3 +1,5 @@
+#![crate_name="issue_23812"]
+
macro_rules! doc {
(#[$outer:meta] mod $i:ident { #![$inner:meta] }) =>
(
diff --git a/tests/rustdoc/issue-25001.rs b/tests/rustdoc/issue-25001.rs
index 268fae59496ac..d20268f176cec 100644
--- a/tests/rustdoc/issue-25001.rs
+++ b/tests/rustdoc/issue-25001.rs
@@ -1,3 +1,5 @@
+#![crate_name="issue_25001"]
+
// @has issue_25001/struct.Foo.html
pub struct Foo(T);
diff --git a/tests/rustdoc/issue-25944.rs b/tests/rustdoc/issue-25944.rs
index 49625294bbea0..17f3431593024 100644
--- a/tests/rustdoc/issue-25944.rs
+++ b/tests/rustdoc/issue-25944.rs
@@ -1,5 +1,7 @@
// compile-flags:--test
+#![crate_name="issue_25944"]
+
/// ```
/// let a = r#"
/// foo
diff --git a/tests/rustdoc/issue-26606.rs b/tests/rustdoc/issue-26606.rs
index d5cb2c710cde8..1b62b32a4a705 100644
--- a/tests/rustdoc/issue-26606.rs
+++ b/tests/rustdoc/issue-26606.rs
@@ -2,10 +2,12 @@
// ignore-cross-compile
// build-aux-docs
+#![crate_name="issue_26606"]
+
// @has issue_26606_macro/macro.make_item.html
#[macro_use]
extern crate issue_26606_macro;
// @has issue_26606/constant.FOO.html
-// @has - '//a[@href="../src/issue_26606/issue-26606.rs.html#11"]' 'source'
+// @has - '//a[@href="../src/issue_26606/issue-26606.rs.html#13"]' 'source'
make_item!(FOO);
diff --git a/tests/rustdoc/issue-26995.rs b/tests/rustdoc/issue-26995.rs
index fedc9f5174920..e2cad215d6775 100644
--- a/tests/rustdoc/issue-26995.rs
+++ b/tests/rustdoc/issue-26995.rs
@@ -1,6 +1,8 @@
// ignore-windows
// compile-flags: --no-defaults
+#![crate_name="issue_26995"]
+
// @has src/issue_26995/dev/null.html
// @has issue_26995/null/index.html '//a/@href' '../../src/issue_26995/dev/null.html'
#[path="/dev/null"]
diff --git a/tests/rustdoc/issue-27104.rs b/tests/rustdoc/issue-27104.rs
index 9f2fd9071144f..220df629686ef 100644
--- a/tests/rustdoc/issue-27104.rs
+++ b/tests/rustdoc/issue-27104.rs
@@ -2,6 +2,8 @@
// aux-build:empty.rs
// ignore-cross-compile
+#![crate_name="issue_27104"]
+
// @has issue_27104/index.html
// @!hasraw - 'extern crate std'
// @!hasraw - 'use std::prelude::'
diff --git a/tests/rustdoc/issue-27362.rs b/tests/rustdoc/issue-27362.rs
index 097e4e3b03d9d..d2e8879dd25f5 100644
--- a/tests/rustdoc/issue-27362.rs
+++ b/tests/rustdoc/issue-27362.rs
@@ -1,6 +1,8 @@
// aux-build:issue-27362-aux.rs
// ignore-cross-compile
+#![crate_name="issue_27362"]
+
extern crate issue_27362_aux;
pub use issue_27362_aux::*;
diff --git a/tests/rustdoc/issue-27759.rs b/tests/rustdoc/issue-27759.rs
index 65e0f7cb87b0c..28ea515d81f44 100644
--- a/tests/rustdoc/issue-27759.rs
+++ b/tests/rustdoc/issue-27759.rs
@@ -1,3 +1,5 @@
+#![crate_name="issue_27759"]
+
#![feature(staged_api)]
#![doc(issue_tracker_base_url = "http://issue_url/")]
diff --git a/tests/rustdoc/issue-27862.rs b/tests/rustdoc/issue-27862.rs
index 77522f1be2307..19adcb9450802 100644
--- a/tests/rustdoc/issue-27862.rs
+++ b/tests/rustdoc/issue-27862.rs
@@ -1,3 +1,5 @@
+#![crate_name="issue_27862"]
+
/// Tests | Table
/// ------|-------------
/// t = b | id = \|x\| x
diff --git a/tests/rustdoc/issue-28478.rs b/tests/rustdoc/issue-28478.rs
index 497276e6826a1..60ba9090f71db 100644
--- a/tests/rustdoc/issue-28478.rs
+++ b/tests/rustdoc/issue-28478.rs
@@ -1,3 +1,5 @@
+#![crate_name="issue_28478"]
+
#![feature(associated_type_defaults)]
// @has issue_28478/trait.Bar.html
diff --git a/tests/rustdoc/issue-28927.rs b/tests/rustdoc/issue-28927.rs
index 38a520850b6dd..ca07add2ba8da 100644
--- a/tests/rustdoc/issue-28927.rs
+++ b/tests/rustdoc/issue-28927.rs
@@ -2,5 +2,7 @@
// aux-build:issue-28927-1.rs
// ignore-cross-compile
+#![crate_name="issue_28927"]
+
pub extern crate issue_28927_1 as inner1;
pub use inner1 as foo;