Skip to content

Commit

Permalink
adjust for more backtrace pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 25, 2022
1 parent 6227e1e commit b514667
Show file tree
Hide file tree
Showing 43 changed files with 102 additions and 193 deletions.
2 changes: 1 addition & 1 deletion tests/fail/intrinsics/copy_overflow.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//@error-pattern: overflow computing total size
use std::mem;

fn main() {
let x = 0;
let mut y = 0;
unsafe {
(&mut y as *mut i32).copy_from(&x, 1usize << (mem::size_of::<usize>() * 8 - 1));
//~^ERROR: overflow computing total size
}
}
14 changes: 4 additions & 10 deletions tests/fail/intrinsics/copy_overflow.stderr
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
error: Undefined Behavior: overflow computing total size of `copy`
--> RUSTLIB/core/src/intrinsics.rs:LL:CC
--> $DIR/copy_overflow.rs:LL:CC
|
LL | copy(src, dst, count)
| ^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy`
LL | (&mut y as *mut i32).copy_from(&x, 1usize << (mem::size_of::<usize>() * 8 - 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy`
|
= 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::intrinsics::copy::<i32>` at RUSTLIB/core/src/intrinsics.rs:LL:CC
= note: inside `std::ptr::mut_ptr::<impl *mut i32>::copy_from` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
note: inside `main` at $DIR/copy_overflow.rs:LL:CC
--> $DIR/copy_overflow.rs:LL:CC
|
LL | (&mut y as *mut i32).copy_from(&x, 1usize << (mem::size_of::<usize>() * 8 - 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: inside `main` at $DIR/copy_overflow.rs:LL:CC

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

Expand Down
3 changes: 1 addition & 2 deletions tests/fail/intrinsics/out_of_bounds_ptr_1.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//@error-pattern: pointer to 5 bytes starting at offset 0 is out-of-bounds
fn main() {
let v = [0i8; 4];
let x = &v as *const i8;
// The error is inside another function, so we cannot match it by line
let x = unsafe { x.offset(5) };
let x = unsafe { x.offset(5) }; //~ERROR: pointer to 5 bytes starting at offset 0 is out-of-bounds
panic!("this should never print: {:?}", x);
}
13 changes: 4 additions & 9 deletions tests/fail/intrinsics/out_of_bounds_ptr_1.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
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
--> RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
--> $DIR/out_of_bounds_ptr_1.rs:LL:CC
|
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 5 bytes starting at offset 0 is out-of-bounds
LL | let x = unsafe { x.offset(5) };
| ^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 5 bytes starting at offset 0 is out-of-bounds
|
= 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::ptr::const_ptr::<impl *const i8>::offset` at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
note: inside `main` at $DIR/out_of_bounds_ptr_1.rs:LL:CC
--> $DIR/out_of_bounds_ptr_1.rs:LL:CC
|
LL | let x = unsafe { x.offset(5) };
| ^^^^^^^^^^^
= note: inside `main` at $DIR/out_of_bounds_ptr_1.rs:LL:CC

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

Expand Down
3 changes: 1 addition & 2 deletions tests/fail/intrinsics/out_of_bounds_ptr_2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@error-pattern: overflowing in-bounds pointer arithmetic
fn main() {
let v = [0i8; 4];
let x = &v as *const i8;
let x = unsafe { x.offset(isize::MIN) };
let x = unsafe { x.offset(isize::MIN) }; //~ERROR: overflowing in-bounds pointer arithmetic
panic!("this should never print: {:?}", x);
}
13 changes: 4 additions & 9 deletions tests/fail/intrinsics/out_of_bounds_ptr_2.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
error: Undefined Behavior: overflowing in-bounds pointer arithmetic
--> RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
--> $DIR/out_of_bounds_ptr_2.rs:LL:CC
|
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing in-bounds pointer arithmetic
LL | let x = unsafe { x.offset(isize::MIN) };
| ^^^^^^^^^^^^^^^^^^^^ overflowing in-bounds pointer arithmetic
|
= 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::ptr::const_ptr::<impl *const i8>::offset` at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
note: inside `main` at $DIR/out_of_bounds_ptr_2.rs:LL:CC
--> $DIR/out_of_bounds_ptr_2.rs:LL:CC
|
LL | let x = unsafe { x.offset(isize::MIN) };
| ^^^^^^^^^^^^^^^^^^^^
= note: inside `main` at $DIR/out_of_bounds_ptr_2.rs:LL:CC

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

Expand Down
3 changes: 1 addition & 2 deletions tests/fail/intrinsics/out_of_bounds_ptr_3.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@error-pattern: pointer to 1 byte starting at offset -1 is out-of-bounds
fn main() {
let v = [0i8; 4];
let x = &v as *const i8;
let x = unsafe { x.offset(-1) };
let x = unsafe { x.offset(-1) }; //~ERROR: pointer to 1 byte starting at offset -1 is out-of-bounds
panic!("this should never print: {:?}", x);
}
13 changes: 4 additions & 9 deletions tests/fail/intrinsics/out_of_bounds_ptr_3.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
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
--> RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
--> $DIR/out_of_bounds_ptr_3.rs:LL:CC
|
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 1 byte starting at offset -1 is out-of-bounds
LL | let x = unsafe { x.offset(-1) };
| ^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer to 1 byte starting at offset -1 is out-of-bounds
|
= 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::ptr::const_ptr::<impl *const i8>::offset` at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
note: inside `main` at $DIR/out_of_bounds_ptr_3.rs:LL:CC
--> $DIR/out_of_bounds_ptr_3.rs:LL:CC
|
LL | let x = unsafe { x.offset(-1) };
| ^^^^^^^^^^^^
= note: inside `main` at $DIR/out_of_bounds_ptr_3.rs:LL:CC

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

