diff --git a/rust-version b/rust-version index 96ff7aae00..bbd3ed9439 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -917bfa78478cbcc77406e5ea37b24c3eedefacf4 +4e5fec2f1ea4b1cfecaa14304c9f56de59b344cb diff --git a/tests/fail/intrinsics/typed-swap-invalid-array.rs b/tests/fail/intrinsics/typed-swap-invalid-array.rs index 89fdd2a01e..de154d771a 100644 --- a/tests/fail/intrinsics/typed-swap-invalid-array.rs +++ b/tests/fail/intrinsics/typed-swap-invalid-array.rs @@ -1,7 +1,7 @@ #![feature(core_intrinsics)] #![feature(rustc_attrs)] -use std::intrinsics::typed_swap; +use std::intrinsics::typed_swap_nonoverlapping; use std::ptr::addr_of_mut; fn invalid_array() { @@ -10,7 +10,7 @@ fn invalid_array() { unsafe { let a = addr_of_mut!(a).cast::<[bool; 100]>(); let b = addr_of_mut!(b).cast::<[bool; 100]>(); - typed_swap(a, b); //~ERROR: constructing invalid value + typed_swap_nonoverlapping(a, b); //~ERROR: constructing invalid value } } diff --git a/tests/fail/intrinsics/typed-swap-invalid-array.stderr b/tests/fail/intrinsics/typed-swap-invalid-array.stderr index 20b20412e7..5884d13a2a 100644 --- a/tests/fail/intrinsics/typed-swap-invalid-array.stderr +++ b/tests/fail/intrinsics/typed-swap-invalid-array.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: constructing invalid value at [0]: encountered 0x02, but expected a boolean --> tests/fail/intrinsics/typed-swap-invalid-array.rs:LL:CC | -LL | typed_swap(a, b); - | ^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered 0x02, but expected a boolean +LL | typed_swap_nonoverlapping(a, b); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered 0x02, but expected a boolean | = 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/typed-swap-invalid-scalar.stderr b/tests/fail/intrinsics/typed-swap-invalid-scalar.left.stderr similarity index 83% rename from tests/fail/intrinsics/typed-swap-invalid-scalar.stderr rename to tests/fail/intrinsics/typed-swap-invalid-scalar.left.stderr index 6062465f36..9804233c7f 100644 --- a/tests/fail/intrinsics/typed-swap-invalid-scalar.stderr +++ b/tests/fail/intrinsics/typed-swap-invalid-scalar.left.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: constructing invalid value: encountered 0x02, but expected a boolean --> tests/fail/intrinsics/typed-swap-invalid-scalar.rs:LL:CC | -LL | typed_swap(a, b); - | ^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x02, but expected a boolean +LL | typed_swap_nonoverlapping(a, b); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x02, but expected a boolean | = 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/typed-swap-invalid-scalar.right.stderr b/tests/fail/intrinsics/typed-swap-invalid-scalar.right.stderr new file mode 100644 index 0000000000..54b21f155c --- /dev/null +++ b/tests/fail/intrinsics/typed-swap-invalid-scalar.right.stderr @@ -0,0 +1,20 @@ +error: Undefined Behavior: constructing invalid value: encountered 0x03, but expected a boolean + --> tests/fail/intrinsics/typed-swap-invalid-scalar.rs:LL:CC + | +LL | typed_swap_nonoverlapping(a, b); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x03, but expected a boolean + | + = 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 `invalid_scalar` at tests/fail/intrinsics/typed-swap-invalid-scalar.rs:LL:CC +note: inside `main` + --> tests/fail/intrinsics/typed-swap-invalid-scalar.rs:LL:CC + | +LL | invalid_scalar(); + | ^^^^^^^^^^^^^^^^ + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error + diff --git a/tests/fail/intrinsics/typed-swap-invalid-scalar.rs b/tests/fail/intrinsics/typed-swap-invalid-scalar.rs index 9d014a523f..f5f9c7efbe 100644 --- a/tests/fail/intrinsics/typed-swap-invalid-scalar.rs +++ b/tests/fail/intrinsics/typed-swap-invalid-scalar.rs @@ -1,16 +1,18 @@ +//@revisions: left right #![feature(core_intrinsics)] #![feature(rustc_attrs)] -use std::intrinsics::typed_swap; +use std::intrinsics::typed_swap_nonoverlapping; use std::ptr::addr_of_mut; fn invalid_scalar() { - let mut a = 1_u8; - let mut b = 2_u8; + // We run the test twice, with either the left or the right side being invalid. + let mut a = if cfg!(left) { 2_u8 } else { 1_u8 }; + let mut b = if cfg!(right) { 3_u8 } else { 1_u8 }; unsafe { let a = addr_of_mut!(a).cast::(); let b = addr_of_mut!(b).cast::(); - typed_swap(a, b); //~ERROR: constructing invalid value + typed_swap_nonoverlapping(a, b); //~ERROR: constructing invalid value } } diff --git a/tests/fail/intrinsics/typed-swap-overlap.rs b/tests/fail/intrinsics/typed-swap-overlap.rs new file mode 100644 index 0000000000..e643091a02 --- /dev/null +++ b/tests/fail/intrinsics/typed-swap-overlap.rs @@ -0,0 +1,13 @@ +#![feature(core_intrinsics)] +#![feature(rustc_attrs)] + +use std::intrinsics::typed_swap_nonoverlapping; +use std::ptr::addr_of_mut; + +fn main() { + let mut a = 0_u8; + unsafe { + let a = addr_of_mut!(a); + typed_swap_nonoverlapping(a, a); //~ERROR: called on overlapping ranges + } +} diff --git a/tests/fail/intrinsics/typed-swap-overlap.stderr b/tests/fail/intrinsics/typed-swap-overlap.stderr new file mode 100644 index 0000000000..6d578841fe --- /dev/null +++ b/tests/fail/intrinsics/typed-swap-overlap.stderr @@ -0,0 +1,15 @@ +error: Undefined Behavior: `copy_nonoverlapping` called on overlapping ranges + --> tests/fail/intrinsics/typed-swap-overlap.rs:LL:CC + | +LL | typed_swap_nonoverlapping(a, a); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `copy_nonoverlapping` called on overlapping ranges + | + = 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 `main` at tests/fail/intrinsics/typed-swap-overlap.rs:LL:CC + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error +