Auto merge of #130303 - Zalathar:rollup-8vsqdox, r=Zalathar

Rollup of 3 pull requests

Successful merges:

 - #130245 (make basic allocation functions track_caller in Miri for nicer backtraces)
 - #130261 (skip target sanity check when it's a `local-rebuild`)
 - #130287 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 9))

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-09-13 11:27:53 +00:00
commit 473ae00839
52 changed files with 117 additions and 175 deletions

View file

@ -89,6 +89,7 @@ pub use std::alloc::Global;
#[stable(feature = "global_alloc", since = "1.28.0")] #[stable(feature = "global_alloc", since = "1.28.0")]
#[must_use = "losing the pointer will leak memory"] #[must_use = "losing the pointer will leak memory"]
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub unsafe fn alloc(layout: Layout) -> *mut u8 { pub unsafe fn alloc(layout: Layout) -> *mut u8 {
unsafe { unsafe {
// Make sure we don't accidentally allow omitting the allocator shim in // 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`]. /// See [`GlobalAlloc::dealloc`].
#[stable(feature = "global_alloc", since = "1.28.0")] #[stable(feature = "global_alloc", since = "1.28.0")]
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) { pub unsafe fn dealloc(ptr: *mut u8, layout: Layout) {
unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) } 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")] #[stable(feature = "global_alloc", since = "1.28.0")]
#[must_use = "losing the pointer will leak memory"] #[must_use = "losing the pointer will leak memory"]
#[inline] #[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 { pub unsafe fn realloc(ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
unsafe { __rust_realloc(ptr, layout.size(), layout.align(), new_size) } 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")] #[stable(feature = "global_alloc", since = "1.28.0")]
#[must_use = "losing the pointer will leak memory"] #[must_use = "losing the pointer will leak memory"]
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 { pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 {
unsafe { __rust_alloc_zeroed(layout.size(), layout.align()) } unsafe { __rust_alloc_zeroed(layout.size(), layout.align()) }
} }
@ -173,6 +177,7 @@ pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 {
#[cfg(not(test))] #[cfg(not(test))]
impl Global { impl Global {
#[inline] #[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> { fn alloc_impl(&self, layout: Layout, zeroed: bool) -> Result<NonNull<[u8]>, AllocError> {
match layout.size() { match layout.size() {
0 => Ok(NonNull::slice_from_raw_parts(layout.dangling(), 0)), 0 => Ok(NonNull::slice_from_raw_parts(layout.dangling(), 0)),
@ -187,6 +192,7 @@ impl Global {
// SAFETY: Same as `Allocator::grow` // SAFETY: Same as `Allocator::grow`
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
unsafe fn grow_impl( unsafe fn grow_impl(
&self, &self,
ptr: NonNull<u8>, ptr: NonNull<u8>,
@ -237,16 +243,19 @@ impl Global {
#[cfg(not(test))] #[cfg(not(test))]
unsafe impl Allocator for Global { unsafe impl Allocator for Global {
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
self.alloc_impl(layout, false) self.alloc_impl(layout, false)
} }
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
self.alloc_impl(layout, true) self.alloc_impl(layout, true)
} }
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) { unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
if layout.size() != 0 { if layout.size() != 0 {
// SAFETY: `layout` is non-zero in size, // SAFETY: `layout` is non-zero in size,
@ -256,6 +265,7 @@ unsafe impl Allocator for Global {
} }
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
unsafe fn grow( unsafe fn grow(
&self, &self,
ptr: NonNull<u8>, ptr: NonNull<u8>,
@ -267,6 +277,7 @@ unsafe impl Allocator for Global {
} }
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
unsafe fn grow_zeroed( unsafe fn grow_zeroed(
&self, &self,
ptr: NonNull<u8>, ptr: NonNull<u8>,
@ -278,6 +289,7 @@ unsafe impl Allocator for Global {
} }
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
unsafe fn shrink( unsafe fn shrink(
&self, &self,
ptr: NonNull<u8>, ptr: NonNull<u8>,
@ -325,6 +337,7 @@ unsafe impl Allocator for Global {
#[cfg(all(not(no_global_oom_handling), not(test)))] #[cfg(all(not(no_global_oom_handling), not(test)))]
#[lang = "exchange_malloc"] #[lang = "exchange_malloc"]
#[inline] #[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 { unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
let layout = unsafe { Layout::from_size_align_unchecked(size, align) }; let layout = unsafe { Layout::from_size_align_unchecked(size, align) };
match Global.allocate(layout) { match Global.allocate(layout) {

View file

@ -250,6 +250,7 @@ impl<T> Box<T> {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[must_use] #[must_use]
#[rustc_diagnostic_item = "box_new"] #[rustc_diagnostic_item = "box_new"]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
pub fn new(x: T) -> Self { pub fn new(x: T) -> Self {
#[rustc_box] #[rustc_box]
Box::new(x) Box::new(x)

View file

@ -233,7 +233,8 @@ than building it.
} }
// Ignore fake targets that are only used for unit tests in bootstrap. // 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 mut has_target = false;
let target_str = target.to_string(); let target_str = target.to_string();

View file

@ -1,10 +1,8 @@
use std::alloc::{alloc, dealloc, Layout}; 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() { fn main() {
unsafe { unsafe {
let x = alloc(Layout::from_size_align_unchecked(1, 1)); 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
} }
} }

View file

@ -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 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()) } 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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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: 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 = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE: = note: BACKTRACE:
= note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC = note: inside `main` at $DIR/deallocate-bad-alignment.rs:LL:CC
note: inside `main`
--> $DIR/deallocate-bad-alignment.rs:LL:CC
|
LL | dealloc(x, Layout::from_size_align_unchecked(1, 2));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

View file

@ -1,10 +1,8 @@
use std::alloc::{alloc, dealloc, Layout}; 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() { fn main() {
unsafe { unsafe {
let x = alloc(Layout::from_size_align_unchecked(1, 1)); 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
} }
} }

View file

@ -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 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()) } 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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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: 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 = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE: = note: BACKTRACE:
= note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC = note: inside `main` at $DIR/deallocate-bad-size.rs:LL:CC
note: inside `main`
--> $DIR/deallocate-bad-size.rs:LL:CC
|
LL | dealloc(x, Layout::from_size_align_unchecked(2, 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

View file

@ -1,11 +1,9 @@
use std::alloc::{alloc, dealloc, Layout}; use std::alloc::{alloc, dealloc, Layout};
//@error-in-other-file: has been freed
fn main() { fn main() {
unsafe { unsafe {
let x = alloc(Layout::from_size_align_unchecked(1, 1)); 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)); dealloc(x, Layout::from_size_align_unchecked(1, 1)); //~ERROR: has been freed
} }
} }

View file

@ -1,8 +1,8 @@
error: Undefined Behavior: memory access failed: ALLOC has been freed, so this pointer is dangling 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()) } LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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: 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 = 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)); LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: BACKTRACE (of the first span): = note: BACKTRACE (of the first span):
= note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC = note: inside `main` at $DIR/deallocate-twice.rs:LL:CC
note: inside `main`
--> $DIR/deallocate-twice.rs:LL:CC
|
LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

View file

@ -1,10 +1,8 @@
use std::alloc::{alloc, realloc, Layout}; 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() { fn main() {
unsafe { unsafe {
let x = alloc(Layout::from_size_align_unchecked(1, 1)); 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
} }
} }

View file

@ -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 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) } 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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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: 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 = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE: = note: BACKTRACE:
= note: inside `std::alloc::realloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC = note: inside `main` at $DIR/reallocate-bad-size.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: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

View file

@ -1,11 +1,9 @@
use std::alloc::{alloc, dealloc, realloc, Layout}; use std::alloc::{alloc, dealloc, realloc, Layout};
//@error-in-other-file: has been freed
fn main() { fn main() {
unsafe { unsafe {
let x = alloc(Layout::from_size_align_unchecked(1, 1)); 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));
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
} }
} }

View file

@ -1,8 +1,8 @@
error: Undefined Behavior: memory access failed: ALLOC has been freed, so this pointer is dangling 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) } 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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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: 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 = 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)); LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: BACKTRACE (of the first span): = note: BACKTRACE (of the first span):
= note: inside `std::alloc::realloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC = note: inside `main` at $DIR/reallocate-dangling.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: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

View file

@ -1,14 +1,12 @@
error: Undefined Behavior: deallocating ALLOC, which is stack variable memory, using Rust heap deallocation operation 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()) } LL | self.1.deallocate(From::from(ptr.cast()), layout);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating ALLOC, which is stack variable memory, using Rust heap deallocation operation | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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: 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 = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE: = 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::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::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 = note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC

View file

@ -1,8 +1,8 @@
error: Undefined Behavior: deallocation through <TAG> at ALLOC[0x0] is forbidden 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()) } LL | self.1.deallocate(From::from(ptr.cast()), layout);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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: 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) = 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 = help: this transition corresponds to a temporary loss of write permissions until function exit
= note: BACKTRACE (of the first span): = 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::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::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 = note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC

View file

@ -1,8 +1,8 @@
error: Undefined Behavior: deallocation through <TAG> at ALLOC[0x0] is forbidden 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()) } LL | self.1.deallocate(From::from(ptr.cast()), layout);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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: 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) = 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 = help: this transition corresponds to a temporary loss of write permissions until function exit
= note: BACKTRACE (of the first span): = 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::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::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 = note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC

View file

@ -1,13 +1,12 @@
//@revisions: stack tree //@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows //@[tree]compile-flags: -Zmiri-tree-borrows
//@[tree]error-in-other-file: /deallocation .* is forbidden/
use std::alloc::{alloc, dealloc, Layout}; use std::alloc::{alloc, dealloc, Layout};
// `x` is strongly protected but covers zero bytes. // `x` is strongly protected but covers zero bytes.
// Let's see if deallocating the allocation x points to is UB: // Let's see if deallocating the allocation x points to is UB:
// in TB, it is UB, but in SB it is not. // in TB, it is UB, but in SB it is not.
fn test(_x: &mut (), ptr: *mut u8, l: Layout) { fn test(_x: &mut (), ptr: *mut u8, l: Layout) {
unsafe { dealloc(ptr, l) }; unsafe { dealloc(ptr, l) }; //~[tree] ERROR: /deallocation .* is forbidden/
} }
fn main() { fn main() {

View file

@ -1,8 +1,8 @@
error: Undefined Behavior: deallocation through <TAG> (root of the allocation) at ALLOC[0x0] is forbidden 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()) } LL | unsafe { dealloc(ptr, l) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> (root of the allocation) at ALLOC[0x0] is forbidden | ^^^^^^^^^^^^^^^ 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: 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> = 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) { LL | fn test(_x: &mut (), ptr: *mut u8, l: Layout) {
| ^^ | ^^
= note: BACKTRACE (of the first span): = note: BACKTRACE (of the first span):
= note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC = note: inside `test` at $DIR/zero-sized-protected.rs:LL:CC
note: inside `test`
--> $DIR/zero-sized-protected.rs:LL:CC
|
LL | unsafe { dealloc(ptr, l) };
| ^^^^^^^^^^^^^^^
note: inside `main` note: inside `main`
--> $DIR/zero-sized-protected.rs:LL:CC --> $DIR/zero-sized-protected.rs:LL:CC
| |

View file

@ -1,6 +1,5 @@
//@error-in-other-file: memory leaked
//@normalize-stderr-test: ".*│.*" -> "$$stripped$$" //@normalize-stderr-test: ".*│.*" -> "$$stripped$$"
fn main() { fn main() {
std::mem::forget(Box::new(42)); std::mem::forget(Box::new(42)); //~ERROR: memory leaked
} }

View file

@ -1,20 +1,11 @@
error: memory leaked: ALLOC (Rust heap, size: 4, align: 4), allocated here: 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 --> $DIR/memleak.rs:LL:CC
| |
LL | std::mem::forget(Box::new(42)); 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 note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

View file

@ -1,15 +1,10 @@
error: memory leaked: ALLOC (Rust heap, SIZE, ALIGN), allocated here: 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: 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 `std::rc::Rc::<std::cell::RefCell<std::option::Option<Dummy>>>::new` at RUSTLIB/alloc/src/rc.rs:LL:CC
note: inside `main` note: inside `main`
--> $DIR/memleak_rc.rs:LL:CC --> $DIR/memleak_rc.rs:LL:CC

View file

@ -1,14 +1,12 @@
error: Undefined Behavior: deallocating while item [Unique for <TAG>] is strongly protected 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()) } LL | self.1.deallocate(From::from(ptr.cast()), layout);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating while item [Unique for <TAG>] is strongly protected | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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: 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 = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
= note: BACKTRACE: = 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::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::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 = note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC

View file

@ -1,4 +1,3 @@
//@error-in-other-file: /deallocation .* tag does not exist in the borrow stack/
use std::alloc::{alloc, dealloc, Layout}; use std::alloc::{alloc, dealloc, Layout};
fn main() { fn main() {
@ -10,5 +9,6 @@ fn main() {
ptr1.write(0); ptr1.write(0);
// Deallocate through ptr2. // Deallocate through ptr2.
dealloc(ptr2, Layout::from_size_align_unchecked(1, 1)); dealloc(ptr2, Layout::from_size_align_unchecked(1, 1));
//~^ERROR: /deallocation .* tag does not exist in the borrow stack/
} }
} }