Expand Down
6 changes: 2 additions & 4 deletions tests/fail/intrinsics/overflowing-unchecked-rsh.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#![feature(core_intrinsics)]

use std::intrinsics::*;
#![feature(unchecked_math)]

fn main() {
unsafe {
let _n = unchecked_shr(1i64, 64);
let _n = 1i64.unchecked_shr(64);
//~^ ERROR: overflowing shift by 64 in `unchecked_shr`
}
}
4 changes: 2 additions & 2 deletions tests/fail/intrinsics/overflowing-unchecked-rsh.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: Undefined Behavior: overflowing shift by 64 in `unchecked_shr`
--> $DIR/overflowing-unchecked-rsh.rs:LL:CC
|
LL | let _n = unchecked_shr(1i64, 64);
| ^^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shr`
LL | let _n = 1i64.unchecked_shr(64);
| ^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shr`
|
= 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
Expand Down
3 changes: 2 additions & 1 deletion tests/fail/intrinsics/ptr_offset_0_plus_0.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//@error-pattern: null pointer is a dangling pointer
//@compile-flags: -Zmiri-permissive-provenance

#[rustfmt::skip] // fails with "left behind trailing whitespace"
fn main() {
let x = 0 as *mut i32;
let _x = x.wrapping_offset(8); // ok, this has no inbounds tag
let _x = unsafe { x.offset(0) }; // UB despite offset 0, NULL is never inbounds
//~^ERROR: null pointer is a dangling pointer
}
13 changes: 4 additions & 9 deletions tests/fail/intrinsics/ptr_offset_0_plus_0.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
error: Undefined Behavior: out-of-bounds pointer arithmetic: null pointer is a dangling pointer (it has no provenance)
--> RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
--> $DIR/ptr_offset_0_plus_0.rs:LL:CC
|
LL | unsafe { intrinsics::offset(self, count) as *mut T }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: null pointer is a dangling pointer (it has no provenance)
LL | let _x = unsafe { x.offset(0) }; // UB despite offset 0, NULL is never inbounds
| ^^^^^^^^^^^ out-of-bounds pointer arithmetic: null pointer is a dangling pointer (it has no provenance)
|
= 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::ptr::mut_ptr::<impl *mut i32>::offset` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
note: inside `main` at $DIR/ptr_offset_0_plus_0.rs:LL:CC
--> $DIR/ptr_offset_0_plus_0.rs:LL:CC
|
LL | let _x = unsafe { x.offset(0) }; // UB despite offset 0, NULL is never inbounds
| ^^^^^^^^^^^
= note: inside `main` at $DIR/ptr_offset_0_plus_0.rs:LL:CC

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

Expand Down
6 changes: 1 addition & 5 deletions tests/fail/intrinsics/ptr_offset_from_oob.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#![feature(core_intrinsics)]

use std::intrinsics::ptr_offset_from;

fn main() {
let start_ptr = &4 as *const _ as *const u8;
let length = 10;
let end_ptr = start_ptr.wrapping_add(length);
// Even if the offset is 0, a dangling OOB pointer is not allowed.
unsafe { ptr_offset_from(end_ptr, end_ptr) }; //~ERROR: pointer at offset 10 is out-of-bounds
unsafe { end_ptr.offset_from(end_ptr) }; //~ERROR: pointer at offset 10 is out-of-bounds
}
4 changes: 2 additions & 2 deletions tests/fail/intrinsics/ptr_offset_from_oob.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: Undefined Behavior: out-of-bounds offset_from: ALLOC has size 4, so pointer at offset 10 is out-of-bounds
--> $DIR/ptr_offset_from_oob.rs:LL:CC
|
LL | unsafe { ptr_offset_from(end_ptr, end_ptr) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: ALLOC has size 4, so pointer at offset 10 is out-of-bounds
LL | unsafe { end_ptr.offset_from(end_ptr) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: ALLOC has size 4, so pointer at offset 10 is out-of-bounds
|
= 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
Expand Down
3 changes: 1 addition & 2 deletions tests/fail/intrinsics/ptr_offset_int_plus_int.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//@error-pattern: is a dangling pointer
//@compile-flags: -Zmiri-permissive-provenance

fn main() {
// Can't offset an integer pointer by non-zero offset.
unsafe {
let _val = (1 as *mut u8).offset(1);
let _val = (1 as *mut u8).offset(1); //~ERROR: is a dangling pointer
}
}
13 changes: 4 additions & 9 deletions tests/fail/intrinsics/ptr_offset_int_plus_int.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
error: Undefined Behavior: out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance)
--> RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
--> $DIR/ptr_offset_int_plus_int.rs:LL:CC
|
LL | unsafe { intrinsics::offset(self, count) as *mut T }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance)
LL | let _val = (1 as *mut u8).offset(1);
| ^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance)
|
= 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::ptr::mut_ptr::<impl *mut u8>::offset` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
note: inside `main` at $DIR/ptr_offset_int_plus_int.rs:LL:CC
--> $DIR/ptr_offset_int_plus_int.rs:LL:CC
|
LL | let _val = (1 as *mut u8).offset(1);
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: inside `main` at $DIR/ptr_offset_int_plus_int.rs:LL:CC

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

