From 03e8c95809b329e775a8e8f0f4459d6b1404abb3 Mon Sep 17 00:00:00 2001
From: Ralf Jung <post@ralfj.de>
Date: Wed, 11 Sep 2024 22:17:03 +0200
Subject: [PATCH 1/6] make basic allocation functions track_caller in Miri for
 nicer backtraces

---
 library/alloc/src/alloc.rs                        | 13 +++++++++++++
 library/alloc/src/boxed.rs                        |  1 +
 .../tests/fail/alloc/deallocate-bad-alignment.rs  |  4 +---
 .../fail/alloc/deallocate-bad-alignment.stderr    | 13 ++++---------
 .../miri/tests/fail/alloc/deallocate-bad-size.rs  |  4 +---
 .../tests/fail/alloc/deallocate-bad-size.stderr   | 13 ++++---------
 .../miri/tests/fail/alloc/deallocate-twice.rs     |  4 +---
 .../miri/tests/fail/alloc/deallocate-twice.stderr | 13 ++++---------
 .../miri/tests/fail/alloc/reallocate-bad-size.rs  |  4 +---
 .../tests/fail/alloc/reallocate-bad-size.stderr   | 13 ++++---------
 .../miri/tests/fail/alloc/reallocate-dangling.rs  |  4 +---
 .../tests/fail/alloc/reallocate-dangling.stderr   | 13 ++++---------
 src/tools/miri/tests/fail/alloc/stack_free.stderr |  8 +++-----
 .../newtype_pair_retagging.tree.stderr            |  8 +++-----
 .../both_borrows/newtype_retagging.tree.stderr    |  8 +++-----
 .../fail/both_borrows/zero-sized-protected.rs     |  3 +--
 .../both_borrows/zero-sized-protected.tree.stderr | 13 ++++---------
 src/tools/miri/tests/fail/memleak.rs              |  3 +--
 src/tools/miri/tests/fail/memleak.stderr          | 15 +++------------
 src/tools/miri/tests/fail/memleak_rc.stderr       | 11 +++--------
 .../deallocate_against_protector1.stderr          |  8 +++-----
 .../fail/stacked_borrows/illegal_dealloc1.rs      |  2 +-
 .../fail/stacked_borrows/illegal_dealloc1.stderr  | 13 ++++---------
 src/tools/miri/tests/fail/tls_macro_leak.rs       |  3 +--
 src/tools/miri/tests/fail/tls_macro_leak.stderr   | 15 +++------------
 src/tools/miri/tests/fail/tls_static_leak.rs      |  3 +--
 src/tools/miri/tests/fail/tls_static_leak.stderr  | 15 +++------------
 .../fail/tree_borrows/strongly-protected.stderr   |  8 +++-----
 28 files changed, 79 insertions(+), 156 deletions(-)

diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs
index cddf4f6f39963..de58b06545b07 100644
--- a/library/alloc/src/alloc.rs
+++ b/library/alloc/src/alloc.rs
@@ -89,6 +89,7 @@ pub use std::alloc::Global;
 #[stable(feature = "global_alloc", since = "1.28.0")]
 #[must_use = "losing the pointer will leak memory"]
 #[inline]
