From b514667c36f559317a316a5d9b8cd019328be581 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 24 Jul 2022 14:28:45 -0400 Subject: [PATCH] adjust for more backtrace pruning --- tests/fail/intrinsics/copy_overflow.rs | 2 +- tests/fail/intrinsics/copy_overflow.stderr | 14 ++++---------- tests/fail/intrinsics/out_of_bounds_ptr_1.rs | 3 +-- tests/fail/intrinsics/out_of_bounds_ptr_1.stderr | 13 ++++--------- tests/fail/intrinsics/out_of_bounds_ptr_2.rs | 3 +-- tests/fail/intrinsics/out_of_bounds_ptr_2.stderr | 13 ++++--------- tests/fail/intrinsics/out_of_bounds_ptr_3.rs | 3 +-- tests/fail/intrinsics/out_of_bounds_ptr_3.stderr | 13 ++++--------- tests/fail/intrinsics/overflowing-unchecked-rsh.rs | 6 ++---- .../intrinsics/overflowing-unchecked-rsh.stderr | 4 ++-- tests/fail/intrinsics/ptr_offset_0_plus_0.rs | 3 ++- tests/fail/intrinsics/ptr_offset_0_plus_0.stderr | 13 ++++--------- tests/fail/intrinsics/ptr_offset_from_oob.rs | 6 +----- tests/fail/intrinsics/ptr_offset_from_oob.stderr | 4 ++-- tests/fail/intrinsics/ptr_offset_int_plus_int.rs | 3 +-- .../fail/intrinsics/ptr_offset_int_plus_int.stderr | 13 ++++--------- tests/fail/intrinsics/ptr_offset_int_plus_ptr.rs | 3 +-- .../fail/intrinsics/ptr_offset_int_plus_ptr.stderr | 13 ++++--------- tests/fail/intrinsics/ptr_offset_overflow.rs | 3 +-- tests/fail/intrinsics/ptr_offset_overflow.stderr | 13 ++++--------- tests/fail/intrinsics/ptr_offset_ptr_plus_0.rs | 4 ++-- tests/fail/intrinsics/ptr_offset_ptr_plus_0.stderr | 13 ++++--------- tests/fail/intrinsics/unchecked_add1.rs | 7 +++---- tests/fail/intrinsics/unchecked_add1.stderr | 4 ++-- tests/fail/intrinsics/unchecked_add2.rs | 7 +++---- tests/fail/intrinsics/unchecked_add2.stderr | 4 ++-- tests/fail/intrinsics/unchecked_mul1.rs | 6 ++---- tests/fail/intrinsics/unchecked_mul1.stderr | 4 ++-- tests/fail/intrinsics/unchecked_mul2.rs | 6 ++---- tests/fail/intrinsics/unchecked_mul2.stderr | 4 ++-- tests/fail/intrinsics/unchecked_sub1.rs | 6 ++---- tests/fail/intrinsics/unchecked_sub1.stderr | 4 ++-- tests/fail/intrinsics/unchecked_sub2.rs | 6 ++---- tests/fail/intrinsics/unchecked_sub2.stderr | 4 ++-- tests/fail/invalid_enum_tag.rs | 4 +--- tests/fail/invalid_enum_tag.stderr | 13 ++++--------- tests/fail/provenance/ptr_invalid_offset.rs | 3 +-- tests/fail/provenance/ptr_invalid_offset.stderr | 13 ++++--------- tests/fail/should-pass/cpp20_rwc_syncs.rs | 3 +-- tests/fail/should-pass/cpp20_rwc_syncs.stderr | 13 ++++--------- tests/fail/unreachable.rs | 3 +-- tests/fail/unreachable.stderr | 13 ++++--------- tests/fail/weak_memory/racing_mixed_size.rs | 3 ++- 43 files changed, 102 insertions(+), 193 deletions(-) diff --git a/tests/fail/intrinsics/copy_overflow.rs b/tests/fail/intrinsics/copy_overflow.rs index c4ce192c449c..e64a1f909021 100644 --- a/tests/fail/intrinsics/copy_overflow.rs +++ b/tests/fail/intrinsics/copy_overflow.rs @@ -1,4 +1,3 @@ -//@error-pattern: overflow computing total size use std::mem; fn main() { @@ -6,5 +5,6 @@ fn main() { let mut y = 0; unsafe { (&mut y as *mut i32).copy_from(&x, 1usize << (mem::size_of::() * 8 - 1)); + //~^ERROR: overflow computing total size } } diff --git a/tests/fail/intrinsics/copy_overflow.stderr b/tests/fail/intrinsics/copy_overflow.stderr index 76917ae7ea15..3534f4d1fb85 100644 --- a/tests/fail/intrinsics/copy_overflow.stderr +++ b/tests/fail/intrinsics/copy_overflow.stderr @@ -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::() * 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::` at RUSTLIB/core/src/intrinsics.rs:LL:CC - = note: inside `std::ptr::mut_ptr::::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::() * 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 diff --git a/tests/fail/intrinsics/out_of_bounds_ptr_1.rs b/tests/fail/intrinsics/out_of_bounds_ptr_1.rs index 0109bff69688..b6a110ee84d2 100644 --- a/tests/fail/intrinsics/out_of_bounds_ptr_1.rs +++ b/tests/fail/intrinsics/out_of_bounds_ptr_1.rs @@ -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); } diff --git a/tests/fail/intrinsics/out_of_bounds_ptr_1.stderr b/tests/fail/intrinsics/out_of_bounds_ptr_1.stderr index 789e9d1f6cbe..afa2c8306466 100644 --- a/tests/fail/intrinsics/out_of_bounds_ptr_1.stderr +++ b/tests/fail/intrinsics/out_of_bounds_ptr_1.stderr @@ -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::::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 diff --git a/tests/fail/intrinsics/out_of_bounds_ptr_2.rs b/tests/fail/intrinsics/out_of_bounds_ptr_2.rs index 74d391dc2120..0d4eea9a5bde 100644 --- a/tests/fail/intrinsics/out_of_bounds_ptr_2.rs +++ b/tests/fail/intrinsics/out_of_bounds_ptr_2.rs @@ -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); } diff --git a/tests/fail/intrinsics/out_of_bounds_ptr_2.stderr b/tests/fail/intrinsics/out_of_bounds_ptr_2.stderr index 70ce2dc02a82..a32b50a18e6a 100644 --- a/tests/fail/intrinsics/out_of_bounds_ptr_2.stderr +++ b/tests/fail/intrinsics/out_of_bounds_ptr_2.stderr @@ -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::::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 diff --git a/tests/fail/intrinsics/out_of_bounds_ptr_3.rs b/tests/fail/intrinsics/out_of_bounds_ptr_3.rs index b54cf3dd25c0..701bc33a645e 100644 --- a/tests/fail/intrinsics/out_of_bounds_ptr_3.rs +++ b/tests/fail/intrinsics/out_of_bounds_ptr_3.rs @@ -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); } diff --git a/tests/fail/intrinsics/out_of_bounds_ptr_3.stderr b/tests/fail/intrinsics/out_of_bounds_ptr_3.stderr index 973bf043e155..d06c33beb48a 100644 --- a/tests/fail/intrinsics/out_of_bounds_ptr_3.stderr +++ b/tests/fail/intrinsics/out_of_bounds_ptr_3.stderr @@ -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::::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 diff --git a/tests/fail/intrinsics/overflowing-unchecked-rsh.rs b/tests/fail/intrinsics/overflowing-unchecked-rsh.rs index 958a9f90ed98..fe2e85be6986 100644 --- a/tests/fail/intrinsics/overflowing-unchecked-rsh.rs +++ b/tests/fail/intrinsics/overflowing-unchecked-rsh.rs @@ -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` } } diff --git a/tests/fail/intrinsics/overflowing-unchecked-rsh.stderr b/tests/fail/intrinsics/overflowing-unchecked-rsh.stderr index 705ae01188b8..bba92602285a 100644 --- a/tests/fail/intrinsics/overflowing-unchecked-rsh.stderr +++ b/tests/fail/intrinsics/overflowing-unchecked-rsh.stderr @@ -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 diff --git a/tests/fail/intrinsics/ptr_offset_0_plus_0.rs b/tests/fail/intrinsics/ptr_offset_0_plus_0.rs index 32974a825a54..e2329c131398 100644 --- a/tests/fail/intrinsics/ptr_offset_0_plus_0.rs +++ b/tests/fail/intrinsics/ptr_offset_0_plus_0.rs @@ -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 } diff --git a/tests/fail/intrinsics/ptr_offset_0_plus_0.stderr b/tests/fail/intrinsics/ptr_offset_0_plus_0.stderr index cb9b02c84051..40a5022351dd 100644 --- a/tests/fail/intrinsics/ptr_offset_0_plus_0.stderr +++ b/tests/fail/intrinsics/ptr_offset_0_plus_0.stderr @@ -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::::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 diff --git a/tests/fail/intrinsics/ptr_offset_from_oob.rs b/tests/fail/intrinsics/ptr_offset_from_oob.rs index 1fd5100a97b9..0e5acf08b203 100644 --- a/tests/fail/intrinsics/ptr_offset_from_oob.rs +++ b/tests/fail/intrinsics/ptr_offset_from_oob.rs @@ -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 } diff --git a/tests/fail/intrinsics/ptr_offset_from_oob.stderr b/tests/fail/intrinsics/ptr_offset_from_oob.stderr index 699ca1a87ae8..546245a499e1 100644 --- a/tests/fail/intrinsics/ptr_offset_from_oob.stderr +++ b/tests/fail/intrinsics/ptr_offset_from_oob.stderr @@ -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 diff --git a/tests/fail/intrinsics/ptr_offset_int_plus_int.rs b/tests/fail/intrinsics/ptr_offset_int_plus_int.rs index f51e00746e2f..19bd265c1435 100644 --- a/tests/fail/intrinsics/ptr_offset_int_plus_int.rs +++ b/tests/fail/intrinsics/ptr_offset_int_plus_int.rs @@ -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 } } diff --git a/tests/fail/intrinsics/ptr_offset_int_plus_int.stderr b/tests/fail/intrinsics/ptr_offset_int_plus_int.stderr index e92b0a321665..a96717a06707 100644 --- a/tests/fail/intrinsics/ptr_offset_int_plus_int.stderr +++ b/tests/fail/intrinsics/ptr_offset_int_plus_int.stderr @@ -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::::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 diff --git a/tests/fail/intrinsics/ptr_offset_int_plus_ptr.rs b/tests/fail/intrinsics/ptr_offset_int_plus_ptr.rs index 8fc4d7fe7350..fd3c9b44615c 100644 --- a/tests/fail/intrinsics/ptr_offset_int_plus_ptr.rs +++ b/tests/fail/intrinsics/ptr_offset_int_plus_ptr.rs @@ -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 } } diff --git a/tests/fail/intrinsics/ptr_offset_int_plus_ptr.stderr b/tests/fail/intrinsics/ptr_offset_int_plus_ptr.stderr index 47eac678e2ef..c1abe01dcea5 100644 --- a/tests/fail/intrinsics/ptr_offset_int_plus_ptr.stderr +++ b/tests/fail/intrinsics/ptr_offset_int_plus_ptr.stderr @@ -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::::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 diff --git a/tests/fail/intrinsics/ptr_offset_overflow.rs b/tests/fail/intrinsics/ptr_offset_overflow.rs index 829cf90c855d..c3db1e23b9bf 100644 --- a/tests/fail/intrinsics/ptr_offset_overflow.rs +++ b/tests/fail/intrinsics/ptr_offset_overflow.rs @@ -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 } diff --git a/tests/fail/intrinsics/ptr_offset_overflow.stderr b/tests/fail/intrinsics/ptr_offset_overflow.stderr index d8596acc33b0..d5935006e43b 100644 --- a/tests/fail/intrinsics/ptr_offset_overflow.stderr +++ b/tests/fail/intrinsics/ptr_offset_overflow.stderr @@ -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::::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 diff --git a/tests/fail/intrinsics/ptr_offset_ptr_plus_0.rs b/tests/fail/intrinsics/ptr_offset_ptr_plus_0.rs index f8ee7d0b5092..575e28854b1a 100644 --- a/tests/fail/intrinsics/ptr_offset_ptr_plus_0.rs +++ b/tests/fail/intrinsics/ptr_offset_ptr_plus_0.rs @@ -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 } diff --git a/tests/fail/intrinsics/ptr_offset_ptr_plus_0.stderr b/tests/fail/intrinsics/ptr_offset_ptr_plus_0.stderr index 767ed2fc3c45..5c516d5a490f 100644 --- a/tests/fail/intrinsics/ptr_offset_ptr_plus_0.stderr +++ b/tests/fail/intrinsics/ptr_offset_ptr_plus_0.stderr @@ -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::::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 diff --git a/tests/fail/intrinsics/unchecked_add1.rs b/tests/fail/intrinsics/unchecked_add1.rs index 25dbb817fae0..13265d0fb0ee 100644 --- a/tests/fail/intrinsics/unchecked_add1.rs +++ b/tests/fail/intrinsics/unchecked_add1.rs @@ -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` } diff --git a/tests/fail/intrinsics/unchecked_add1.stderr b/tests/fail/intrinsics/unchecked_add1.stderr index 9d48590593f5..062acbb8de8c 100644 --- a/tests/fail/intrinsics/unchecked_add1.stderr +++ b/tests/fail/intrinsics/unchecked_add1.stderr @@ -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 diff --git a/tests/fail/intrinsics/unchecked_add2.rs b/tests/fail/intrinsics/unchecked_add2.rs index a454f6478059..229f50321d7d 100644 --- a/tests/fail/intrinsics/unchecked_add2.rs +++ b/tests/fail/intrinsics/unchecked_add2.rs @@ -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` } diff --git a/tests/fail/intrinsics/unchecked_add2.stderr b/tests/fail/intrinsics/unchecked_add2.stderr index 64691932e712..09b622d6e296 100644 --- a/tests/fail/intrinsics/unchecked_add2.stderr +++ b/tests/fail/intrinsics/unchecked_add2.stderr @@ -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 diff --git a/tests/fail/intrinsics/unchecked_mul1.rs b/tests/fail/intrinsics/unchecked_mul1.rs index 514eb60602da..810d3418dc8f 100644 --- a/tests/fail/intrinsics/unchecked_mul1.rs +++ b/tests/fail/intrinsics/unchecked_mul1.rs @@ -1,7 +1,5 @@ -#![feature(core_intrinsics)] +#![feature(unchecked_math)] fn main() { // MAX overflow - unsafe { - std::intrinsics::unchecked_mul(300u16, 250u16); //~ ERROR: overflow executing `unchecked_mul` - } + let _val = unsafe { 300u16.unchecked_mul(250u16) }; //~ ERROR: overflow executing `unchecked_mul` } diff --git a/tests/fail/intrinsics/unchecked_mul1.stderr b/tests/fail/intrinsics/unchecked_mul1.stderr index 4d3a45d41575..e260c343c4e6 100644 --- a/tests/fail/intrinsics/unchecked_mul1.stderr +++ b/tests/fail/intrinsics/unchecked_mul1.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: overflow executing `unchecked_mul` --> $DIR/unchecked_mul1.rs:LL:CC | -LL | std::intrinsics::unchecked_mul(300u16, 250u16); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_mul` +LL | let _val = unsafe { 300u16.unchecked_mul(250u16) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_mul` | = 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 diff --git a/tests/fail/intrinsics/unchecked_mul2.rs b/tests/fail/intrinsics/unchecked_mul2.rs index e103c1e7ad17..421019542a95 100644 --- a/tests/fail/intrinsics/unchecked_mul2.rs +++ b/tests/fail/intrinsics/unchecked_mul2.rs @@ -1,7 +1,5 @@ -#![feature(core_intrinsics)] +#![feature(unchecked_math)] fn main() { // MIN overflow - unsafe { - std::intrinsics::unchecked_mul(1_000_000_000i32, -4); //~ ERROR: overflow executing `unchecked_mul` - } + let _val = unsafe { 1_000_000_000i32.unchecked_mul(-4) }; //~ ERROR: overflow executing `unchecked_mul` } diff --git a/tests/fail/intrinsics/unchecked_mul2.stderr b/tests/fail/intrinsics/unchecked_mul2.stderr index b64ef116be45..88b3a49b98ec 100644 --- a/tests/fail/intrinsics/unchecked_mul2.stderr +++ b/tests/fail/intrinsics/unchecked_mul2.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: overflow executing `unchecked_mul` --> $DIR/unchecked_mul2.rs:LL:CC | -LL | std::intrinsics::unchecked_mul(1_000_000_000i32, -4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_mul` +LL | let _val = unsafe { 1_000_000_000i32.unchecked_mul(-4) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_mul` | = 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 diff --git a/tests/fail/intrinsics/unchecked_sub1.rs b/tests/fail/intrinsics/unchecked_sub1.rs index e99f88edc863..c6e006667441 100644 --- a/tests/fail/intrinsics/unchecked_sub1.rs +++ b/tests/fail/intrinsics/unchecked_sub1.rs @@ -1,7 +1,5 @@ -#![feature(core_intrinsics)] +#![feature(unchecked_math)] fn main() { // MIN overflow - unsafe { - std::intrinsics::unchecked_sub(14u32, 22); //~ ERROR: overflow executing `unchecked_sub` - } + let _val = unsafe { 14u32.unchecked_sub(22) }; //~ ERROR: overflow executing `unchecked_sub` } diff --git a/tests/fail/intrinsics/unchecked_sub1.stderr b/tests/fail/intrinsics/unchecked_sub1.stderr index 8454382777a0..ebd7bc10eb41 100644 --- a/tests/fail/intrinsics/unchecked_sub1.stderr +++ b/tests/fail/intrinsics/unchecked_sub1.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: overflow executing `unchecked_sub` --> $DIR/unchecked_sub1.rs:LL:CC | -LL | std::intrinsics::unchecked_sub(14u32, 22); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_sub` +LL | let _val = unsafe { 14u32.unchecked_sub(22) }; + | ^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_sub` | = 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 diff --git a/tests/fail/intrinsics/unchecked_sub2.rs b/tests/fail/intrinsics/unchecked_sub2.rs index f83f6843c9ec..65aa292e212d 100644 --- a/tests/fail/intrinsics/unchecked_sub2.rs +++ b/tests/fail/intrinsics/unchecked_sub2.rs @@ -1,7 +1,5 @@ -#![feature(core_intrinsics)] +#![feature(unchecked_math)] fn main() { // MAX overflow - unsafe { - std::intrinsics::unchecked_sub(30000i16, -7000); //~ ERROR: overflow executing `unchecked_sub` - } + let _val = unsafe { 30000i16.unchecked_sub(-7000) }; //~ ERROR: overflow executing `unchecked_sub` } diff --git a/tests/fail/intrinsics/unchecked_sub2.stderr b/tests/fail/intrinsics/unchecked_sub2.stderr index 2e6fc2e0b64f..73d7c4d86bc0 100644 --- a/tests/fail/intrinsics/unchecked_sub2.stderr +++ b/tests/fail/intrinsics/unchecked_sub2.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: overflow executing `unchecked_sub` --> $DIR/unchecked_sub2.rs:LL:CC | -LL | std::intrinsics::unchecked_sub(30000i16, -7000); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_sub` +LL | let _val = unsafe { 30000i16.unchecked_sub(-7000) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow executing `unchecked_sub` | = 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 diff --git a/tests/fail/invalid_enum_tag.rs b/tests/fail/invalid_enum_tag.rs index 92cc1d1d34e4..84fa2c297390 100644 --- a/tests/fail/invalid_enum_tag.rs +++ b/tests/fail/invalid_enum_tag.rs @@ -2,8 +2,6 @@ // Make sure we find these even with many checks disabled. //@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation -//@error-pattern: enum value has invalid tag - use std::mem; #[repr(C)] @@ -16,5 +14,5 @@ pub enum Foo { fn main() { let f = unsafe { std::mem::transmute::(42) }; - let _val = mem::discriminant(&f); + let _val = mem::discriminant(&f); //~ERROR: enum value has invalid tag } diff --git a/tests/fail/invalid_enum_tag.stderr b/tests/fail/invalid_enum_tag.stderr index 2f5a4541129c..eff59cbfc8c2 100644 --- a/tests/fail/invalid_enum_tag.stderr +++ b/tests/fail/invalid_enum_tag.stderr @@ -1,18 +1,13 @@ error: Undefined Behavior: enum value has invalid tag: $HEX - --> RUSTLIB/core/src/mem/mod.rs:LL:CC + --> $DIR/invalid_enum_tag.rs:LL:CC | -LL | Discriminant(intrinsics::discriminant_value(v)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ enum value has invalid tag: $HEX +LL | let _val = mem::discriminant(&f); + | ^^^^^^^^^^^^^^^^^^^^^ enum value has invalid tag: $HEX | = 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::mem::discriminant::` at RUSTLIB/core/src/mem/mod.rs:LL:CC -note: inside `main` at $DIR/invalid_enum_tag.rs:LL:CC - --> $DIR/invalid_enum_tag.rs:LL:CC - | -LL | let _val = mem::discriminant(&f); - | ^^^^^^^^^^^^^^^^^^^^^ + = note: inside `main` at $DIR/invalid_enum_tag.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/tests/fail/provenance/ptr_invalid_offset.rs b/tests/fail/provenance/ptr_invalid_offset.rs index a3510d8e8929..91ba18f76805 100644 --- a/tests/fail/provenance/ptr_invalid_offset.rs +++ b/tests/fail/provenance/ptr_invalid_offset.rs @@ -1,5 +1,4 @@ //@compile-flags: -Zmiri-strict-provenance -//@error-pattern: is a dangling pointer #![feature(strict_provenance)] fn main() { @@ -7,5 +6,5 @@ fn main() { let ptr = &x as *const _ as *const u8; let roundtrip = std::ptr::invalid::(ptr as usize); // Not even offsetting this is allowed. - let _ = unsafe { roundtrip.offset(1) }; + let _ = unsafe { roundtrip.offset(1) }; //~ERROR: is a dangling pointer } diff --git a/tests/fail/provenance/ptr_invalid_offset.stderr b/tests/fail/provenance/ptr_invalid_offset.stderr index df73689deae8..813a6515b771 100644 --- a/tests/fail/provenance/ptr_invalid_offset.stderr +++ b/tests/fail/provenance/ptr_invalid_offset.stderr @@ -1,18 +1,13 @@ error: Undefined Behavior: out-of-bounds pointer arithmetic: $HEX[noalloc] is a dangling pointer (it has no provenance) - --> RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC + --> $DIR/ptr_invalid_offset.rs:LL:CC | -LL | unsafe { intrinsics::offset(self, count) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: $HEX[noalloc] is a dangling pointer (it has no provenance) +LL | let _ = unsafe { roundtrip.offset(1) }; + | ^^^^^^^^^^^^^^^^^^^ out-of-bounds pointer arithmetic: $HEX[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::const_ptr::::offset` at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC -note: inside `main` at $DIR/ptr_invalid_offset.rs:LL:CC - --> $DIR/ptr_invalid_offset.rs:LL:CC - | -LL | let _ = unsafe { roundtrip.offset(1) }; - | ^^^^^^^^^^^^^^^^^^^ + = note: inside `main` at $DIR/ptr_invalid_offset.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/tests/fail/should-pass/cpp20_rwc_syncs.rs b/tests/fail/should-pass/cpp20_rwc_syncs.rs index dbac6469fbab..6a7622671b59 100644 --- a/tests/fail/should-pass/cpp20_rwc_syncs.rs +++ b/tests/fail/should-pass/cpp20_rwc_syncs.rs @@ -1,6 +1,5 @@ //@ignore-target-windows: Concurrency on Windows is not supported yet. //@compile-flags: -Zmiri-ignore-leaks -//@error-pattern: unreachable // https://plv.mpi-sws.org/scfix/paper.pdf // 2.2 Second Problem: SC Fences are Too Weak @@ -77,7 +76,7 @@ fn test_cpp20_rwc_syncs() { if (b, c) == (0, 0) { // This *should* be unreachable, but Miri will reach it. unsafe { - std::hint::unreachable_unchecked(); + std::hint::unreachable_unchecked(); //~ERROR: unreachable } } } diff --git a/tests/fail/should-pass/cpp20_rwc_syncs.stderr b/tests/fail/should-pass/cpp20_rwc_syncs.stderr index 0ab02687e2ae..17573a33b3d7 100644 --- a/tests/fail/should-pass/cpp20_rwc_syncs.stderr +++ b/tests/fail/should-pass/cpp20_rwc_syncs.stderr @@ -1,18 +1,13 @@ error: Undefined Behavior: entering unreachable code - --> RUSTLIB/core/src/hint.rs:LL:CC + --> $DIR/cpp20_rwc_syncs.rs:LL:CC | -LL | unsafe { intrinsics::unreachable() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ entering unreachable code +LL | std::hint::unreachable_unchecked(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ entering unreachable code | = 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::hint::unreachable_unchecked` at RUSTLIB/core/src/hint.rs:LL:CC -note: inside `test_cpp20_rwc_syncs` at $DIR/cpp20_rwc_syncs.rs:LL:CC - --> $DIR/cpp20_rwc_syncs.rs:LL:CC - | -LL | std::hint::unreachable_unchecked(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: inside `test_cpp20_rwc_syncs` at $DIR/cpp20_rwc_syncs.rs:LL:CC note: inside `main` at $DIR/cpp20_rwc_syncs.rs:LL:CC --> $DIR/cpp20_rwc_syncs.rs:LL:CC | diff --git a/tests/fail/unreachable.rs b/tests/fail/unreachable.rs index ef2bb42c65cc..3389d5b9ddea 100644 --- a/tests/fail/unreachable.rs +++ b/tests/fail/unreachable.rs @@ -1,4 +1,3 @@ -//@error-pattern: entering unreachable code fn main() { - unsafe { std::hint::unreachable_unchecked() } + unsafe { std::hint::unreachable_unchecked() } //~ERROR: entering unreachable code } diff --git a/tests/fail/unreachable.stderr b/tests/fail/unreachable.stderr index e9eb3649dea4..b487b4374756 100644 --- a/tests/fail/unreachable.stderr +++ b/tests/fail/unreachable.stderr @@ -1,18 +1,13 @@ error: Undefined Behavior: entering unreachable code - --> RUSTLIB/core/src/hint.rs:LL:CC + --> $DIR/unreachable.rs:LL:CC | -LL | unsafe { intrinsics::unreachable() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ entering unreachable code +LL | unsafe { std::hint::unreachable_unchecked() } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ entering unreachable code | = 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::hint::unreachable_unchecked` at RUSTLIB/core/src/hint.rs:LL:CC -note: inside `main` at $DIR/unreachable.rs:LL:CC - --> $DIR/unreachable.rs:LL:CC - | -LL | unsafe { std::hint::unreachable_unchecked() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: inside `main` at $DIR/unreachable.rs:LL:CC note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace diff --git a/tests/fail/weak_memory/racing_mixed_size.rs b/tests/fail/weak_memory/racing_mixed_size.rs index a7c5a4191762..95a10510713c 100644 --- a/tests/fail/weak_memory/racing_mixed_size.rs +++ b/tests/fail/weak_memory/racing_mixed_size.rs @@ -4,6 +4,7 @@ #![feature(core_intrinsics)] +use std::ptr; use std::sync::atomic::AtomicU32; use std::sync::atomic::Ordering::*; use std::thread::spawn; @@ -30,7 +31,7 @@ pub fn main() { let x_ptr = x as *const AtomicU32 as *const u32; let x_split = split_u32_ptr(x_ptr); unsafe { - let hi = &(*x_split)[0] as *const u16; + let hi = ptr::addr_of!((*x_split)[0]); std::intrinsics::atomic_load_relaxed(hi); //~ ERROR: imperfectly overlapping } });