diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt
index 4516bf86e2b..4fbfa442fcc 100644
--- a/src/tools/tidy/src/allowed_run_make_makefiles.txt
+++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt
@@ -63,7 +63,6 @@ run-make/issue-33329/Makefile
 run-make/issue-35164/Makefile
 run-make/issue-36710/Makefile
 run-make/issue-37839/Makefile
-run-make/issue-40535/Makefile
 run-make/issue-47551/Makefile
 run-make/issue-69368/Makefile
 run-make/issue-83045/Makefile
diff --git a/tests/run-make/issue-40535/Makefile b/tests/run-make/issue-40535/Makefile
deleted file mode 100644
index 155c8825214..00000000000
--- a/tests/run-make/issue-40535/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-include ../tools.mk
-
-# The ICE occurred in the following situation:
-# * `foo` declares `extern crate bar, baz`, depends only on `bar` (forgetting `baz` in `Cargo.toml`)
-# * `bar` declares and depends on `extern crate baz`
-# * All crates built in metadata-only mode (`cargo check`)
-all:
-	# cc https://github.com/rust-lang/rust/issues/40623
-	$(RUSTC) baz.rs --emit=metadata
-	$(RUSTC) bar.rs --emit=metadata --extern baz=$(TMPDIR)/libbaz.rmeta
-	$(RUSTC) foo.rs --emit=metadata --extern bar=$(TMPDIR)/libbar.rmeta 2>&1 | \
-		$(CGREP) -v "unexpectedly panicked"
-	# ^ Succeeds if it doesn't find the ICE message
diff --git a/tests/run-make/issue-40535/bar.rs b/tests/run-make/metadata-only-crate-no-ice/bar.rs
similarity index 100%
rename from tests/run-make/issue-40535/bar.rs
rename to tests/run-make/metadata-only-crate-no-ice/bar.rs
diff --git a/tests/run-make/issue-40535/baz.rs b/tests/run-make/metadata-only-crate-no-ice/baz.rs
similarity index 100%
rename from tests/run-make/issue-40535/baz.rs
rename to tests/run-make/metadata-only-crate-no-ice/baz.rs
diff --git a/tests/run-make/issue-40535/foo.rs b/tests/run-make/metadata-only-crate-no-ice/foo.rs
similarity index 100%
rename from tests/run-make/issue-40535/foo.rs
rename to tests/run-make/metadata-only-crate-no-ice/foo.rs
diff --git a/tests/run-make/metadata-only-crate-no-ice/rmake.rs b/tests/run-make/metadata-only-crate-no-ice/rmake.rs
new file mode 100644
index 00000000000..825da12cfd1
--- /dev/null
+++ b/tests/run-make/metadata-only-crate-no-ice/rmake.rs
@@ -0,0 +1,14 @@
+// In a dependency hierarchy, metadata-only crates could cause an Internal
+// Compiler Error (ICE) due to a compiler bug - not correctly fetching sources for
+// metadata-only crates. This test is a minimal reproduction of a program that triggered
+// this bug, and checks that no ICE occurs.
+// See https://github.com/rust-lang/rust/issues/40535
+
+use run_make_support::rustc;
+
+fn main() {
+    rustc().input("baz.rs").emit("metadata").run();
+    rustc().input("bar.rs").emit("metadata").extern_("baz", "libbaz.rmeta").run();
+    // There should be no internal compiler error message.
+    rustc().input("foo.rs").emit("metadata").extern_("bar", "libbaz.rmeta").run().assert_stderr_not_contains("unexpectedly panicked");
+}