Expand Down
3 changes: 1 addition & 2 deletions tests/fail/intrinsics/ptr_offset_int_plus_ptr.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//@error-pattern: is a dangling pointer
//@compile-flags: -Zmiri-permissive-provenance

fn main() {
let ptr = Box::into_raw(Box::new(0u32));
// Can't start with an integer pointer and get to something usable
unsafe {
let _val = (1 as *mut u8).offset(ptr as isize);
let _val = (1 as *mut u8).offset(ptr as isize); //~ERROR: is a dangling pointer
}
}
13 changes: 4 additions & 9 deletions tests/fail/intrinsics/ptr_offset_int_plus_ptr.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
error: Undefined Behavior: out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance)
--> RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
--> $DIR/ptr_offset_int_plus_ptr.rs:LL:CC
|
LL | unsafe { intrinsics::offset(self, count) as *mut T }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance)
LL | let _val = (1 as *mut u8).offset(ptr as isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: 0x1[noalloc] is a dangling pointer (it has no provenance)
|
= 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::ptr::mut_ptr::<impl *mut u8>::offset` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
note: inside `main` at $DIR/ptr_offset_int_plus_ptr.rs:LL:CC
--> $DIR/ptr_offset_int_plus_ptr.rs:LL:CC
|
LL | let _val = (1 as *mut u8).offset(ptr as isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: inside `main` at $DIR/ptr_offset_int_plus_ptr.rs:LL:CC

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

Expand Down
3 changes: 1 addition & 2 deletions tests/fail/intrinsics/ptr_offset_overflow.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//@error-pattern: overflowing in-bounds pointer arithmetic
fn main() {
let v = [1i8, 2];
let x = &v[1] as *const i8;
let _val = unsafe { x.offset(isize::MIN) };
let _val = unsafe { x.offset(isize::MIN) }; //~ERROR: overflowing in-bounds pointer arithmetic
}
13 changes: 4 additions & 9 deletions tests/fail/intrinsics/ptr_offset_overflow.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
error: Undefined Behavior: overflowing in-bounds pointer arithmetic
--> RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
--> $DIR/ptr_offset_overflow.rs:LL:CC
|
LL | unsafe { intrinsics::offset(self, count) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflowing in-bounds pointer arithmetic
LL | let _val = unsafe { x.offset(isize::MIN) };
| ^^^^^^^^^^^^^^^^^^^^ overflowing in-bounds pointer arithmetic
|
= 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::ptr::const_ptr::<impl *const i8>::offset` at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC
note: inside `main` at $DIR/ptr_offset_overflow.rs:LL:CC
--> $DIR/ptr_offset_overflow.rs:LL:CC
|
LL | let _val = unsafe { x.offset(isize::MIN) };
| ^^^^^^^^^^^^^^^^^^^^
= note: inside `main` at $DIR/ptr_offset_overflow.rs:LL:CC

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

Expand Down
4 changes: 2 additions & 2 deletions tests/fail/intrinsics/ptr_offset_ptr_plus_0.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@error-pattern: pointer at offset 32 is out-of-bounds

#[rustfmt::skip] // fails with "left behind trailing whitespace"
fn main() {
let x = Box::into_raw(Box::new(0u32));
let x = x.wrapping_offset(8); // ok, this has no inbounds tag
let _x = unsafe { x.offset(0) }; // UB despite offset 0, the pointer is not inbounds of the only object it can point to
//~^ERROR: pointer at offset 32 is out-of-bounds
}
13 changes: 4 additions & 9 deletions tests/fail/intrinsics/ptr_offset_ptr_plus_0.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
error: Undefined Behavior: out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer at offset 32 is out-of-bounds
--> RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
--> $DIR/ptr_offset_ptr_plus_0.rs:LL:CC
|
LL | unsafe { intrinsics::offset(self, count) as *mut T }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer at offset 32 is out-of-bounds
LL | let _x = unsafe { x.offset(0) }; // UB despite offset 0, the pointer is not inbounds of the only object it can point to
| ^^^^^^^^^^^ out-of-bounds pointer arithmetic: ALLOC has size 4, so pointer at offset 32 is out-of-bounds
|
= 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::ptr::mut_ptr::<impl *mut u32>::offset` at RUSTLIB/core/src/ptr/mut_ptr.rs:LL:CC
note: inside `main` at $DIR/ptr_offset_ptr_plus_0.rs:LL:CC
--> $DIR/ptr_offset_ptr_plus_0.rs:LL:CC
|
LL | let _x = unsafe { x.offset(0) }; // UB despite offset 0, the pointer is not inbounds of the only object it can point to
| ^^^^^^^^^^^
= note: inside `main` at $DIR/ptr_offset_ptr_plus_0.rs:LL:CC

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

Expand Down
7 changes: 3 additions & 4 deletions tests/fail/intrinsics/unchecked_add1.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![feature(core_intrinsics)]
#![feature(unchecked_math)]

fn main() {
// MAX overflow
unsafe {
std::intrinsics::unchecked_add(40000u16, 30000); //~ ERROR: overflow executing `unchecked_add`
}
let _val = unsafe { 40000u16.unchecked_add(30000) }; //~ ERROR: overflow executing `unchecked_add`
}
4 changes: 2 additions & 2 deletions tests/fail/intrinsics/unchecked_add1.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: Undefined Behavior: overflow executing `unchecked_add`
--> $DIR/unchecked_add1.rs:LL:CC
|
LL | std::intrinsics::unchecked_add(40000u16, 30000);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_add`
LL | let _val = unsafe { 40000u16.unchecked_add(30000) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_add`
|
= 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
Expand Down
7 changes: 3 additions & 4 deletions tests/fail/intrinsics/unchecked_add2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![feature(core_intrinsics)]
#![feature(unchecked_math)]

fn main() {
// MIN overflow
unsafe {
std::intrinsics::unchecked_add(-30000i16, -8000); //~ ERROR: overflow executing `unchecked_add`
}
let _val = unsafe { (-30000i16).unchecked_add(-8000) }; //~ ERROR: overflow executing `unchecked_add`
}
4 changes: 2 additions & 2 deletions tests/fail/intrinsics/unchecked_add2.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: Undefined Behavior: overflow executing `unchecked_add`
--> $DIR/unchecked_add2.rs:LL:CC
|
LL | std::intrinsics::unchecked_add(-30000i16, -8000);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_add`
LL | let _val = unsafe { (-30000i16).unchecked_add(-8000) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_add`
|
= 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
Expand Down
Loading

0 comments on commit b514667

Please sign in to comment.