View file

@ -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 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()) } 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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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: 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 = 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); LL | ptr1.write(0);
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
= note: BACKTRACE (of the first span): = note: BACKTRACE (of the first span):
= note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC = note: inside `main` at $DIR/illegal_deALLOC.rs:LL:CC
note: inside `main`
--> $DIR/illegal_deALLOC.rs:LL:CC
|
LL | dealloc(ptr2, Layout::from_size_align_unchecked(1, 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

View file

@ -1,4 +1,3 @@
//@error-in-other-file: memory leaked
//@normalize-stderr-test: ".*│.*" -> "$$stripped$$" //@normalize-stderr-test: ".*│.*" -> "$$stripped$$"
use std::cell::Cell; use std::cell::Cell;
@ -10,7 +9,7 @@ pub fn main() {
std::thread::spawn(|| { std::thread::spawn(|| {
TLS.with(|cell| { TLS.with(|cell| {
cell.set(Some(Box::leak(Box::new(123)))); cell.set(Some(Box::leak(Box::new(123)))); //~ERROR: memory leaked
}); });
}) })
.join() .join()

View file

@ -1,20 +1,11 @@
error: memory leaked: ALLOC (Rust heap, size: 4, align: 4), allocated here: 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 --> $DIR/tls_macro_leak.rs:LL:CC
| |
LL | cell.set(Some(Box::leak(Box::new(123)))); 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>>>::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 `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 note: inside closure

View file

@ -1,4 +1,3 @@
//@error-in-other-file: memory leaked
//@normalize-stderr-test: ".*│.*" -> "$$stripped$$" //@normalize-stderr-test: ".*│.*" -> "$$stripped$$"
#![feature(thread_local)] #![feature(thread_local)]
@ -12,7 +11,7 @@ pub fn main() {
static TLS: Cell<Option<&'static i32>> = Cell::new(None); static TLS: Cell<Option<&'static i32>> = Cell::new(None);
std::thread::spawn(|| { std::thread::spawn(|| {
TLS.set(Some(Box::leak(Box::new(123)))); TLS.set(Some(Box::leak(Box::new(123)))); //~ERROR: memory leaked
}) })
.join() .join()
.unwrap(); .unwrap();

View file

@ -1,20 +1,11 @@
error: memory leaked: ALLOC (Rust heap, size: 4, align: 4), allocated here: 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 --> $DIR/tls_static_leak.rs:LL:CC
| |
LL | TLS.set(Some(Box::leak(Box::new(123)))); 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 note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

View file

@ -1,8 +1,8 @@
error: Undefined Behavior: deallocation through <TAG> at ALLOC[0x0] is forbidden 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()) } LL | self.1.deallocate(From::from(ptr.cast()), layout);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocation through <TAG> at ALLOC[0x0] is forbidden | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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: 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> = 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)) { LL | fn inner(x: &mut i32, f: fn(*mut i32)) {
| ^ | ^
= note: BACKTRACE (of the first span): = 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::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::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 = note: inside `std::mem::drop::<std::boxed::Box<i32>>` at RUSTLIB/core/src/mem/mod.rs:LL:CC

View file

@ -67,6 +67,7 @@ change-id = 115898
[build] [build]
rustc = "{rustc}" rustc = "{rustc}"
cargo = "{cargo}" cargo = "{cargo}"
local-rebuild = true
[target.{host_triple}] [target.{host_triple}]
llvm-config = "{llvm_config}" llvm-config = "{llvm_config}"
@ -102,13 +103,7 @@ llvm-config = "{llvm_config}"
for test_path in env.skipped_tests() { for test_path in env.skipped_tests() {
args.extend(["--skip", test_path]); args.extend(["--skip", test_path]);
} }
cmd(&args) cmd(&args).env("COMPILETEST_FORCE_STAGE0", "1").run().context("Cannot execute tests")
.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")
} }
/// Tries to find the version of the dist artifacts (either nightly, beta, or 1.XY.Z). /// Tries to find the version of the dist artifacts (either nightly, beta, or 1.XY.Z).

View file

@ -1,5 +1,5 @@
error[E0229]: associated item constraints are not allowed here 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>; LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated item constraint not allowed here | ^^^^^^^^ 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 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>; LL | type A: S<C<X = 0i32> = 34>;
| ^^^^^^^^ associated item constraint not allowed here | ^^^^^^^^ associated item constraint not allowed here

View file

@ -1,4 +1,5 @@
//@ check-pass //@ check-pass
// https://github.com/rust-lang/rust/issues/110629
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]

View file

@ -1,3 +1,5 @@
// https://github.com/rust-lang/rust/issues/110629
type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>; type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>;
//~^ ERROR cycle detected when expanding type alias //~^ ERROR cycle detected when expanding type alias

View file

@ -1,5 +1,5 @@
error[E0391]: cycle detected when expanding type alias `Bar` error[E0391]: cycle detected when expanding type alias `Bar`
--> $DIR/issue-110629-private-type-cycle-dyn.rs:1:38 --> $DIR/private-type-cycle-dyn-110629.rs:3:38
| |
LL | type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>; 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: 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 = 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 note: cycle used when checking that `Bar` is well-formed
--> $DIR/issue-110629-private-type-cycle-dyn.rs:1:1 --> $DIR/private-type-cycle-dyn-110629.rs:3:1
| |
LL | type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>; LL | type Bar<'a, 'b> = Box<dyn PartialEq<Bar<'a, 'b>>>;
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^

View file

@ -1,4 +1,5 @@
// Ensuring that anonymous re-exports are always inlined. // Ensuring that anonymous re-exports are always inlined.
// https://github.com/rust-lang/rust/issues/108931
#![crate_name = "foo"] #![crate_name = "foo"]

View file

@ -1,5 +1,6 @@
// This test ensures that even if the crate module is `#[doc(hidden)]`, the file // This test ensures that even if the crate module is `#[doc(hidden)]`, the file
// is generated. // is generated.
// https://github.com/rust-lang/rust/issues/109695
//@ has 'foo/index.html' //@ has 'foo/index.html'
//@ has 'foo/all.html' //@ has 'foo/all.html'

View file

@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/100679
#![crate_name="foo"] #![crate_name="foo"]
pub struct Vec; pub struct Vec;

View file

@ -1,5 +1,6 @@
//@ aux-build: issue-113982-doc_auto_cfg-reexport-foreign.rs //@ aux-build: issue-113982-doc_auto_cfg-reexport-foreign.rs
// https://github.com/rust-lang/rust/issues/113982
#![feature(no_core, doc_auto_cfg)] #![feature(no_core, doc_auto_cfg)]
#![no_core] #![no_core]
#![crate_name = "foo"] #![crate_name = "foo"]

View file

@ -1,11 +1,13 @@
// ignore-tidy-linelength // 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 Foo'
//@ has - '//h3[@class="code-header"]' 'impl Bar for Foo' //@ has - '//h3[@class="code-header"]' 'impl Bar for Foo'
//@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 //@ count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1
//@ count - '//*[@id="main-content"]/div[@id="implementations-list"]/details/summary/*[@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' //@ has - '//h3[@class="code-header"]' 'impl Bar for Foo'
//@ count - '//*[@class="struct"]' 1 //@ count - '//*[@class="struct"]' 1
pub mod impls; pub mod impls;

View file

@ -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 { pub enum Enum {
//@ has - '//*[@id="variant.Empty"]//h3' 'Empty()' //@ has - '//*[@id="variant.Empty"]//h3' 'Empty()'
Empty(), Empty(),
} }
//@ has issue_118180_empty_tuple_struct/struct.Empty.html //@ has foo/struct.Empty.html
//@ has - '//pre/code' 'Empty()' //@ has - '//pre/code' 'Empty()'
pub struct Empty(); pub struct Empty();

View file

@ -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' 'Shown'
//@ !has - '//code' 'NotShown' //@ !has - '//code' 'NotShown'
//@ !has - '//code' '// some variants omitted' //@ !has - '//code' '// some variants omitted'

View file

@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/111249
#![crate_name = "foo"] #![crate_name = "foo"]
#![feature(no_core)] #![feature(no_core)]
#![no_core] #![no_core]

View file

@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/94683
#![crate_name = "foo"] #![crate_name = "foo"]
pub trait Trait { pub trait Trait {

View file

@ -1,8 +1,10 @@
// Make sure that we escape the arguments of the GAT projection even if we fail to compute // 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). // the href of the corresponding trait (in this case it is private).
// Further, test that we also linkify the GAT arguments. // 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"]' '<S as Tr>::P<Option<i32>>'
//@ has - '//pre[@class="rust item-decl"]//a[@class="enum"]/@href' '{{channel}}/core/option/enum.Option.html' //@ 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>>; pub type A = <S as Tr>::P<Option<i32>>;

View file

@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/115295
#![crate_name = "foo"] #![crate_name = "foo"]
//@ has foo/trait.Trait.html //@ has foo/trait.Trait.html

View file

@ -1,10 +1,12 @@
//@ compile-flags: --document-private-items //@ compile-flags: --document-private-items
// https://github.com/rust-lang/rust/issues/110629
#![crate_name="foo"]
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]
type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + std::fmt::Debug; 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"]' \ //@ has - '//pre[@class="rust item-decl"]' \
// "pub(crate) type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + Debug;" // "pub(crate) type Bar<'a, 'b> = impl PartialEq<Bar<'a, 'b>> + Debug;"

View file

@ -1,3 +1,4 @@
// Regression test for <https://github.com/rust-lang/rust/issues/111064>.
#![feature(no_core)] #![feature(no_core)]
#![no_core] #![no_core]
#![crate_name = "foo"] #![crate_name = "foo"]