From b514667c36f559317a316a5d9b8cd019328be581 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 24 Jul 2022 14:28:45 -0400 Subject: [PATCH 1/3] 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 c4ce192c44..e64a1f9090 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 76917ae7ea..3534f4d1fb 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 0109bff696..b6a110ee84 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 789e9d1f6c..afa2c83064 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 74d391dc21..0d4eea9a5b 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 70ce2dc02a..a32b50a18e 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 b54cf3dd25..701bc33a64 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 973bf043e1..d06c33beb4 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 958a9f90ed..fe2e85be69 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 705ae01188..bba9260228 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 32974a825a..e2329c1313 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 cb9b02c840..40a5022351 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 1fd5100a97..0e5acf08b2 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 699ca1a87a..546245a499 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 f51e00746e..19bd265c14 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 e92b0a3216..a96717a067 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 8fc4d7fe73..fd3c9b4461 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 47eac678e2..c1abe01dce 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 829cf90c85..c3db1e23b9 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 d8596acc33..d5935006e4 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 f8ee7d0b50..575e28854b 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 767ed2fc3c..5c516d5a49 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 25dbb817fa..13265d0fb0 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 9d48590593..062acbb8de 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 a454f64780..229f50321d 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 64691932e7..09b622d6e2 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 514eb60602..810d3418dc 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 4d3a45d415..e260c343c4 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 e103c1e7ad..421019542a 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 b64ef116be..88b3a49b98 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 e99f88edc8..c6e0066674 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 8454382777..ebd7bc10eb 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 f83f6843c9..65aa292e21 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 2e6fc2e0b6..73d7c4d86b 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 92cc1d1d34..84fa2c2973 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 2f5a454112..eff59cbfc8 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 a3510d8e89..91ba18f768 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 df73689dea..813a6515b7 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 dbac6469fb..6a7622671b 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 0ab02687e2..17573a33b3 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 ef2bb42c65..3389d5b9dd 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 e9eb3649de..b487b43747 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 a7c5a41917..95a1051071 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 } }); From c48b8c782cf8f5a04138fe76cbe823c93218f169 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 25 Jul 2022 07:52:17 -0400 Subject: [PATCH 2/3] Preparing for a rustc behavior change that'll happen soon --- tests/fail/intrinsics/ptr_offset_from_unsigned_neg.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.rs b/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.rs index d6413faf74..1162be1303 100644 --- a/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.rs +++ b/tests/fail/intrinsics/ptr_offset_from_unsigned_neg.rs @@ -1,4 +1,6 @@ //@error-pattern: first pointer has smaller offset than second: 0 < 4 +// Preparing for a rustc behavior change that'll happen soon: (FIXME remove this after the next submodule bump succeeded) +//@normalize-stderr-test: "`(ptr_offset_from_unsigned)`" -> "$1" #![feature(ptr_sub_ptr)] fn main() { From 1d52d0ce3cba38f1d046daa390bbb40e4d6e1efc Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 25 Jul 2022 10:24:38 -0400 Subject: [PATCH 3/3] rustup --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index b70ab6fdd4..b948bc8b4e 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -7fe022f5aa32bbbb33c3a58755729d6667a461a9 +2fdbf075cf502431ca9fee6616331b32e34f25de