Skip to content

Commit 30e8618

Browse files
committed
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
2 parents b2f11d6 + 144f401 commit 30e8618

26 files changed

+65
-156
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use std::alloc::{alloc, dealloc, Layout};
22

3-
//@error-in-other-file: has size 1 and alignment 1, but gave size 1 and alignment 2
4-
53
fn main() {
64
unsafe {
75
let x = alloc(Layout::from_size_align_unchecked(1, 1));
8-
dealloc(x, Layout::from_size_align_unchecked(1, 2));
6+
dealloc(x, Layout::from_size_align_unchecked(1, 2)); //~ERROR: has size 1 and alignment 1, but gave size 1 and alignment 2
97
}
108
}

tests/fail/alloc/deallocate-bad-alignment.stderr

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 1 and alignment ALIGN
2-
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
2+
--> $DIR/deallocate-bad-alignment.rs:LL:CC
33
|
4-
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 1 and alignment ALIGN
4+
LL | dealloc(x, Layout::from_size_align_unchecked(1, 2));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 1 and alignment ALIGN
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: BACKTRACE:
10-
= note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
11-
note: inside `main`
12-
--> $DIR/deallocate-bad-alignment.rs:LL:CC
13-
|
14-
LL | dealloc(x, Layout::from_size_align_unchecked(1, 2));
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
= note: inside `main` at $DIR/deallocate-bad-alignment.rs:LL:CC
1611

1712
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1813

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use std::alloc::{alloc, dealloc, Layout};
22

3-
//@error-in-other-file: has size 1 and alignment 1, but gave size 2 and alignment 1
4-
53
fn main() {
64
unsafe {
75
let x = alloc(Layout::from_size_align_unchecked(1, 1));
8-
dealloc(x, Layout::from_size_align_unchecked(2, 1));
6+
dealloc(x, Layout::from_size_align_unchecked(2, 1)); //~ERROR: has size 1 and alignment 1, but gave size 2 and alignment 1
97
}
108
}

tests/fail/alloc/deallocate-bad-size.stderr

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
2-
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
2+
--> $DIR/deallocate-bad-size.rs:LL:CC
33
|
4-
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
4+
LL | dealloc(x, Layout::from_size_align_unchecked(2, 1));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: BACKTRACE:
10-
= note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
11-
note: inside `main`
12-
--> $DIR/deallocate-bad-size.rs:LL:CC
13-
|
14-
LL | dealloc(x, Layout::from_size_align_unchecked(2, 1));
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
= note: inside `main` at $DIR/deallocate-bad-size.rs:LL:CC
1611

1712
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1813

tests/fail/alloc/deallocate-twice.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
use std::alloc::{alloc, dealloc, Layout};
22

3-
//@error-in-other-file: has been freed
4-
53
fn main() {
64
unsafe {
75
let x = alloc(Layout::from_size_align_unchecked(1, 1));
86
dealloc(x, Layout::from_size_align_unchecked(1, 1));
9-
dealloc(x, Layout::from_size_align_unchecked(1, 1));
7+
dealloc(x, Layout::from_size_align_unchecked(1, 1)); //~ERROR: has been freed
108
}
119
}

tests/fail/alloc/deallocate-twice.stderr

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: memory access failed: ALLOC has been freed, so this pointer is dangling
2-
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
2+
--> $DIR/deallocate-twice.rs:LL:CC
33
|
4-
LL | unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
4+
LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= 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:
1717
LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1919
= note: BACKTRACE (of the first span):
20-
= note: inside `std::alloc::dealloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
21-
note: inside `main`
22-
--> $DIR/deallocate-twice.rs:LL:CC
23-
|
24-
LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
25-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
= note: inside `main` at $DIR/deallocate-twice.rs:LL:CC
2621

2722
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2823

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use std::alloc::{alloc, realloc, Layout};
22

3-
//@error-in-other-file: has size 1 and alignment 1, but gave size 2 and alignment 1
4-
53
fn main() {
64
unsafe {
75
let x = alloc(Layout::from_size_align_unchecked(1, 1));
8-
let _y = realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
6+
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
97
}
108
}

tests/fail/alloc/reallocate-bad-size.stderr

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
error: Undefined Behavior: incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
2-
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
2+
--> $DIR/reallocate-bad-size.rs:LL:CC
33
|
4-
LL | unsafe { __rust_realloc(ptr, layout.size(), layout.align(), new_size) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
4+
LL | let _y = realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect layout on deallocation: ALLOC has size 1 and alignment ALIGN, but gave size 2 and alignment ALIGN
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
99
= note: BACKTRACE:
10-
= note: inside `std::alloc::realloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
11-
note: inside `main`
12-
--> $DIR/reallocate-bad-size.rs:LL:CC
13-
|
14-
LL | let _y = realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
15-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
= note: inside `main` at $DIR/reallocate-bad-size.rs:LL:CC
1611

1712
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
1813

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
use std::alloc::{alloc, dealloc, realloc, Layout};
22

3-
//@error-in-other-file: has been freed
4-
53
fn main() {
64
unsafe {
75
let x = alloc(Layout::from_size_align_unchecked(1, 1));
86
dealloc(x, Layout::from_size_align_unchecked(1, 1));
9-
let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
7+
let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1); //~ERROR: has been freed
108
}
119
}

tests/fail/alloc/reallocate-dangling.stderr

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: memory access failed: ALLOC has been freed, so this pointer is dangling
2-
--> RUSTLIB/alloc/src/alloc.rs:LL:CC
2+
--> $DIR/reallocate-dangling.rs:LL:CC
33
|
4-
LL | unsafe { __rust_realloc(ptr, layout.size(), layout.align(), new_size) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
4+
LL | let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: ALLOC has been freed, so this pointer is dangling
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= 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:
1717
LL | dealloc(x, Layout::from_size_align_unchecked(1, 1));
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1919
= note: BACKTRACE (of the first span):
20-
= note: inside `std::alloc::realloc` at RUSTLIB/alloc/src/alloc.rs:LL:CC
21-
note: inside `main`
22-
--> $DIR/reallocate-dangling.rs:LL:CC
23-
|
24-
LL | let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
25-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
= note: inside `main` at $DIR/reallocate-dangling.rs:LL:CC
2621

2722
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
2823

0 commit comments

Comments
 (0)