Skip to content

Commit 35252eb

Browse files
committed
Auto merge of #2438 - RalfJung:more-track-caller, r=RalfJung
adjust for more backtrace pruning The Miri side of rust-lang/rust#99690. Those messages are much nicer. :) And we also need error-pattern much less.
2 parents 6227e1e + 982979e commit 35252eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+110
-205
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7fe022f5aa32bbbb33c3a58755729d6667a461a9
1+
2fdbf075cf502431ca9fee6616331b32e34f25de
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//@error-pattern: overflow computing total size
21
use std::mem;
32

43
fn main() {
54
let x = 0;
65
let mut y = 0;
76
unsafe {
87
(&mut y as *mut i32).copy_from(&x, 1usize << (mem::size_of::<usize>() * 8 - 1));
8+
//~^ERROR: overflow computing total size
99
}
1010
}

tests/fail/intrinsics/copy_overflow.stderr

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
error: Undefined Behavior: overflow computing total size of `copy`
2-
--> RUSTLIB/core/src/intrinsics.rs:LL:CC
2+
--> $DIR/copy_overflow.rs:LL:CC
33
|
4-
LL | copy(src, dst, count)
5-
| ^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy`
4+
LL | (&mut y as *mut i32).copy_from(&x, 1usize << (mem::size_of::<usize>() * 8 - 1));
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy`
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::intrinsics::copy::<i32>` at RUSTLIB/core/src/intrinsics.rs:LL:CC
11-
= note: inside `std::ptr::mut_ptr::<impl *mut i32>::copy_from` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
12-
note: inside `main` at $DIR/copy_overflow.rs:LL:CC
13-
--> $DIR/copy_overflow.rs:LL:CC
14-
|
15-
LL | (&mut y as *mut i32).copy_from(&x, 1usize << (mem::size_of::<usize>() * 8 - 1));
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
= note: inside `main` at $DIR/copy_overflow.rs:LL:CC
1711

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
//@error-pattern: pointer to 5 bytes starting at offset 0 is out-of-bounds
21
fn main() {
32
let v = [0i8; 4];
43
let x = &v as *const i8;
54
// The error is inside another function, so we cannot match it by line
6-
let x = unsafe { x.offset(5) };
5+
let x = unsafe { x.offset(5) }; //~ERROR: pointer to 5 bytes starting at offset 0 is out-of-bounds
76
panic!("this should never print: {:?}", x);
87
}

tests/fail/intrinsics/out_of_bounds_ptr_1.stderr

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
error: Undefined Behavior: out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 5 bytes starting at offset 0 is out-of-bounds
2-
--> RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
2+
--> $DIR/out_of_bounds_ptr_1.rs:LL:CC
33
|
4-
LL | unsafe { intrinsics::offset(self, count) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 5 bytes starting at offset 0 is out-of-bounds
4+
LL | let x = unsafe { x.offset(5) };
5+
| ^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 5 bytes starting at offset 0 is out-of-bounds
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::ptr::const_ptr::<impl *const i8>::offset` at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
11-
note: inside `main` at $DIR/out_of_bounds_ptr_1.rs:LL:CC
12-
--> $DIR/out_of_bounds_ptr_1.rs:LL:CC
13-
|
14-
LL | let x = unsafe { x.offset(5) };
15-
| ^^^^^^^^^^^
10+
= note: inside `main` at $DIR/out_of_bounds_ptr_1.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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
//@error-pattern: overflowing in-bounds pointer arithmetic
21
fn main() {
32
let v = [0i8; 4];
43
let x = &v as *const i8;
5-
let x = unsafe { x.offset(isize::MIN) };
4+
let x = unsafe { x.offset(isize::MIN) }; //~ERROR: overflowing in-bounds pointer arithmetic
65
panic!("this should never print: {:?}", x);
76
}

tests/fail/intrinsics/out_of_bounds_ptr_2.stderr

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
error: Undefined Behavior: overflowing in-bounds pointer arithmetic
2-
--> RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
2+
--> $DIR/out_of_bounds_ptr_2.rs:LL:CC
33
|
4-
LL | unsafe { intrinsics::offset(self, count) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing in-bounds pointer arithmetic
4+
LL | let x = unsafe { x.offset(isize::MIN) };
5+
| ^^^^^^^^^^^^^^^^^^^^ overflowing in-bounds pointer arithmetic
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::ptr::const_ptr::<impl *const i8>::offset` at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
11-
note: inside `main` at $DIR/out_of_bounds_ptr_2.rs:LL:CC
12-
--> $DIR/out_of_bounds_ptr_2.rs:LL:CC
13-
|
14-
LL | let x = unsafe { x.offset(isize::MIN) };
15-
| ^^^^^^^^^^^^^^^^^^^^
10+
= note: inside `main` at $DIR/out_of_bounds_ptr_2.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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
//@error-pattern: pointer to 1 byte starting at offset -1 is out-of-bounds
21
fn main() {
32
let v = [0i8; 4];
43
let x = &v as *const i8;
5-
let x = unsafe { x.offset(-1) };
4+
let x = unsafe { x.offset(-1) }; //~ERROR: pointer to 1 byte starting at offset -1 is out-of-bounds
65
panic!("this should never print: {:?}", x);
76
}

tests/fail/intrinsics/out_of_bounds_ptr_3.stderr

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
error: Undefined Behavior: out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 1 byte starting at offset -1 is out-of-bounds
2-
--> RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
2+
--> $DIR/out_of_bounds_ptr_3.rs:LL:CC
33
|
4-
LL | unsafe { intrinsics::offset(self, count) }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 1 byte starting at offset -1 is out-of-bounds
4+
LL | let x = unsafe { x.offset(-1) };
5+
| ^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 1 byte starting at offset -1 is out-of-bounds
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::ptr::const_ptr::<impl *const i8>::offset` at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
11-
note: inside `main` at $DIR/out_of_bounds_ptr_3.rs:LL:CC
12-
--> $DIR/out_of_bounds_ptr_3.rs:LL:CC
13-
|
14-
LL | let x = unsafe { x.offset(-1) };
15-
| ^^^^^^^^^^^^
10+
= note: inside `main` at $DIR/out_of_bounds_ptr_3.rs:LL:CC
1611

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
#![feature(core_intrinsics)]
2-
3-
use std::intrinsics::*;
1+
#![feature(unchecked_math)]
42

53
fn main() {
64
unsafe {
7-
let _n = unchecked_shr(1i64, 64);
5+
let _n = 1i64.unchecked_shr(64);
86
//~^ ERROR: overflowing shift by 64 in `unchecked_shr`
97
}
108
}

0 commit comments

Comments
 (0)