+#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
 pub unsafe fn alloc(layout: Layout) -> *mut u8 {
     unsafe {
         // Make sure we don't accidentally allow omitting the allocator shim in
@@ -113,6 +114,7 @@ pub unsafe fn alloc(layout: Layout) -> *mut u8 {
 /// See [`GlobalAlloc::dealloc`].
 #[stable(feature = "global_alloc", since = "1.28.0")]
 #[inline]
+#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
 pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) {
     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
 }
@@ -132,6 +134,7 @@ pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) {
 #[stable(feature = "global_alloc", since = "1.28.0")]
 #[must_use = "losing the pointer will leak memory"]
 #[inline]
+#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
 pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
     unsafe { __rust_realloc(ptr, layout.size(), layout.align(), new_size) }
 }
@@ -166,6 +169,7 @@ pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8
 #[stable(feature = "global_alloc", since = "1.28.0")]
 #[must_use = "losing the pointer will leak memory"]
 #[inline]
+#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
 pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 {
     unsafe { __rust_alloc_zeroed(layout.size(), layout.align()) }
 }
@@ -173,6 +177,7 @@ pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 {
 #[cfg(not(test))]
 impl Global {
     #[inline]
+    #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
     fn alloc_impl(&self, layout: Layout, zeroed: bool) -> Result<NonNull<[u8]>, AllocError> {
         match layout.size() {
             0 => Ok(NonNull::slice_from_raw_parts(layout.dangling(), 0)),
@@ -187,6 +192,7 @@ impl Global {
 
     // SAFETY: Same as `Allocator::grow`
     #[inline]
+    #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
     unsafe fn grow_impl(
         &self,
         ptr: NonNull<u8>,
@@ -237,16 +243,19 @@ impl Global {
 #[cfg(not(test))]
 unsafe impl Allocator for Global {
     #[inline]
+    #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
     fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
         self.alloc_impl(layout, false)
     }
 
     #[inline]
+    #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
     fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
         self.alloc_impl(layout, true)
     }
 
     #[inline]
+    #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
     unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
         if layout.size() != 0 {
             // SAFETY: `layout` is non-zero in size,
@@ -256,6 +265,7 @@ unsafe impl Allocator for Global {
     }
 
     #[inline]
+    #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
     unsafe fn grow(
         &self,
         ptr: NonNull<u8>,
@@ -267,6 +277,7 @@ unsafe impl Allocator for Global {
     }
 
     #[inline]
+    #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
     unsafe fn grow_zeroed(
         &self,
         ptr: NonNull<u8>,
@@ -278,6 +289,7 @@ unsafe impl Allocator for Global {
     }
 
     #[inline]
+    #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
     unsafe fn shrink(
         &self,
         ptr: NonNull<u8>,
@@ -325,6 +337,7 @@ unsafe impl Allocator for Global {
 #[cfg(all(not(no_global_oom_handling), not(test)))]
 #[lang = "exchange_malloc"]
 #[inline]
+#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
 unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
     let layout = unsafe { Layout::from_size_align_unchecked(size, align) };
     match Global.allocate(layout) {
diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs
index 6dc75478700ce..4b1d493113c68 100644
--- a/library/alloc/src/boxed.rs
+++ b/library/alloc/src/boxed.rs
@@ -250,6 +250,7 @@ impl<T> Box<T> {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[must_use]
     #[rustc_diagnostic_item = "box_new"]
+    #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
     pub fn new(x: T) -> Self {
         #[rustc_box]
         Box::new(x)
diff --git a/src/tools/miri/tests/fail/alloc/deallocate-bad-alignment.rs b/src/tools/miri/tests/fail/alloc/deallocate-bad-alignment.rs
index e8ba824db717c..552a67419b247 100644
--- a/src/tools/miri/tests/fail/alloc/deallocate-bad-alignment.rs
+++ b/src/tools/miri/tests/fail/alloc/deallocate-bad-alignment.rs
@@ -1,10 +1,8 @@
 use std::alloc::{alloc, dealloc, Layout};
 
-//@error-in-other-file: has size 1 and alignment 1, but gave size 1 and alignment 2
-
 fn main() {
     unsafe {
         let x = alloc(Layout::from_size_align_unchecked(1, 1));
-        dealloc(x, Layout::from_size_align_unchecked(1, 2));
+        dealloc(x, Layout::from_size_align_unchecked(1, 2)); //~ERROR: has size 1 and alignment 1, but gave size 1 and alignment 2
     }
 }
diff --git a/src/tools/miri/tests/fail/alloc/deallocate-bad-alignment.stderr b/src/tools/miri/tests/fail/alloc/deallocate-bad-alignment.stderr
index 40ed093198d30..d340413d231b6 100644
--- a/src/tools/miri/tests/fail/alloc/deallocate-bad-alignment.stderr
+++ b/src/tools/miri/tests/fail/alloc/deallocate-bad-alignment.stderr
@@ -1,18 +1,13 @@
 error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 1 and alignment ALIGN
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+  --> $DIR/deallocate-bad-alignment.rs:LL:CC
    |
-LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 1 and alignment ALIGN
+LL |         dealloc(x, Layout::from_size_align_unchecked(1, 2));
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 1 and alignment ALIGN
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
    = note: BACKTRACE:
-   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-note: inside `main`
-  --> $DIR/deallocate-bad-alignment.rs:LL:CC
-   |
-LL |         dealloc(x, Layout::from_size_align_unchecked(1, 2));
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: inside `main` at $DIR/deallocate-bad-alignment.rs:LL:CC
 
 note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
 
diff --git a/src/tools/miri/tests/fail/alloc/deallocate-bad-size.rs b/src/tools/miri/tests/fail/alloc/deallocate-bad-size.rs
index e3f9a20ac3bcb..906a3b52a2232 100644
--- a/src/tools/miri/tests/fail/alloc/deallocate-bad-size.rs
+++ b/src/tools/miri/tests/fail/alloc/deallocate-bad-size.rs
@@ -1,10 +1,8 @@
 use std::alloc::{alloc, dealloc, Layout};
 
-//@error-in-other-file: has size 1 and alignment 1, but gave size 2 and alignment 1
-
 fn main() {
     unsafe {
         let x = alloc(Layout::from_size_align_unchecked(1, 1));
-        dealloc(x, Layout::from_size_align_unchecked(2, 1));
+        dealloc(x, Layout::from_size_align_unchecked(2, 1)); //~ERROR: has size 1 and alignment 1, but gave size 2 and alignment 1
     }
 }
diff --git a/src/tools/miri/tests/fail/alloc/deallocate-bad-size.stderr b/src/tools/miri/tests/fail/alloc/deallocate-bad-size.stderr
index e9b935d2c83b2..b661b49c9f343 100644
--- a/src/tools/miri/tests/fail/alloc/deallocate-bad-size.stderr
+++ b/src/tools/miri/tests/fail/alloc/deallocate-bad-size.stderr
@@ -1,18 +1,13 @@
 error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+  --> $DIR/deallocate-bad-size.rs:LL:CC
    |
-LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
+LL |         dealloc(x, Layout::from_size_align_unchecked(2, 1));
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
    = note: BACKTRACE:
-   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-note: inside `main`
-  --> $DIR/deallocate-bad-size.rs:LL:CC
-   |
-LL |         dealloc(x, Layout::from_size_align_unchecked(2, 1));
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: inside `main` at $DIR/deallocate-bad-size.rs:LL:CC
 
 note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
 
diff --git a/src/tools/miri/tests/fail/alloc/deallocate-twice.rs b/src/tools/miri/tests/fail/alloc/deallocate-twice.rs
index 7a3ff84b2cb13..ee514f4c55e15 100644
--- a/src/tools/miri/tests/fail/alloc/deallocate-twice.rs
+++ b/src/tools/miri/tests/fail/alloc/deallocate-twice.rs
@@ -1,11 +1,9 @@
 use std::alloc::{alloc, dealloc, Layout};
 
-//@error-in-other-file: has been freed
-
 fn main() {
     unsafe {
         let x = alloc(Layout::from_size_align_unchecked(1, 1));
         dealloc(x, Layout::from_size_align_unchecked(1, 1));
-        dealloc(x, Layout::from_size_align_unchecked(1, 1));
+        dealloc(x, Layout::from_size_align_unchecked(1, 1)); //~ERROR: has been freed
     }
 }
diff --git a/src/tools/miri/tests/fail/alloc/deallocate-twice.stderr b/src/tools/miri/tests/fail/alloc/deallocate-twice.stderr
index 76abd96e24afb..32cdfa0d228f3 100644
--- a/src/tools/miri/tests/fail/alloc/deallocate-twice.stderr
+++ b/src/tools/miri/tests/fail/alloc/deallocate-twice.stderr
@@ -1,8 +1,8 @@
 error: Undefined Behavior: memory access failed: ALLOC has been freed, so this pointer is dangling
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+  --> $DIR/deallocate-twice.rs:LL:CC
    |
-LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
+LL |         dealloc(x, Layout::from_size_align_unchecked(1, 1));
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
@@ -17,12 +17,7 @@ help: ALLOC was deallocated here:
 LL |         dealloc(x, Layout::from_size_align_unchecked(1, 1));
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: BACKTRACE (of the first span):
-   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-note: inside `main`
-  --> $DIR/deallocate-twice.rs:LL:CC
-   |
-LL |         dealloc(x, Layout::from_size_align_unchecked(1, 1));
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: inside `main` at $DIR/deallocate-twice.rs:LL:CC
 
 note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
 
diff --git a/src/tools/miri/tests/fail/alloc/reallocate-bad-size.rs b/src/tools/miri/tests/fail/alloc/reallocate-bad-size.rs
index 49b2c62d7e4f7..174e4f2276188 100644
--- a/src/tools/miri/tests/fail/alloc/reallocate-bad-size.rs
+++ b/src/tools/miri/tests/fail/alloc/reallocate-bad-size.rs
@@ -1,10 +1,8 @@
 use std::alloc::{alloc, realloc, Layout};
 
-//@error-in-other-file: has size 1 and alignment 1, but gave size 2 and alignment 1
-
 fn main() {
     unsafe {
         let x = alloc(Layout::from_size_align_unchecked(1, 1));
-        let _y = realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
+        let _y = realloc(x, Layout::from_size_align_unchecked(2, 1), 1); //~ERROR: has size 1 and alignment 1, but gave size 2 and alignment 1
     }
 }
diff --git a/src/tools/miri/tests/fail/alloc/reallocate-bad-size.stderr b/src/tools/miri/tests/fail/alloc/reallocate-bad-size.stderr
index 5347e7a95ac4d..965cbc4dd0358 100644
--- a/src/tools/miri/tests/fail/alloc/reallocate-bad-size.stderr
+++ b/src/tools/miri/tests/fail/alloc/reallocate-bad-size.stderr
@@ -1,18 +1,13 @@
 error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+  --> $DIR/reallocate-bad-size.rs:LL:CC
    |
-LL |     unsafe { __rust_realloc(ptr, layout.size(), layout.align(), new_size) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
+LL |         let _y = realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
    = note: BACKTRACE:
-   = note: inside `std::alloc::realloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-note: inside `main`
-  --> $DIR/reallocate-bad-size.rs:LL:CC
-   |
-LL |         let _y = realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
-   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: inside `main` at $DIR/reallocate-bad-size.rs:LL:CC
 
 note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
 
diff --git a/src/tools/miri/tests/fail/alloc/reallocate-dangling.rs b/src/tools/miri/tests/fail/alloc/reallocate-dangling.rs
index 622348ad190d1..c605f68a7f63d 100644
--- a/src/tools/miri/tests/fail/alloc/reallocate-dangling.rs
+++ b/src/tools/miri/tests/fail/alloc/reallocate-dangling.rs
@@ -1,11 +1,9 @@
 use std::alloc::{alloc, dealloc, realloc, Layout};
 
-//@error-in-other-file: has been freed
-
 fn main() {
     unsafe {
         let x = alloc(Layout::from_size_align_unchecked(1, 1));
         dealloc(x, Layout::from_size_align_unchecked(1, 1));
-        let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
+        let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1); //~ERROR: has been freed
     }
 }
diff --git a/src/tools/miri/tests/fail/alloc/reallocate-dangling.stderr b/src/tools/miri/tests/fail/alloc/reallocate-dangling.stderr
index 9b8a892620162..9a582b9b4cf1a 100644
--- a/src/tools/miri/tests/fail/alloc/reallocate-dangling.stderr
+++ b/src/tools/miri/tests/fail/alloc/reallocate-dangling.stderr
@@ -1,8 +1,8 @@
 error: Undefined Behavior: memory access failed: ALLOC has been freed, so this pointer is dangling
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+  --> $DIR/reallocate-dangling.rs:LL:CC
    |
-LL |     unsafe { __rust_realloc(ptr, layout.size(), layout.align(), new_size) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
+LL |         let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
+   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
@@ -17,12 +17,7 @@ help: ALLOC was deallocated here:
 LL |         dealloc(x, Layout::from_size_align_unchecked(1, 1));
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: BACKTRACE (of the first span):
-   = note: inside `std::alloc::realloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-note: inside `main`
-  --> $DIR/reallocate-dangling.rs:LL:CC
-   |
-LL |         let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
-   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: inside `main` at $DIR/reallocate-dangling.rs:LL:CC
 
 note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
 
diff --git a/src/tools/miri/tests/fail/alloc/stack_free.stderr b/src/tools/miri/tests/fail/alloc/stack_free.stderr
index 2adec68c0dd84..36e78c1b7fb5a 100644
--- a/src/tools/miri/tests/fail/alloc/stack_free.stderr
+++ b/src/tools/miri/tests/fail/alloc/stack_free.stderr
@@ -1,14 +1,12 @@
 error: Undefined Behavior: deallocating ALLOC, which is stack variable memory, using Rust heap deallocation operation
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+  --> RUSTLIB/alloc/src/boxed.rs:LL:CC
    |
-LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating ALLOC, which is stack variable memory, using Rust heap deallocation operation
+LL |                 self.1.deallocate(From::from(ptr.cast()), layout);
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating ALLOC, which is stack variable memory, using Rust heap deallocation operation
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
    = note: BACKTRACE:
-   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
    = note: inside `<std::boxed::Box<i32> as std::ops::Drop>::drop` at RUSTLIB/alloc/src/boxed.rs:LL:CC
    = note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
    = note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC
diff --git a/src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.tree.stderr b/src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.tree.stderr
index 0a54f14bb5e19..a344229eeb432 100644
--- a/src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.tree.stderr
+++ b/src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.tree.stderr
@@ -1,8 +1,8 @@
 error: Undefined Behavior: deallocation through <TAG> at ALLOC[0x0] is forbidden
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+  --> RUSTLIB/alloc/src/boxed.rs:LL:CC
    |
-LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden
+LL |                 self.1.deallocate(From::from(ptr.cast()), layout);
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
    = help: the accessed tag <TAG> is foreign to the protected tag <TAG> (i.e., it is not a child)
@@ -25,8 +25,6 @@ LL |             || drop(Box::from_raw(ptr)),
    |                     ^^^^^^^^^^^^^^^^^^
    = help: this transition corresponds to a temporary loss of write permissions until function exit
    = note: BACKTRACE (of the first span):
-   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
    = note: inside `<std::boxed::Box<i32> as std::ops::Drop>::drop` at RUSTLIB/alloc/src/boxed.rs:LL:CC
    = note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
    = note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC
diff --git a/src/tools/miri/tests/fail/both_borrows/newtype_retagging.tree.stderr b/src/tools/miri/tests/fail/both_borrows/newtype_retagging.tree.stderr
index 05f1d8822c81f..321ef39e62b0c 100644
--- a/src/tools/miri/tests/fail/both_borrows/newtype_retagging.tree.stderr
+++ b/src/tools/miri/tests/fail/both_borrows/newtype_retagging.tree.stderr
@@ -1,8 +1,8 @@
 error: Undefined Behavior: deallocation through <TAG> at ALLOC[0x0] is forbidden
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+  --> RUSTLIB/alloc/src/boxed.rs:LL:CC
    |
-LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden
+LL |                 self.1.deallocate(From::from(ptr.cast()), layout);
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
    = help: the accessed tag <TAG> is foreign to the protected tag <TAG> (i.e., it is not a child)
@@ -25,8 +25,6 @@ LL |             || drop(Box::from_raw(ptr)),
    |                     ^^^^^^^^^^^^^^^^^^
    = help: this transition corresponds to a temporary loss of write permissions until function exit
    = note: BACKTRACE (of the first span):
-   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
    = note: inside `<std::boxed::Box<i32> as std::ops::Drop>::drop` at RUSTLIB/alloc/src/boxed.rs:LL:CC
    = note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
    = note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC
diff --git a/src/tools/miri/tests/fail/both_borrows/zero-sized-protected.rs b/src/tools/miri/tests/fail/both_borrows/zero-sized-protected.rs
index aed5cb1125817..c8060d4c9cb76 100644
--- a/src/tools/miri/tests/fail/both_borrows/zero-sized-protected.rs
+++ b/src/tools/miri/tests/fail/both_borrows/zero-sized-protected.rs
@@ -1,13 +1,12 @@
 //@revisions: stack tree
 //@[tree]compile-flags: -Zmiri-tree-borrows
-//@[tree]error-in-other-file: /deallocation .* is forbidden/
 use std::alloc::{alloc, dealloc, Layout};
 
 // `x` is strongly protected but covers zero bytes.
 // Let's see if deallocating the allocation x points to is UB:
 // in TB, it is UB, but in SB it is not.
 fn test(_x: &mut (), ptr: *mut u8, l: Layout) {
-    unsafe { dealloc(ptr, l) };
+    unsafe { dealloc(ptr, l) }; //~[tree] ERROR: /deallocation .* is forbidden/
 }
 
 fn main() {
diff --git a/src/tools/miri/tests/fail/both_borrows/zero-sized-protected.tree.stderr b/src/tools/miri/tests/fail/both_borrows/zero-sized-protected.tree.stderr
index ef981038e5540..e798833058961 100644
--- a/src/tools/miri/tests/fail/both_borrows/zero-sized-protected.tree.stderr
+++ b/src/tools/miri/tests/fail/both_borrows/zero-sized-protected.tree.stderr
@@ -1,8 +1,8 @@
 error: Undefined Behavior: deallocation through <TAG> (root of the allocation) at ALLOC[0x0] is forbidden
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+  --> $DIR/zero-sized-protected.rs:LL:CC
    |
-LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> (root of the allocation) at ALLOC[0x0] is forbidden
+LL |     unsafe { dealloc(ptr, l) };
+   |              ^^^^^^^^^^^^^^^ deallocation through <TAG> (root of the allocation) at ALLOC[0x0] is forbidden
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
    = help: the allocation of the accessed tag <TAG> (root of the allocation) also contains the strongly protected tag <TAG>
@@ -18,12 +18,7 @@ help: the strongly protected tag <TAG> was created here, in the initial state Re
 LL | fn test(_x: &mut (), ptr: *mut u8, l: Layout) {
    |         ^^
    = note: BACKTRACE (of the first span):
-   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-note: inside `test`
-  --> $DIR/zero-sized-protected.rs:LL:CC
-   |
-LL |     unsafe { dealloc(ptr, l) };
-   |              ^^^^^^^^^^^^^^^
+   = note: inside `test` at $DIR/zero-sized-protected.rs:LL:CC
 note: inside `main`
   --> $DIR/zero-sized-protected.rs:LL:CC
    |
diff --git a/src/tools/miri/tests/fail/memleak.rs b/src/tools/miri/tests/fail/memleak.rs
index 984b44d6d4092..8ffa457be9220 100644
--- a/src/tools/miri/tests/fail/memleak.rs
+++ b/src/tools/miri/tests/fail/memleak.rs
@@ -1,6 +1,5 @@
-//@error-in-other-file: memory leaked
 //@normalize-stderr-test: ".*│.*" -> "$$stripped$$"
 
 fn main() {
-    std::mem::forget(Box::new(42));
+    std::mem::forget(Box::new(42)); //~ERROR: memory leaked
 }
diff --git a/src/tools/miri/tests/fail/memleak.stderr b/src/tools/miri/tests/fail/memleak.stderr
index a9ee76fbe8a78..d30322551660b 100644
--- a/src/tools/miri/tests/fail/memleak.stderr
+++ b/src/tools/miri/tests/fail/memleak.stderr
@@ -1,20 +1,11 @@
 error: memory leaked: ALLOC (Rust heap, size: 4, align: 4), allocated here:
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
-   |
-LL |         __rust_alloc(layout.size(), layout.align())
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: BACKTRACE:
-   = note: inside `std::alloc::alloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `std::alloc::Global::alloc_impl` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `<std::alloc::Global as std::alloc::Allocator>::allocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `alloc::alloc::exchange_malloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `std::boxed::Box::<i32>::new` at RUSTLIB/alloc/src/boxed.rs:LL:CC
-note: inside `main`
   --> $DIR/memleak.rs:LL:CC
    |
 LL |     std::mem::forget(Box::new(42));
    |                      ^^^^^^^^^^^^
+   |
+   = note: BACKTRACE:
+   = note: inside `main` at $DIR/memleak.rs:LL:CC
 
 note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
 
diff --git a/src/tools/miri/tests/fail/memleak_rc.stderr b/src/tools/miri/tests/fail/memleak_rc.stderr
index dbf2daf818c6f..91166384adcaa 100644
--- a/src/tools/miri/tests/fail/memleak_rc.stderr
+++ b/src/tools/miri/tests/fail/memleak_rc.stderr
@@ -1,15 +1,10 @@
 error: memory leaked: ALLOC (Rust heap, SIZE, ALIGN), allocated here:
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+  --> RUSTLIB/alloc/src/rc.rs:LL:CC
    |
-LL |         __rust_alloc(layout.size(), layout.align())
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |                 Box::leak(Box::new(RcBox { strong: Cell::new(1), weak: Cell::new(1), value }))
+   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: BACKTRACE:
-   = note: inside `std::alloc::alloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `std::alloc::Global::alloc_impl` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `<std::alloc::Global as std::alloc::Allocator>::allocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `alloc::alloc::exchange_malloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `std::boxed::Box::<std::rc::RcBox<std::cell::RefCell<std::option::Option<Dummy>>>>::new` at RUSTLIB/alloc/src/boxed.rs:LL:CC
    = note: inside `std::rc::Rc::<std::cell::RefCell<std::option::Option<Dummy>>>::new` at RUSTLIB/alloc/src/rc.rs:LL:CC
 note: inside `main`
   --> $DIR/memleak_rc.rs:LL:CC
diff --git a/src/tools/miri/tests/fail/stacked_borrows/deallocate_against_protector1.stderr b/src/tools/miri/tests/fail/stacked_borrows/deallocate_against_protector1.stderr
index 2a8d4f3aea0f8..31a6722ea0c2c 100644
--- a/src/tools/miri/tests/fail/stacked_borrows/deallocate_against_protector1.stderr
+++ b/src/tools/miri/tests/fail/stacked_borrows/deallocate_against_protector1.stderr
@@ -1,14 +1,12 @@
 error: Undefined Behavior: deallocating while item [Unique for <TAG>] is strongly protected
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+  --> RUSTLIB/alloc/src/boxed.rs:LL:CC
    |
-LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating while item [Unique for <TAG>] is strongly protected
+LL |                 self.1.deallocate(From::from(ptr.cast()), layout);
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating while item [Unique for <TAG>] is strongly protected
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
    = note: BACKTRACE:
-   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
    = note: inside `<std::boxed::Box<i32> as std::ops::Drop>::drop` at RUSTLIB/alloc/src/boxed.rs:LL:CC
    = note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
    = note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC
diff --git a/src/tools/miri/tests/fail/stacked_borrows/illegal_dealloc1.rs b/src/tools/miri/tests/fail/stacked_borrows/illegal_dealloc1.rs
index b2ec23bda02c5..76a5e6a0b6240 100644
--- a/src/tools/miri/tests/fail/stacked_borrows/illegal_dealloc1.rs
+++ b/src/tools/miri/tests/fail/stacked_borrows/illegal_dealloc1.rs
@@ -1,4 +1,3 @@
-//@error-in-other-file: /deallocation .* tag does not exist in the borrow stack/
 use std::alloc::{alloc, dealloc, Layout};
 
 fn main() {
@@ -10,5 +9,6 @@ fn main() {
         ptr1.write(0);
         // Deallocate through ptr2.
         dealloc(ptr2, Layout::from_size_align_unchecked(1, 1));
+        //~^ERROR: /deallocation .* tag does not exist in the borrow stack/
     }
 }
diff --git a/src/tools/miri/tests/fail/stacked_borrows/illegal_dealloc1.stderr b/src/tools/miri/tests/fail/stacked_borrows/illegal_dealloc1.stderr
index 7a44c8384a063..d06584d19d77b 100644
--- a/src/tools/miri/tests/fail/stacked_borrows/illegal_dealloc1.stderr
+++ b/src/tools/miri/tests/fail/stacked_borrows/illegal_dealloc1.stderr
@@ -1,8 +1,8 @@
 error: Undefined Behavior: attempting deallocation using <TAG> at ALLOC, but that tag does not exist in the borrow stack for this location
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+  --> $DIR/illegal_deALLOC.rs:LL:CC
    |
-LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempting deallocation using <TAG> at ALLOC, but that tag does not exist in the borrow stack for this location
+LL |         dealloc(ptr2, Layout::from_size_align_unchecked(1, 1));
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempting deallocation using <TAG> at ALLOC, but that tag does not exist in the borrow stack for this location
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
@@ -17,12 +17,7 @@ help: <TAG> was later invalidated at offsets [0x0..0x1] by a write access
 LL |         ptr1.write(0);
    |         ^^^^^^^^^^^^^
    = note: BACKTRACE (of the first span):
-   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-note: inside `main`
-  --> $DIR/illegal_deALLOC.rs:LL:CC
-   |
-LL |         dealloc(ptr2, Layout::from_size_align_unchecked(1, 1));
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: inside `main` at $DIR/illegal_deALLOC.rs:LL:CC
 
 note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
 
diff --git a/src/tools/miri/tests/fail/tls_macro_leak.rs b/src/tools/miri/tests/fail/tls_macro_leak.rs
index 996d7ed4a2360..b8a4b81911aca 100644
--- a/src/tools/miri/tests/fail/tls_macro_leak.rs
+++ b/src/tools/miri/tests/fail/tls_macro_leak.rs
@@ -1,4 +1,3 @@
-//@error-in-other-file: memory leaked
 //@normalize-stderr-test: ".*│.*" -> "$$stripped$$"
 
 use std::cell::Cell;
@@ -10,7 +9,7 @@ pub fn main() {
 
     std::thread::spawn(|| {
         TLS.with(|cell| {
-            cell.set(Some(Box::leak(Box::new(123))));
+            cell.set(Some(Box::leak(Box::new(123)))); //~ERROR: memory leaked
         });
     })
     .join()
diff --git a/src/tools/miri/tests/fail/tls_macro_leak.stderr b/src/tools/miri/tests/fail/tls_macro_leak.stderr
index c7c641a30f1bd..e485432815554 100644
--- a/src/tools/miri/tests/fail/tls_macro_leak.stderr
+++ b/src/tools/miri/tests/fail/tls_macro_leak.stderr
@@ -1,20 +1,11 @@
 error: memory leaked: ALLOC (Rust heap, size: 4, align: 4), allocated here:
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
-   |
-LL |         __rust_alloc(layout.size(), layout.align())
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: BACKTRACE:
-   = note: inside `std::alloc::alloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `std::alloc::Global::alloc_impl` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `<std::alloc::Global as std::alloc::Allocator>::allocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `alloc::alloc::exchange_malloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `std::boxed::Box::<i32>::new` at RUSTLIB/alloc/src/boxed.rs:LL:CC
-note: inside closure
   --> $DIR/tls_macro_leak.rs:LL:CC
    |
 LL |             cell.set(Some(Box::leak(Box::new(123))));
    |                                     ^^^^^^^^^^^^^
+   |
+   = note: BACKTRACE:
+   = note: inside closure at $DIR/tls_macro_leak.rs:LL:CC
    = note: inside `std::thread::LocalKey::<std::cell::Cell<std::option::Option<&i32>>>::try_with::<{closure@$DIR/tls_macro_leak.rs:LL:CC}, ()>` at RUSTLIB/std/src/thread/local.rs:LL:CC
    = note: inside `std::thread::LocalKey::<std::cell::Cell<std::option::Option<&i32>>>::with::<{closure@$DIR/tls_macro_leak.rs:LL:CC}, ()>` at RUSTLIB/std/src/thread/local.rs:LL:CC
 note: inside closure
diff --git a/src/tools/miri/tests/fail/tls_static_leak.rs b/src/tools/miri/tests/fail/tls_static_leak.rs
index 637d648fb3fbf..4d52803363778 100644
--- a/src/tools/miri/tests/fail/tls_static_leak.rs
+++ b/src/tools/miri/tests/fail/tls_static_leak.rs
@@ -1,4 +1,3 @@
-//@error-in-other-file: memory leaked
 //@normalize-stderr-test: ".*│.*" -> "$$stripped$$"
 
 #![feature(thread_local)]
@@ -12,7 +11,7 @@ pub fn main() {
     static TLS: Cell<Option<&'static i32>> = Cell::new(None);
 
     std::thread::spawn(|| {
-        TLS.set(Some(Box::leak(Box::new(123))));
+        TLS.set(Some(Box::leak(Box::new(123)))); //~ERROR: memory leaked
     })
     .join()
     .unwrap();
diff --git a/src/tools/miri/tests/fail/tls_static_leak.stderr b/src/tools/miri/tests/fail/tls_static_leak.stderr
index f7b90a1118c85..06d71fb456881 100644
--- a/src/tools/miri/tests/fail/tls_static_leak.stderr
+++ b/src/tools/miri/tests/fail/tls_static_leak.stderr
@@ -1,20 +1,11 @@
 error: memory leaked: ALLOC (Rust heap, size: 4, align: 4), allocated here:
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
-   |
-LL |         __rust_alloc(layout.size(), layout.align())
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: BACKTRACE:
-   = note: inside `std::alloc::alloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `std::alloc::Global::alloc_impl` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `<std::alloc::Global as std::alloc::Allocator>::allocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `alloc::alloc::exchange_malloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `std::boxed::Box::<i32>::new` at RUSTLIB/alloc/src/boxed.rs:LL:CC
-note: inside closure
   --> $DIR/tls_static_leak.rs:LL:CC
    |
 LL |         TLS.set(Some(Box::leak(Box::new(123))));
    |                                ^^^^^^^^^^^^^
+   |
+   = note: BACKTRACE:
+   = note: inside closure at $DIR/tls_static_leak.rs:LL:CC
 
 note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
 
diff --git a/src/tools/miri/tests/fail/tree_borrows/strongly-protected.stderr b/src/tools/miri/tests/fail/tree_borrows/strongly-protected.stderr
index 9da43055af240..2a7f69ff202fe 100644
--- a/src/tools/miri/tests/fail/tree_borrows/strongly-protected.stderr
+++ b/src/tools/miri/tests/fail/tree_borrows/strongly-protected.stderr
@@ -1,8 +1,8 @@
 error: Undefined Behavior: deallocation through <TAG> at ALLOC[0x0] is forbidden
-  --> RUSTLIB/alloc/src/alloc.rs:LL:CC
+  --> RUSTLIB/alloc/src/boxed.rs:LL:CC
    |
-LL |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
-   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden
+LL |                 self.1.deallocate(From::from(ptr.cast()), layout);
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the Tree Borrows rules it violated are still experimental
    = help: the allocation of the accessed tag <TAG> also contains the strongly protected tag <TAG>
@@ -18,8 +18,6 @@ help: the strongly protected tag <TAG> was created here, in the initial state Re
 LL | fn inner(x: &mut i32, f: fn(*mut i32)) {
    |          ^
    = note: BACKTRACE (of the first span):
-   = note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
-   = note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at RUSTLIB/alloc/src/alloc.rs:LL:CC
    = note: inside `<std::boxed::Box<i32> as std::ops::Drop>::drop` at RUSTLIB/alloc/src/boxed.rs:LL:CC
    = note: inside `std::ptr::drop_in_place::<std::boxed::Box<i32>> - shim(Some(std::boxed::Box<i32>))` at RUSTLIB/core/src/ptr/mod.rs:LL:CC
    = note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC

From 041b59eb626661d39984bc3c25a148793147fef6 Mon Sep 17 00:00:00 2001
From: onur-ozkan <work@onurozkan.dev>
Date: Thu, 12 Sep 2024 08:31:19 +0300
Subject: [PATCH 2/6] skip target sanity check when it's a `local-rebuild`

Running the stage0 target sanity check on the newly built compiler can result
in errors and incorrect assumptions.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
---
 src/bootstrap/src/core/sanity.rs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs
index dbc712adadf3e..bd21fafc999be 100644
--- a/src/bootstrap/src/core/sanity.rs
+++ b/src/bootstrap/src/core/sanity.rs
@@ -233,7 +233,8 @@ than building it.
         }
 
         // Ignore fake targets that are only used for unit tests in bootstrap.
-        if cfg!(not(feature = "bootstrap-self-test")) && !skip_target_sanity {
+        if cfg!(not(feature = "bootstrap-self-test")) && !skip_target_sanity && !build.local_rebuild
+        {
             let mut has_target = false;
             let target_str = target.to_string();
 

From 654513e202dcea87724c89507ecb1b47547d4cb2 Mon Sep 17 00:00:00 2001
From: onur-ozkan <work@onurozkan.dev>
Date: Thu, 12 Sep 2024 08:38:26 +0300
Subject: [PATCH 3/6] use `local-rebuild` instead of
 `BOOTSTRAP_SKIP_TARGET_SANITY` workaround

Signed-off-by: onur-ozkan <work@onurozkan.dev>
---
 src/tools/opt-dist/src/tests.rs | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/tools/opt-dist/src/tests.rs b/src/tools/opt-dist/src/tests.rs
index 9dbba7a05001d..e7a3ed787ed7c 100644
--- a/src/tools/opt-dist/src/tests.rs
+++ b/src/tools/opt-dist/src/tests.rs
@@ -67,6 +67,7 @@ change-id = 115898
 [build]
 rustc = "{rustc}"
 cargo = "{cargo}"
+local-rebuild = true
 
 [target.{host_triple}]
 llvm-config = "{llvm_config}"
@@ -102,13 +103,7 @@ llvm-config = "{llvm_config}"
     for test_path in env.skipped_tests() {
         args.extend(["--skip", test_path]);
     }
-    cmd(&args)
-        .env("COMPILETEST_FORCE_STAGE0", "1")
-        // Above we override the stage 0 compiler with previously compiled compiler,
-        // which can cause confusion in bootstrap's target sanity checks.
-        .env("BOOTSTRAP_SKIP_TARGET_SANITY", "1")
-        .run()
-        .context("Cannot execute tests")
+    cmd(&args).env("COMPILETEST_FORCE_STAGE0", "1").run().context("Cannot execute tests")
 }
 
 /// Tries to find the version of the dist artifacts (either nightly, beta, or 1.XY.Z).

From 9454a89ef0ad62b804dc61740b83e8bf10661918 Mon Sep 17 00:00:00 2001
From: Michael Howell <michael@notriddle.com>
Date: Thu, 12 Sep 2024 13:38:24 -0700
Subject: [PATCH 4/6] Add URL and crate_name to test cases

---
 tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.rs    | 2 ++
 .../rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr  | 4 ++--
 tests/rustdoc-ui/issue-110629-private-type-cycle.rs        | 1 +
 tests/rustdoc/deref/issue-100679-sidebar-links-deref.rs    | 1 +
 tests/rustdoc/duplicate_impls/issue-33054.rs               | 6 ++++--
 tests/rustdoc/generic-associated-types/issue-109488.rs     | 4 +++-
 tests/rustdoc/generic-associated-types/issue-94683.rs      | 1 +
 tests/rustdoc/issue-108925.rs                              | 5 ++++-
 tests/rustdoc/issue-108931-anonymous-reexport.rs           | 1 +
 tests/rustdoc/issue-109695-crate-doc-hidden.rs             | 1 +
 tests/rustdoc/issue-110629-private-type-cycle.rs           | 4 +++-
 tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs | 1 +
 tests/rustdoc/issue-111249-file-creation.rs                | 1 +
 .../rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs  | 1 +
 tests/rustdoc/issue-115295-macro-const-display.rs          | 1 +
 tests/rustdoc/issue-118180-empty-tuple-struct.rs           | 7 +++++--
 16 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.rs b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.rs
index c920a815fda75..91bf64cdc567d 100644
--- a/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.rs
+++ b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.rs
@@ -1,3 +1,5 @@
+// https://github.com/rust-lang/rust/issues/110629
+
 type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>;
 //~^ ERROR cycle detected when expanding type alias
 
diff --git a/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr
index 9394b019e11e0..b19e4a245f1b6 100644
--- a/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr
+++ b/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr
@@ -1,5 +1,5 @@
 error[E0391]: cycle detected when expanding type alias `Bar`
-  --> $DIR/issue-110629-private-type-cycle-dyn.rs:1:38
+  --> $DIR/issue-110629-private-type-cycle-dyn.rs:3:38
    |
 LL | type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>;
    |                                      ^^^^^^^^^^^
@@ -9,7 +9,7 @@ LL | type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>;
    = help: consider using a struct, enum, or union instead to break the cycle
    = help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
 note: cycle used when checking that `Bar` is well-formed
-  --> $DIR/issue-110629-private-type-cycle-dyn.rs:1:1
+  --> $DIR/issue-110629-private-type-cycle-dyn.rs:3:1
    |
 LL | type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>;
    | ^^^^^^^^^^^^^^^^
diff --git a/tests/rustdoc-ui/issue-110629-private-type-cycle.rs b/tests/rustdoc-ui/issue-110629-private-type-cycle.rs
index b31b9d03e7cb3..fecb0239a3c22 100644
--- a/tests/rustdoc-ui/issue-110629-private-type-cycle.rs
+++ b/tests/rustdoc-ui/issue-110629-private-type-cycle.rs
@@ -1,4 +1,5 @@
 //@ check-pass
+// https://github.com/rust-lang/rust/issues/110629
 
 #![feature(type_alias_impl_trait)]
 
diff --git a/tests/rustdoc/deref/issue-100679-sidebar-links-deref.rs b/tests/rustdoc/deref/issue-100679-sidebar-links-deref.rs
index 44ac08de0b820..d0c37529487eb 100644
--- a/tests/rustdoc/deref/issue-100679-sidebar-links-deref.rs
+++ b/tests/rustdoc/deref/issue-100679-sidebar-links-deref.rs
@@ -1,3 +1,4 @@
+// https://github.com/rust-lang/rust/issues/100679
 #![crate_name="foo"]
 
 pub struct Vec;
diff --git a/tests/rustdoc/duplicate_impls/issue-33054.rs b/tests/rustdoc/duplicate_impls/issue-33054.rs
index 24ff30668cfac..511a40c38a0a2 100644
--- a/tests/rustdoc/duplicate_impls/issue-33054.rs
+++ b/tests/rustdoc/duplicate_impls/issue-33054.rs
@@ -1,11 +1,13 @@
 // ignore-tidy-linelength
+// https://github.com/rust-lang/rust/issues/100679
+#![crate_name="foo"]
 
-//@ has issue_33054/impls/struct.Foo.html
+//@ has foo/impls/struct.Foo.html
 //@ has - '//h3[@class="code-header"]' 'impl Foo'
 //@ has - '//h3[@class="code-header"]' 'impl Bar for Foo'
 //@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1
 //@ count - '//*[@id="main-content"]/div[@id="implementations-list"]/details/summary/*[@class="impl"]' 1
-//@ has issue_33054/impls/bar/trait.Bar.html
+//@ has foo/impls/bar/trait.Bar.html
 //@ has - '//h3[@class="code-header"]' 'impl Bar for Foo'
 //@ count - '//*[@class="struct"]' 1
 pub mod impls;
diff --git a/tests/rustdoc/generic-associated-types/issue-109488.rs b/tests/rustdoc/generic-associated-types/issue-109488.rs
index 12f8988f52002..be55a10b4033d 100644
--- a/tests/rustdoc/generic-associated-types/issue-109488.rs
+++ b/tests/rustdoc/generic-associated-types/issue-109488.rs
@@ -1,8 +1,10 @@
 // Make sure that we escape the arguments of the GAT projection even if we fail to compute
 // the href of the corresponding trait (in this case it is private).
 // Further, test that we also linkify the GAT arguments.
+// https://github.com/rust-lang/rust/issues/94683
+#![crate_name="foo"]
 
-//@ has 'issue_109488/type.A.html'
+//@ has 'foo/type.A.html'
 //@ has - '//pre[@class="rust item-decl"]' '<S as Tr>::P<Option<i32>>'
 //@ has - '//pre[@class="rust item-decl"]//a[@class="enum"]/@href' '{{channel}}/core/option/enum.Option.html'
 pub type A = <S as Tr>::P<Option<i32>>;
diff --git a/tests/rustdoc/generic-associated-types/issue-94683.rs b/tests/rustdoc/generic-associated-types/issue-94683.rs
index 19a1e9d448e65..c1cacaf3f1158 100644
--- a/tests/rustdoc/generic-associated-types/issue-94683.rs
+++ b/tests/rustdoc/generic-associated-types/issue-94683.rs
@@ -1,3 +1,4 @@
+// https://github.com/rust-lang/rust/issues/94683
 #![crate_name = "foo"]
 
 pub trait Trait {
diff --git a/tests/rustdoc/issue-108925.rs b/tests/rustdoc/issue-108925.rs
index a332771616d4a..ea2462449d2b7 100644
--- a/tests/rustdoc/issue-108925.rs
+++ b/tests/rustdoc/issue-108925.rs
@@ -1,4 +1,7 @@
-//@ has issue_108925/enum.MyThing.html
+// https://github.com/rust-lang/rust/issues/108925
+#![crate_name="foo"]
+
+//@ has foo/enum.MyThing.html
 //@ has - '//code' 'Shown'
 //@ !has - '//code' 'NotShown'
 //@ !has - '//code' '// some variants omitted'
diff --git a/tests/rustdoc/issue-108931-anonymous-reexport.rs b/tests/rustdoc/issue-108931-anonymous-reexport.rs
index 300ee3baf053f..f4cc7f1239628 100644
--- a/tests/rustdoc/issue-108931-anonymous-reexport.rs
+++ b/tests/rustdoc/issue-108931-anonymous-reexport.rs
@@ -1,4 +1,5 @@
 // Ensuring that anonymous re-exports are always inlined.
+// https://github.com/rust-lang/rust/issues/108931
 
 #![crate_name = "foo"]
 
diff --git a/tests/rustdoc/issue-109695-crate-doc-hidden.rs b/tests/rustdoc/issue-109695-crate-doc-hidden.rs
index 8dc077d15657e..fc8361ab2976b 100644
--- a/tests/rustdoc/issue-109695-crate-doc-hidden.rs
+++ b/tests/rustdoc/issue-109695-crate-doc-hidden.rs
@@ -1,5 +1,6 @@
 // This test ensures that even if the crate module is `#[doc(hidden)]`, the file
 // is generated.
+// https://github.com/rust-lang/rust/issues/109695
 
 //@ has 'foo/index.html'
 //@ has 'foo/all.html'
diff --git a/tests/rustdoc/issue-110629-private-type-cycle.rs b/tests/rustdoc/issue-110629-private-type-cycle.rs
index 22ea721fd440d..e237680969795 100644
--- a/tests/rustdoc/issue-110629-private-type-cycle.rs
+++ b/tests/rustdoc/issue-110629-private-type-cycle.rs
@@ -1,10 +1,12 @@
 //@ compile-flags: --document-private-items
 
+// https://github.com/rust-lang/rust/issues/110629
+#![crate_name="foo"]
 #![feature(type_alias_impl_trait)]
 
 type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + std::fmt::Debug;
 
-//@ has issue_110629_private_type_cycle/type.Bar.html
+//@ has foo/type.Bar.html
 //@ has - '//pre[@class="rust item-decl"]' \
 //     "pub(crate) type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + Debug;"
 
diff --git a/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs b/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs
index 4b80f508e7f53..2b21f9862b447 100644
--- a/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs
+++ b/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs
@@ -1,3 +1,4 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/111064>.
 #![feature(no_core)]
 #![no_core]
 #![crate_name = "foo"]
diff --git a/tests/rustdoc/issue-111249-file-creation.rs b/tests/rustdoc/issue-111249-file-creation.rs
index 89a25aef97def..a6522d682f191 100644
--- a/tests/rustdoc/issue-111249-file-creation.rs
+++ b/tests/rustdoc/issue-111249-file-creation.rs
@@ -1,3 +1,4 @@
+// https://github.com/rust-lang/rust/issues/111249
 #![crate_name = "foo"]
 #![feature(no_core)]
 #![no_core]
diff --git a/tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs b/tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs
index c083d9495f43c..76b25127a9c64 100644
--- a/tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs
+++ b/tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs
@@ -1,5 +1,6 @@
 //@ aux-build: issue-113982-doc_auto_cfg-reexport-foreign.rs
 
+// https://github.com/rust-lang/rust/issues/113982
 #![feature(no_core, doc_auto_cfg)]
 #![no_core]
 #![crate_name = "foo"]
diff --git a/tests/rustdoc/issue-115295-macro-const-display.rs b/tests/rustdoc/issue-115295-macro-const-display.rs
index 0dadb76ae5cdd..445b47e0b2467 100644
--- a/tests/rustdoc/issue-115295-macro-const-display.rs
+++ b/tests/rustdoc/issue-115295-macro-const-display.rs
@@ -1,3 +1,4 @@
+// https://github.com/rust-lang/rust/issues/115295
 #![crate_name = "foo"]
 
 //@ has foo/trait.Trait.html
diff --git a/tests/rustdoc/issue-118180-empty-tuple-struct.rs b/tests/rustdoc/issue-118180-empty-tuple-struct.rs
index 2cd1df27b2bf0..614857ad5aeab 100644
--- a/tests/rustdoc/issue-118180-empty-tuple-struct.rs
+++ b/tests/rustdoc/issue-118180-empty-tuple-struct.rs
@@ -1,9 +1,12 @@
-//@ has issue_118180_empty_tuple_struct/enum.Enum.html
+// https://github.com/rust-lang/rust/issues/118180
+#![crate_name="foo"]
+
+//@ has foo/enum.Enum.html
 pub enum Enum {
     //@ has - '//*[@id="variant.Empty"]//h3' 'Empty()'
     Empty(),
 }
 
-//@ has issue_118180_empty_tuple_struct/struct.Empty.html
+//@ has foo/struct.Empty.html
 //@ has - '//pre/code' 'Empty()'
 pub struct Empty();

From 061cbae7c9a101c81b132cf411117bf089c832bd Mon Sep 17 00:00:00 2001
From: Michael Howell <michael@notriddle.com>
Date: Thu, 12 Sep 2024 13:47:51 -0700
Subject: [PATCH 5/6] rustdoc: rename `issue-\d+.rs` tests to have meaningful
 names

---
 ...{issue-102467.rs => associated-constant-not-allowed-102467.rs} | 0
 ...02467.stderr => associated-constant-not-allowed-102467.stderr} | 0
 ...-110629-private-type-cycle.rs => private-type-cycle-110629.rs} | 0
 ...private-type-cycle-dyn.rs => private-type-cycle-dyn-110629.rs} | 0
 ...type-cycle-dyn.stderr => private-type-cycle-dyn-110629.stderr} | 0
 ...-108931-anonymous-reexport.rs => anonymous-reexport-108931.rs} | 0
 ...ssue-109695-crate-doc-hidden.rs => crate-doc-hidden-109695.rs} | 0
 ...00679-sidebar-links-deref.rs => sidebar-links-deref-100679.rs} | 0
 ...449-doc-hidden-reexports.rs => doc-hidden-reexports-109449.rs} | 0
 ...eexport-foreign.rs => doc_auto_cfg-reexport-foreign-113982.rs} | 0
 .../{issue-33054.rs => sidebar-links-duplicate-impls-33054.rs}    | 0
 ...-118180-empty-tuple-struct.rs => empty-tuple-struct-118180.rs} | 0
 tests/rustdoc/{issue-108925.rs => enum-non-exhaustive-108925.rs}  | 0
 .../{issue-111249-file-creation.rs => file-creation-111249.rs}    | 0
 .../{issue-94683.rs => gat-elided-lifetime-94683.rs}              | 0
 .../{issue-109488.rs => gat-linkification-109488.rs}              | 0
 .../{issue-110422-inner-private.rs => inner-private-110422.rs}    | 0
 ...15295-macro-const-display.rs => macro-const-display-115295.rs} | 0
 ...ing-private-inlining.rs => missing-private-inlining-109258.rs} | 0
 ...-110629-private-type-cycle.rs => private-type-cycle-110629.rs} | 0
 ...it-from-hidden-2.rs => reexport-trait-from-hidden-111064-2.rs} | 0
 ...-trait-from-hidden.rs => reexport-trait-from-hidden-111064.rs} | 0
 22 files changed, 0 insertions(+), 0 deletions(-)
 rename tests/rustdoc-ui/{issue-102467.rs => associated-constant-not-allowed-102467.rs} (100%)
 rename tests/rustdoc-ui/{issue-102467.stderr => associated-constant-not-allowed-102467.stderr} (100%)
 rename tests/rustdoc-ui/{issue-110629-private-type-cycle.rs => private-type-cycle-110629.rs} (100%)
 rename tests/rustdoc-ui/{issue-110629-private-type-cycle-dyn.rs => private-type-cycle-dyn-110629.rs} (100%)
 rename tests/rustdoc-ui/{issue-110629-private-type-cycle-dyn.stderr => private-type-cycle-dyn-110629.stderr} (100%)
 rename tests/rustdoc/{issue-108931-anonymous-reexport.rs => anonymous-reexport-108931.rs} (100%)
 rename tests/rustdoc/{issue-109695-crate-doc-hidden.rs => crate-doc-hidden-109695.rs} (100%)
 rename tests/rustdoc/deref/{issue-100679-sidebar-links-deref.rs => sidebar-links-deref-100679.rs} (100%)
 rename tests/rustdoc/{issue-109449-doc-hidden-reexports.rs => doc-hidden-reexports-109449.rs} (100%)
 rename tests/rustdoc/{issue-113982-doc_auto_cfg-reexport-foreign.rs => doc_auto_cfg-reexport-foreign-113982.rs} (100%)
 rename tests/rustdoc/duplicate_impls/{issue-33054.rs => sidebar-links-duplicate-impls-33054.rs} (100%)
 rename tests/rustdoc/{issue-118180-empty-tuple-struct.rs => empty-tuple-struct-118180.rs} (100%)
 rename tests/rustdoc/{issue-108925.rs => enum-non-exhaustive-108925.rs} (100%)
 rename tests/rustdoc/{issue-111249-file-creation.rs => file-creation-111249.rs} (100%)
 rename tests/rustdoc/generic-associated-types/{issue-94683.rs => gat-elided-lifetime-94683.rs} (100%)
 rename tests/rustdoc/generic-associated-types/{issue-109488.rs => gat-linkification-109488.rs} (100%)
 rename tests/rustdoc/{issue-110422-inner-private.rs => inner-private-110422.rs} (100%)
 rename tests/rustdoc/{issue-115295-macro-const-display.rs => macro-const-display-115295.rs} (100%)
 rename tests/rustdoc/{issue-109258-missing-private-inlining.rs => missing-private-inlining-109258.rs} (100%)
 rename tests/rustdoc/{issue-110629-private-type-cycle.rs => private-type-cycle-110629.rs} (100%)
 rename tests/rustdoc/{issue-111064-reexport-trait-from-hidden-2.rs => reexport-trait-from-hidden-111064-2.rs} (100%)
 rename tests/rustdoc/{issue-111064-reexport-trait-from-hidden.rs => reexport-trait-from-hidden-111064.rs} (100%)

diff --git a/tests/rustdoc-ui/issue-102467.rs b/tests/rustdoc-ui/associated-constant-not-allowed-102467.rs
similarity index 100%
rename from tests/rustdoc-ui/issue-102467.rs
rename to tests/rustdoc-ui/associated-constant-not-allowed-102467.rs
diff --git a/tests/rustdoc-ui/issue-102467.stderr b/tests/rustdoc-ui/associated-constant-not-allowed-102467.stderr
similarity index 100%
rename from tests/rustdoc-ui/issue-102467.stderr
rename to tests/rustdoc-ui/associated-constant-not-allowed-102467.stderr
diff --git a/tests/rustdoc-ui/issue-110629-private-type-cycle.rs b/tests/rustdoc-ui/private-type-cycle-110629.rs
similarity index 100%
rename from tests/rustdoc-ui/issue-110629-private-type-cycle.rs
rename to tests/rustdoc-ui/private-type-cycle-110629.rs
diff --git a/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.rs b/tests/rustdoc-ui/private-type-cycle-dyn-110629.rs
similarity index 100%
rename from tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.rs
rename to tests/rustdoc-ui/private-type-cycle-dyn-110629.rs
diff --git a/tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr b/tests/rustdoc-ui/private-type-cycle-dyn-110629.stderr
similarity index 100%
rename from tests/rustdoc-ui/issue-110629-private-type-cycle-dyn.stderr
rename to tests/rustdoc-ui/private-type-cycle-dyn-110629.stderr
diff --git a/tests/rustdoc/issue-108931-anonymous-reexport.rs b/tests/rustdoc/anonymous-reexport-108931.rs
similarity index 100%
rename from tests/rustdoc/issue-108931-anonymous-reexport.rs
rename to tests/rustdoc/anonymous-reexport-108931.rs
diff --git a/tests/rustdoc/issue-109695-crate-doc-hidden.rs b/tests/rustdoc/crate-doc-hidden-109695.rs
similarity index 100%
rename from tests/rustdoc/issue-109695-crate-doc-hidden.rs
rename to tests/rustdoc/crate-doc-hidden-109695.rs
diff --git a/tests/rustdoc/deref/issue-100679-sidebar-links-deref.rs b/tests/rustdoc/deref/sidebar-links-deref-100679.rs
similarity index 100%
rename from tests/rustdoc/deref/issue-100679-sidebar-links-deref.rs
rename to tests/rustdoc/deref/sidebar-links-deref-100679.rs
diff --git a/tests/rustdoc/issue-109449-doc-hidden-reexports.rs b/tests/rustdoc/doc-hidden-reexports-109449.rs
similarity index 100%
rename from tests/rustdoc/issue-109449-doc-hidden-reexports.rs
rename to tests/rustdoc/doc-hidden-reexports-109449.rs
diff --git a/tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs b/tests/rustdoc/doc_auto_cfg-reexport-foreign-113982.rs
similarity index 100%
rename from tests/rustdoc/issue-113982-doc_auto_cfg-reexport-foreign.rs
rename to tests/rustdoc/doc_auto_cfg-reexport-foreign-113982.rs
diff --git a/tests/rustdoc/duplicate_impls/issue-33054.rs b/tests/rustdoc/duplicate_impls/sidebar-links-duplicate-impls-33054.rs
similarity index 100%
rename from tests/rustdoc/duplicate_impls/issue-33054.rs
rename to tests/rustdoc/duplicate_impls/sidebar-links-duplicate-impls-33054.rs
diff --git a/tests/rustdoc/issue-118180-empty-tuple-struct.rs b/tests/rustdoc/empty-tuple-struct-118180.rs
similarity index 100%
rename from tests/rustdoc/issue-118180-empty-tuple-struct.rs
rename to tests/rustdoc/empty-tuple-struct-118180.rs
diff --git a/tests/rustdoc/issue-108925.rs b/tests/rustdoc/enum-non-exhaustive-108925.rs
similarity index 100%
rename from tests/rustdoc/issue-108925.rs
rename to tests/rustdoc/enum-non-exhaustive-108925.rs
diff --git a/tests/rustdoc/issue-111249-file-creation.rs b/tests/rustdoc/file-creation-111249.rs
similarity index 100%
rename from tests/rustdoc/issue-111249-file-creation.rs
rename to tests/rustdoc/file-creation-111249.rs
diff --git a/tests/rustdoc/generic-associated-types/issue-94683.rs b/tests/rustdoc/generic-associated-types/gat-elided-lifetime-94683.rs
similarity index 100%
rename from tests/rustdoc/generic-associated-types/issue-94683.rs
rename to tests/rustdoc/generic-associated-types/gat-elided-lifetime-94683.rs
diff --git a/tests/rustdoc/generic-associated-types/issue-109488.rs b/tests/rustdoc/generic-associated-types/gat-linkification-109488.rs
similarity index 100%
rename from tests/rustdoc/generic-associated-types/issue-109488.rs
rename to tests/rustdoc/generic-associated-types/gat-linkification-109488.rs
diff --git a/tests/rustdoc/issue-110422-inner-private.rs b/tests/rustdoc/inner-private-110422.rs
similarity index 100%
rename from tests/rustdoc/issue-110422-inner-private.rs
rename to tests/rustdoc/inner-private-110422.rs
diff --git a/tests/rustdoc/issue-115295-macro-const-display.rs b/tests/rustdoc/macro-const-display-115295.rs
similarity index 100%
rename from tests/rustdoc/issue-115295-macro-const-display.rs
rename to tests/rustdoc/macro-const-display-115295.rs
diff --git a/tests/rustdoc/issue-109258-missing-private-inlining.rs b/tests/rustdoc/missing-private-inlining-109258.rs
similarity index 100%
rename from tests/rustdoc/issue-109258-missing-private-inlining.rs
rename to tests/rustdoc/missing-private-inlining-109258.rs
diff --git a/tests/rustdoc/issue-110629-private-type-cycle.rs b/tests/rustdoc/private-type-cycle-110629.rs
similarity index 100%
rename from tests/rustdoc/issue-110629-private-type-cycle.rs
rename to tests/rustdoc/private-type-cycle-110629.rs
diff --git a/tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs b/tests/rustdoc/reexport-trait-from-hidden-111064-2.rs
similarity index 100%
rename from tests/rustdoc/issue-111064-reexport-trait-from-hidden-2.rs
rename to tests/rustdoc/reexport-trait-from-hidden-111064-2.rs
diff --git a/tests/rustdoc/issue-111064-reexport-trait-from-hidden.rs b/tests/rustdoc/reexport-trait-from-hidden-111064.rs
similarity index 100%
rename from tests/rustdoc/issue-111064-reexport-trait-from-hidden.rs
rename to tests/rustdoc/reexport-trait-from-hidden-111064.rs

From 48c7e444b15823342e8482a7c6590bca6d83e691 Mon Sep 17 00:00:00 2001
From: Michael Howell <michael@notriddle.com>
Date: Thu, 12 Sep 2024 13:48:51 -0700
Subject: [PATCH 6/6] rustdoc: re-bless stderrs after renaming the test case

---
 .../rustdoc-ui/associated-constant-not-allowed-102467.stderr  | 4 ++--
 tests/rustdoc-ui/private-type-cycle-dyn-110629.stderr         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/rustdoc-ui/associated-constant-not-allowed-102467.stderr b/tests/rustdoc-ui/associated-constant-not-allowed-102467.stderr
index 5fcdba782e7eb..5c8f08afe7a5a 100644
--- a/tests/rustdoc-ui/associated-constant-not-allowed-102467.stderr
+++ b/tests/rustdoc-ui/associated-constant-not-allowed-102467.stderr
@@ -1,5 +1,5 @@
 error[E0229]: associated item constraints are not allowed here
-  --> $DIR/issue-102467.rs:7:17
+  --> $DIR/associated-constant-not-allowed-102467.rs:7:17
    |
 LL |     type A: S<C<X = 0i32> = 34>;
    |                 ^^^^^^^^ associated item constraint not allowed here
@@ -11,7 +11,7 @@ LL +     type A: S<C = 34>;
    |
 
 error[E0229]: associated item constraints are not allowed here
-  --> $DIR/issue-102467.rs:7:17
+  --> $DIR/associated-constant-not-allowed-102467.rs:7:17
    |
 LL |     type A: S<C<X = 0i32> = 34>;
    |                 ^^^^^^^^ associated item constraint not allowed here
diff --git a/tests/rustdoc-ui/private-type-cycle-dyn-110629.stderr b/tests/rustdoc-ui/private-type-cycle-dyn-110629.stderr
index b19e4a245f1b6..6ee7e4b781c5b 100644
--- a/tests/rustdoc-ui/private-type-cycle-dyn-110629.stderr
+++ b/tests/rustdoc-ui/private-type-cycle-dyn-110629.stderr
@@ -1,5 +1,5 @@
 error[E0391]: cycle detected when expanding type alias `Bar`
-  --> $DIR/issue-110629-private-type-cycle-dyn.rs:3:38
+  --> $DIR/private-type-cycle-dyn-110629.rs:3:38
    |
 LL | type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>;
    |                                      ^^^^^^^^^^^
@@ -9,7 +9,7 @@ LL | type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>;
    = help: consider using a struct, enum, or union instead to break the cycle
    = help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
 note: cycle used when checking that `Bar` is well-formed
-  --> $DIR/issue-110629-private-type-cycle-dyn.rs:3:1
+  --> $DIR/private-type-cycle-dyn-110629.rs:3:1
    |
 LL | type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>;
    | ^^^^^^^^^^^^^^^^