--- /dev/null
+#![feature(core_intrinsics)]
+
+//error-pattern: copy_nonoverlapping called on overlapping ranges
+
+fn main() {
+ let mut data = [0u8; 16];
+ unsafe {
+ let a = data.as_mut_ptr();
+ let b = a.wrapping_offset(1) as *mut _;
+ std::ptr::copy_nonoverlapping(a, b, 2);
+ }
+}
--- /dev/null
+//error-pattern: invalid use of NULL pointer
+
+fn main() {
+ let mut data = [0u16; 4];
+ let ptr = &mut data[0] as *mut u16;
+ // Even copying 0 elements from NULL should error.
+ unsafe { ptr.copy_from(std::ptr::null(), 0); }
+}
--- /dev/null
+//error-pattern: tried to access memory with alignment 1, but alignment 2 is required
+
+fn main() {
+ let mut data = [0u16; 8];
+ let ptr = (&mut data[0] as *mut u16 as *mut u8).wrapping_add(1) as *mut u16;
+ // Even copying 0 elements to something unaligned should error
+ unsafe { ptr.copy_from(&data[5], 0); }
+}
+++ /dev/null
-#![feature(core_intrinsics)]
-
-//error-pattern: copy_nonoverlapping called on overlapping ranges
-
-fn main() {
- let mut data = [0u8; 16];
- unsafe {
- let a = data.as_mut_ptr();
- let b = a.wrapping_offset(1) as *mut _;
- std::ptr::copy_nonoverlapping(a, b, 2);
- }
-}
+++ /dev/null
-//error-pattern: invalid use of NULL pointer
-
-fn main() {
- let mut data = [0u16; 4];
- let ptr = &mut data[0] as *mut u16;
- // Even copying 0 elements from NULL should error.
- unsafe { ptr.copy_from(std::ptr::null(), 0); }
-}
+++ /dev/null
-//error-pattern: tried to access memory with alignment 1, but alignment 2 is required
-
-fn main() {
- let mut data = [0u16; 8];
- let ptr = (&mut data[0] as *mut u16 as *mut u8).wrapping_add(1) as *mut u16;
- // Even copying 0 elements to something unaligned should error
- unsafe { ptr.copy_from(&data[5], 0); }
-}
fn compile_fail_miri(opt: bool) {
compile_fail("tests/compile-fail", &get_target(), opt);
+ if rustc_test_suite().is_none() {
+ // FIXME: Some tests disabled in rustc test suite because
+ // they run with a debug-assertion libstd which changes the errors.
+ // We should build our own libstd for testing, see
+ // <https://github.com/rust-lang/rust/issues/61833>.
+ compile_fail("tests/compile-fail-norustc", &get_target(), opt);
+ }
}
fn test_runner(_tests: &[&()]) {