]> git.lizzy.rs Git - rust.git/commitdiff
organize compile-fail tests in folders
authorRalf Jung <post@ralfj.de>
Sat, 11 Apr 2020 07:30:13 +0000 (09:30 +0200)
committerRalf Jung <post@ralfj.de>
Sat, 11 Apr 2020 09:36:55 +0000 (11:36 +0200)
146 files changed:
tests/compile-fail/alignment.rs [deleted file]
tests/compile-fail/alloc/deallocate-bad-alignment.rs [new file with mode: 0644]
tests/compile-fail/alloc/deallocate-bad-size.rs [new file with mode: 0644]
tests/compile-fail/alloc/deallocate-twice.rs [new file with mode: 0644]
tests/compile-fail/alloc/reallocate-bad-size.rs [new file with mode: 0644]
tests/compile-fail/alloc/reallocate-change-alloc.rs [new file with mode: 0644]
tests/compile-fail/alloc/reallocate-dangling.rs [new file with mode: 0644]
tests/compile-fail/alloc/stack_free.rs [new file with mode: 0644]
tests/compile-fail/assume.rs [deleted file]
tests/compile-fail/atomic_unaligned.rs [deleted file]
tests/compile-fail/cast_box_int_to_fn_ptr.rs [deleted file]
tests/compile-fail/cast_fn_ptr1.rs [deleted file]
tests/compile-fail/cast_fn_ptr2.rs [deleted file]
tests/compile-fail/cast_fn_ptr3.rs [deleted file]
tests/compile-fail/cast_fn_ptr4.rs [deleted file]
tests/compile-fail/cast_fn_ptr5.rs [deleted file]
tests/compile-fail/cast_int_to_fn_ptr.rs [deleted file]
tests/compile-fail/copy_null.rs [deleted file]
tests/compile-fail/copy_overflow.rs [deleted file]
tests/compile-fail/copy_overlapping.rs [deleted file]
tests/compile-fail/copy_unaligned.rs [deleted file]
tests/compile-fail/ctlz_nonzero.rs [deleted file]
tests/compile-fail/cttz_nonzero.rs [deleted file]
tests/compile-fail/dangling_pointer_deref.rs [deleted file]
tests/compile-fail/dangling_pointers/dangling_pointer_deref.rs [new file with mode: 0644]
tests/compile-fail/dangling_pointers/dangling_zst_deref.rs [new file with mode: 0644]
tests/compile-fail/dangling_pointers/deref-invalid-ptr.rs [new file with mode: 0644]
tests/compile-fail/dangling_pointers/deref-partially-dangling.rs [new file with mode: 0644]
tests/compile-fail/dangling_pointers/maybe_null_pointer_deref_zst.rs [new file with mode: 0644]
tests/compile-fail/dangling_pointers/maybe_null_pointer_write_zst.rs [new file with mode: 0644]
tests/compile-fail/dangling_pointers/out_of_bounds_read1.rs [new file with mode: 0644]
tests/compile-fail/dangling_pointers/out_of_bounds_read2.rs [new file with mode: 0644]
tests/compile-fail/dangling_pointers/wild_pointer_deref.rs [new file with mode: 0644]
tests/compile-fail/dangling_zst_deref.rs [deleted file]
tests/compile-fail/deallocate-bad-alignment.rs [deleted file]
tests/compile-fail/deallocate-bad-size.rs [deleted file]
tests/compile-fail/deallocate-twice.rs [deleted file]
tests/compile-fail/deref-invalid-ptr.rs [deleted file]
tests/compile-fail/deref-partially-dangling.rs [deleted file]
tests/compile-fail/deref_fn_ptr.rs [deleted file]
tests/compile-fail/div-by-zero-1.rs [deleted file]
tests/compile-fail/div-by-zero-2.rs [deleted file]
tests/compile-fail/exact_div1.rs [deleted file]
tests/compile-fail/exact_div2.rs [deleted file]
tests/compile-fail/exact_div3.rs [deleted file]
tests/compile-fail/exact_div4.rs [deleted file]
tests/compile-fail/execute_memory.rs [deleted file]
tests/compile-fail/fn_ptr_offset.rs [deleted file]
tests/compile-fail/function_pointers/cast_box_int_to_fn_ptr.rs [new file with mode: 0644]
tests/compile-fail/function_pointers/cast_fn_ptr1.rs [new file with mode: 0644]
tests/compile-fail/function_pointers/cast_fn_ptr2.rs [new file with mode: 0644]
tests/compile-fail/function_pointers/cast_fn_ptr3.rs [new file with mode: 0644]
tests/compile-fail/function_pointers/cast_fn_ptr4.rs [new file with mode: 0644]
tests/compile-fail/function_pointers/cast_fn_ptr5.rs [new file with mode: 0644]
tests/compile-fail/function_pointers/cast_int_to_fn_ptr.rs [new file with mode: 0644]
tests/compile-fail/function_pointers/deref_fn_ptr.rs [new file with mode: 0644]
tests/compile-fail/function_pointers/execute_memory.rs [new file with mode: 0644]
tests/compile-fail/function_pointers/fn_ptr_offset.rs [new file with mode: 0644]
tests/compile-fail/intptrcast_alignment_check.rs [deleted file]
tests/compile-fail/intrinsics/assume.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/copy_null.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/copy_overflow.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/copy_overlapping.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/copy_unaligned.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/ctlz_nonzero.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/cttz_nonzero.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/div-by-zero-1.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/div-by-zero-2.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/exact_div1.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/exact_div2.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/exact_div3.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/exact_div4.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/out_of_bounds_ptr_1.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/out_of_bounds_ptr_2.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/overflowing-unchecked-rsh.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/ptr_offset_0_plus_0.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/ptr_offset_int_plus_int.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/ptr_offset_int_plus_ptr.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/ptr_offset_overflow.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/ptr_offset_ptr_plus_0.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/unchecked_add1.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/unchecked_add2.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/unchecked_div1.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/unchecked_mul1.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/unchecked_mul2.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/unchecked_sub1.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/unchecked_sub2.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/write_bytes_null.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/write_bytes_overflow.rs [new file with mode: 0644]
tests/compile-fail/libc_pthread_mutex_destroy_locked.rs [deleted file]
tests/compile-fail/libc_pthread_mutex_normal_deadlock.rs [deleted file]
tests/compile-fail/libc_pthread_mutex_normal_unlock_unlocked.rs [deleted file]
tests/compile-fail/libc_pthread_rwlock_destroy_read_locked.rs [deleted file]
tests/compile-fail/libc_pthread_rwlock_destroy_write_locked.rs [deleted file]
tests/compile-fail/libc_pthread_rwlock_read_write_deadlock.rs [deleted file]
tests/compile-fail/libc_pthread_rwlock_unlock_unlocked.rs [deleted file]
tests/compile-fail/libc_pthread_rwlock_write_read_deadlock.rs [deleted file]
tests/compile-fail/libc_pthread_rwlock_write_write_deadlock.rs [deleted file]
tests/compile-fail/maybe_null_pointer_deref_zst.rs [deleted file]
tests/compile-fail/maybe_null_pointer_write_zst.rs [deleted file]
tests/compile-fail/out_of_bounds_ptr_1.rs [deleted file]
tests/compile-fail/out_of_bounds_ptr_2.rs [deleted file]
tests/compile-fail/out_of_bounds_read1.rs [deleted file]
tests/compile-fail/out_of_bounds_read2.rs [deleted file]
tests/compile-fail/overflowing-unchecked-rsh.rs [deleted file]
tests/compile-fail/ptr_offset_0_plus_0.rs [deleted file]
tests/compile-fail/ptr_offset_int_plus_int.rs [deleted file]
tests/compile-fail/ptr_offset_int_plus_ptr.rs [deleted file]
tests/compile-fail/ptr_offset_overflow.rs [deleted file]
tests/compile-fail/ptr_offset_ptr_plus_0.rs [deleted file]
tests/compile-fail/reallocate-bad-size.rs [deleted file]
tests/compile-fail/reallocate-change-alloc.rs [deleted file]
tests/compile-fail/reallocate-dangling.rs [deleted file]
tests/compile-fail/reference_to_packed.rs [deleted file]
tests/compile-fail/stack_free.rs [deleted file]
tests/compile-fail/sync/libc_pthread_mutex_destroy_locked.rs [new file with mode: 0644]
tests/compile-fail/sync/libc_pthread_mutex_normal_deadlock.rs [new file with mode: 0644]
tests/compile-fail/sync/libc_pthread_mutex_normal_unlock_unlocked.rs [new file with mode: 0644]
tests/compile-fail/sync/libc_pthread_rwlock_destroy_read_locked.rs [new file with mode: 0644]
tests/compile-fail/sync/libc_pthread_rwlock_destroy_write_locked.rs [new file with mode: 0644]
tests/compile-fail/sync/libc_pthread_rwlock_read_write_deadlock.rs [new file with mode: 0644]
tests/compile-fail/sync/libc_pthread_rwlock_unlock_unlocked.rs [new file with mode: 0644]
tests/compile-fail/sync/libc_pthread_rwlock_write_read_deadlock.rs [new file with mode: 0644]
tests/compile-fail/sync/libc_pthread_rwlock_write_write_deadlock.rs [new file with mode: 0644]
tests/compile-fail/unaligned_pointers/alignment.rs [new file with mode: 0644]
tests/compile-fail/unaligned_pointers/atomic_unaligned.rs [new file with mode: 0644]
tests/compile-fail/unaligned_pointers/intptrcast_alignment_check.rs [new file with mode: 0644]
tests/compile-fail/unaligned_pointers/reference_to_packed.rs [new file with mode: 0644]
tests/compile-fail/unaligned_pointers/unaligned_ptr1.rs [new file with mode: 0644]
tests/compile-fail/unaligned_pointers/unaligned_ptr2.rs [new file with mode: 0644]
tests/compile-fail/unaligned_pointers/unaligned_ptr3.rs [new file with mode: 0644]
tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.rs [new file with mode: 0644]
tests/compile-fail/unaligned_ptr1.rs [deleted file]
tests/compile-fail/unaligned_ptr2.rs [deleted file]
tests/compile-fail/unaligned_ptr3.rs [deleted file]
tests/compile-fail/unaligned_ptr_zst.rs [deleted file]
tests/compile-fail/unchecked_add1.rs [deleted file]
tests/compile-fail/unchecked_add2.rs [deleted file]
tests/compile-fail/unchecked_div1.rs [deleted file]
tests/compile-fail/unchecked_mul1.rs [deleted file]
tests/compile-fail/unchecked_mul2.rs [deleted file]
tests/compile-fail/unchecked_sub1.rs [deleted file]
tests/compile-fail/unchecked_sub2.rs [deleted file]
tests/compile-fail/wild_pointer_deref.rs [deleted file]
tests/compile-fail/write_bytes_null.rs [deleted file]
tests/compile-fail/write_bytes_overflow.rs [deleted file]

diff --git a/tests/compile-fail/alignment.rs b/tests/compile-fail/alignment.rs
deleted file mode 100644 (file)
index bac1b92..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-fn main() {
-    // miri always gives allocations the worst possible alignment, so a `u8` array is guaranteed
-    // to be at the virtual location 1 (so one byte offset from the ultimate alignemnt location 0)
-    let mut x = [0u8; 20];
-    let x_ptr: *mut u8 = &mut x[0];
-    let y_ptr = x_ptr as *mut u64;
-    unsafe {
-        *y_ptr = 42; //~ ERROR accessing memory with alignment 1, but alignment
-    }
-    panic!("unreachable in miri");
-}
diff --git a/tests/compile-fail/alloc/deallocate-bad-alignment.rs b/tests/compile-fail/alloc/deallocate-bad-alignment.rs
new file mode 100644 (file)
index 0000000..621c053
--- /dev/null
@@ -0,0 +1,10 @@
+use std::alloc::{alloc, dealloc, Layout};
+
+// error-pattern: allocation has size 1 and alignment 1, but gave size 1 and alignment 2
+
+fn main() {
+    unsafe {
+        let x = alloc(Layout::from_size_align_unchecked(1, 1));
+        dealloc(x, Layout::from_size_align_unchecked(1, 2));
+    }
+}
diff --git a/tests/compile-fail/alloc/deallocate-bad-size.rs b/tests/compile-fail/alloc/deallocate-bad-size.rs
new file mode 100644 (file)
index 0000000..386bb56
--- /dev/null
@@ -0,0 +1,10 @@
+use std::alloc::{alloc, dealloc, Layout};
+
+// error-pattern: allocation has size 1 and alignment 1, but gave size 2 and alignment 1
+
+fn main() {
+    unsafe {
+        let x = alloc(Layout::from_size_align_unchecked(1, 1));
+        dealloc(x, Layout::from_size_align_unchecked(2, 1));
+    }
+}
diff --git a/tests/compile-fail/alloc/deallocate-twice.rs b/tests/compile-fail/alloc/deallocate-twice.rs
new file mode 100644 (file)
index 0000000..67312b0
--- /dev/null
@@ -0,0 +1,11 @@
+use std::alloc::{alloc, dealloc, Layout};
+
+// error-pattern: dereferenced after this allocation got freed
+
+fn main() {
+    unsafe {
+        let x = alloc(Layout::from_size_align_unchecked(1, 1));
+        dealloc(x, Layout::from_size_align_unchecked(1, 1));
+        dealloc(x, Layout::from_size_align_unchecked(1, 1));
+    }
+}
diff --git a/tests/compile-fail/alloc/reallocate-bad-size.rs b/tests/compile-fail/alloc/reallocate-bad-size.rs
new file mode 100644 (file)
index 0000000..7826f26
--- /dev/null
@@ -0,0 +1,10 @@
+use std::alloc::{alloc, realloc, Layout};
+
+// error-pattern: allocation has size 1 and alignment 1, but gave size 2 and alignment 1
+
+fn main() {
+    unsafe {
+        let x = alloc(Layout::from_size_align_unchecked(1, 1));
+        realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
+    }
+}
diff --git a/tests/compile-fail/alloc/reallocate-change-alloc.rs b/tests/compile-fail/alloc/reallocate-change-alloc.rs
new file mode 100644 (file)
index 0000000..2970296
--- /dev/null
@@ -0,0 +1,9 @@
+use std::alloc::{alloc, realloc, Layout};
+
+fn main() {
+    unsafe {
+        let x = alloc(Layout::from_size_align_unchecked(1, 1));
+        realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
+        let _z = *x; //~ ERROR dereferenced after this allocation got freed
+    }
+}
diff --git a/tests/compile-fail/alloc/reallocate-dangling.rs b/tests/compile-fail/alloc/reallocate-dangling.rs
new file mode 100644 (file)
index 0000000..702ddc0
--- /dev/null
@@ -0,0 +1,11 @@
+use std::alloc::{alloc, dealloc, realloc, Layout};
+
+// error-pattern: dereferenced after this allocation got freed
+
+fn main() {
+    unsafe {
+        let x = alloc(Layout::from_size_align_unchecked(1, 1));
+        dealloc(x, Layout::from_size_align_unchecked(1, 1));
+        realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
+    }
+}
diff --git a/tests/compile-fail/alloc/stack_free.rs b/tests/compile-fail/alloc/stack_free.rs
new file mode 100644 (file)
index 0000000..50a590e
--- /dev/null
@@ -0,0 +1,10 @@
+// Validation/SB changes why we fail
+// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
+
+// error-pattern: deallocating stack variable memory using Rust heap deallocation operation
+
+fn main() {
+    let x = 42;
+    let bad_box = unsafe { std::mem::transmute::<&i32, Box<i32>>(&x) };
+    drop(bad_box);
+}
diff --git a/tests/compile-fail/assume.rs b/tests/compile-fail/assume.rs
deleted file mode 100644 (file)
index 7b18cab..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#![feature(core_intrinsics)]
-
-fn main() {
-    let x = 5;
-    unsafe {
-        std::intrinsics::assume(x < 10);
-        std::intrinsics::assume(x > 1);
-        std::intrinsics::assume(x > 42); //~ `assume` intrinsic called with `false`
-    }
-}
diff --git a/tests/compile-fail/atomic_unaligned.rs b/tests/compile-fail/atomic_unaligned.rs
deleted file mode 100644 (file)
index bdec0ff..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#![feature(core_intrinsics)]
-
-fn main() {
-    // Do a 4-aligned u64 atomic access. That should be UB on all platforms,
-    // even if u64 only has alignment 4.
-    let z = [0u32; 2];
-    let zptr = &z as *const _ as *const u64;
-    unsafe {
-        ::std::intrinsics::atomic_load(zptr);
-        //~^ ERROR accessing memory with alignment 4, but alignment 8 is required
-    }
-}
diff --git a/tests/compile-fail/cast_box_int_to_fn_ptr.rs b/tests/compile-fail/cast_box_int_to_fn_ptr.rs
deleted file mode 100644 (file)
index 9eea9d9..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// Validation makes this fail in the wrong place
-// compile-flags: -Zmiri-disable-validation
-
-fn main() {
-    let b = Box::new(42);
-    let g = unsafe {
-        std::mem::transmute::<&Box<usize>, &fn(i32)>(&b)
-    };
-
-    (*g)(42) //~ ERROR it does not point to a function
-}
diff --git a/tests/compile-fail/cast_fn_ptr1.rs b/tests/compile-fail/cast_fn_ptr1.rs
deleted file mode 100644 (file)
index 3702ec8..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-fn main() {
-    fn f() {}
-
-    let g = unsafe {
-        std::mem::transmute::<fn(), fn(i32)>(f)
-    };
-
-    g(42) //~ ERROR calling a function with more arguments than it expected
-}
diff --git a/tests/compile-fail/cast_fn_ptr2.rs b/tests/compile-fail/cast_fn_ptr2.rs
deleted file mode 100644 (file)
index 39f0867..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-fn main() {
-    fn f(_ : (i32,i32)) {}
-
-    let g = unsafe {
-        std::mem::transmute::<fn((i32,i32)), fn(i32)>(f)
-    };
-
-    g(42) //~ ERROR calling a function with argument of type (i32, i32) passing data of type i32
-}
diff --git a/tests/compile-fail/cast_fn_ptr3.rs b/tests/compile-fail/cast_fn_ptr3.rs
deleted file mode 100644 (file)
index 3523db2..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-fn main() {
-    fn f(_ : (i32,i32)) {}
-
-    let g = unsafe {
-        std::mem::transmute::<fn((i32,i32)), fn()>(f)
-    };
-
-    g() //~ ERROR calling a function with fewer arguments than it requires
-}
-
diff --git a/tests/compile-fail/cast_fn_ptr4.rs b/tests/compile-fail/cast_fn_ptr4.rs
deleted file mode 100644 (file)
index 22a36a7..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-fn main() {
-    fn f(_ : *const [i32]) {}
-
-    let g = unsafe {
-        std::mem::transmute::<fn(*const [i32]), fn(*const i32)>(f)
-    };
-
-    g(&42 as *const i32) //~ ERROR calling a function with argument of type *const [i32] passing data of type *const i32
-}
diff --git a/tests/compile-fail/cast_fn_ptr5.rs b/tests/compile-fail/cast_fn_ptr5.rs
deleted file mode 100644 (file)
index fb2b440..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-fn main() {
-    fn f() -> u32 { 42 }
-
-    let g = unsafe {
-        std::mem::transmute::<fn() -> u32, fn()>(f)
-    };
-
-    g() //~ ERROR calling a function with return type u32 passing return place of type ()
-}
diff --git a/tests/compile-fail/cast_int_to_fn_ptr.rs b/tests/compile-fail/cast_int_to_fn_ptr.rs
deleted file mode 100644 (file)
index 3000779..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// Validation makes this fail in the wrong place
-// compile-flags: -Zmiri-disable-validation
-
-fn main() {
-    let g = unsafe {
-        std::mem::transmute::<usize, fn(i32)>(42)
-    };
-
-    g(42) //~ ERROR invalid use of 42 as a pointer
-}
diff --git a/tests/compile-fail/copy_null.rs b/tests/compile-fail/copy_null.rs
deleted file mode 100644 (file)
index b14bdc4..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#![feature(intrinsics)]
-
-// Directly call intrinsic to avoid debug assertions in libstd
-extern "rust-intrinsic" {
-    fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
-}
-
-fn main() {
-    let mut data = [0u16; 4];
-    let ptr = &mut data[0] as *mut u16;
-    // Even copying 0 elements from NULL should error.
-    unsafe { copy_nonoverlapping(std::ptr::null(), ptr, 0); } //~ ERROR: invalid use of NULL pointer
-}
diff --git a/tests/compile-fail/copy_overflow.rs b/tests/compile-fail/copy_overflow.rs
deleted file mode 100644 (file)
index c75cf69..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// error-pattern: overflow computing total size of `copy`
-use std::mem;
-
-fn main() {
-    let x = 0;
-    let mut y = 0;
-    unsafe {
-        (&mut y as *mut i32).copy_from(&x, 1usize << (mem::size_of::<usize>() * 8 - 1));
-    }
-}
diff --git a/tests/compile-fail/copy_overlapping.rs b/tests/compile-fail/copy_overlapping.rs
deleted file mode 100644 (file)
index 76e1e20..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-//error-pattern: copy_nonoverlapping called on overlapping ranges
-#![feature(intrinsics)]
-
-// Directly call intrinsic to avoid debug assertions in libstd
-extern "rust-intrinsic" {
-    fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
-}
-
-fn main() {
-    let mut data = [0u8; 16];
-    unsafe {
-        let a = data.as_mut_ptr();
-        let b = a.wrapping_offset(1) as *mut _;
-        copy_nonoverlapping(a, b, 2);
-    }
-}
diff --git a/tests/compile-fail/copy_unaligned.rs b/tests/compile-fail/copy_unaligned.rs
deleted file mode 100644 (file)
index a2a4762..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-//error-pattern: accessing memory with alignment 1, but alignment 2 is required
-#![feature(intrinsics)]
-
-// Directly call intrinsic to avoid debug assertions in libstd
-extern "rust-intrinsic" {
-    fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
-}
-
-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 { copy_nonoverlapping(&data[5], ptr, 0); }
-}
diff --git a/tests/compile-fail/ctlz_nonzero.rs b/tests/compile-fail/ctlz_nonzero.rs
deleted file mode 100644 (file)
index e82ed89..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#![feature(intrinsics)]
-
-mod rusti {
-    extern "rust-intrinsic" {
-        pub fn ctlz_nonzero<T>(x: T) -> T;
-    }
-}
-
-pub fn main() {
-    unsafe {
-        use crate::rusti::*;
-
-        ctlz_nonzero(0u8); //~ ERROR `ctlz_nonzero` called on 0
-    }
-}
diff --git a/tests/compile-fail/cttz_nonzero.rs b/tests/compile-fail/cttz_nonzero.rs
deleted file mode 100644 (file)
index 205b552..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#![feature(intrinsics)]
-
-mod rusti {
-    extern "rust-intrinsic" {
-        pub fn cttz_nonzero<T>(x: T) -> T;
-    }
-}
-
-pub fn main() {
-    unsafe {
-        use crate::rusti::*;
-
-        cttz_nonzero(0u8); //~ ERROR `cttz_nonzero` called on 0
-    }
-}
diff --git a/tests/compile-fail/dangling_pointer_deref.rs b/tests/compile-fail/dangling_pointer_deref.rs
deleted file mode 100644 (file)
index f2c7ec5..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-fn main() {
-    let p = {
-        let b = Box::new(42);
-        &*b as *const i32
-    };
-    let x = unsafe { *p }; //~ ERROR dereferenced after this allocation got freed
-    panic!("this should never print: {}", x);
-}
diff --git a/tests/compile-fail/dangling_pointers/dangling_pointer_deref.rs b/tests/compile-fail/dangling_pointers/dangling_pointer_deref.rs
new file mode 100644 (file)
index 0000000..f2c7ec5
--- /dev/null
@@ -0,0 +1,8 @@
+fn main() {
+    let p = {
+        let b = Box::new(42);
+        &*b as *const i32
+    };
+    let x = unsafe { *p }; //~ ERROR dereferenced after this allocation got freed
+    panic!("this should never print: {}", x);
+}
diff --git a/tests/compile-fail/dangling_pointers/dangling_zst_deref.rs b/tests/compile-fail/dangling_pointers/dangling_zst_deref.rs
new file mode 100644 (file)
index 0000000..13e5f9d
--- /dev/null
@@ -0,0 +1,7 @@
+fn main() {
+    let p = {
+        let b = Box::new(42);
+        &*b as *const i32 as *const ()
+    };
+    let _x = unsafe { *p }; //~ ERROR dereferenced after this allocation got freed
+}
diff --git a/tests/compile-fail/dangling_pointers/deref-invalid-ptr.rs b/tests/compile-fail/dangling_pointers/deref-invalid-ptr.rs
new file mode 100644 (file)
index 0000000..e0bba8c
--- /dev/null
@@ -0,0 +1,7 @@
+// This should fail even without validation.
+// compile-flags: -Zmiri-disable-validation
+
+fn main() {
+    let x = 16usize as *const u32;
+    let _y = unsafe { &*x as *const u32 }; //~ ERROR invalid use of 16 as a pointer
+}
diff --git a/tests/compile-fail/dangling_pointers/deref-partially-dangling.rs b/tests/compile-fail/dangling_pointers/deref-partially-dangling.rs
new file mode 100644 (file)
index 0000000..a6d3aae
--- /dev/null
@@ -0,0 +1,8 @@
+// Deref a raw ptr to access a field of a large struct, where the field
+// is allocated but not the entire struct is.
+fn main() {
+    let x = (1, 13);
+    let xptr = &x as *const _ as *const (i32, i32, i32);
+    let val = unsafe { (*xptr).1 }; //~ ERROR pointer must be in-bounds at offset 12, but is outside bounds of alloc
+    assert_eq!(val, 13);
+}
diff --git a/tests/compile-fail/dangling_pointers/maybe_null_pointer_deref_zst.rs b/tests/compile-fail/dangling_pointers/maybe_null_pointer_deref_zst.rs
new file mode 100644 (file)
index 0000000..d9f5ad4
--- /dev/null
@@ -0,0 +1,5 @@
+fn main() {
+    // This pointer *could* be NULL so we cannot load from it, not even at ZST
+    let ptr = (&0u8 as *const u8).wrapping_sub(0x800) as *const ();
+    let _x: () = unsafe { *ptr }; //~ ERROR outside bounds
+}
diff --git a/tests/compile-fail/dangling_pointers/maybe_null_pointer_write_zst.rs b/tests/compile-fail/dangling_pointers/maybe_null_pointer_write_zst.rs
new file mode 100644 (file)
index 0000000..ef46a46
--- /dev/null
@@ -0,0 +1,8 @@
+fn main() {
+    // This pointer *could* be NULL so we cannot load from it, not even at ZST.
+    // Not using the () type here, as writes of that type do not even have MIR generated.
+    // Also not assigning directly as that's array initialization, not assignment.
+    let zst_val = [1u8; 0];
+    let ptr = (&0u8 as *const u8).wrapping_sub(0x800) as *mut [u8; 0];
+    unsafe { *ptr = zst_val; } //~ ERROR outside bounds
+}
diff --git a/tests/compile-fail/dangling_pointers/out_of_bounds_read1.rs b/tests/compile-fail/dangling_pointers/out_of_bounds_read1.rs
new file mode 100644 (file)
index 0000000..0c175af
--- /dev/null
@@ -0,0 +1,5 @@
+fn main() {
+    let v: Vec<u8> = vec![1, 2];
+    let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR outside bounds of alloc
+    panic!("this should never print: {}", x);
+}
diff --git a/tests/compile-fail/dangling_pointers/out_of_bounds_read2.rs b/tests/compile-fail/dangling_pointers/out_of_bounds_read2.rs
new file mode 100644 (file)
index 0000000..0c175af
--- /dev/null
@@ -0,0 +1,5 @@
+fn main() {
+    let v: Vec<u8> = vec![1, 2];
+    let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR outside bounds of alloc
+    panic!("this should never print: {}", x);
+}
diff --git a/tests/compile-fail/dangling_pointers/wild_pointer_deref.rs b/tests/compile-fail/dangling_pointers/wild_pointer_deref.rs
new file mode 100644 (file)
index 0000000..5780ccc
--- /dev/null
@@ -0,0 +1,5 @@
+fn main() {
+    let p = 44 as *const i32;
+    let x = unsafe { *p }; //~ ERROR invalid use of 44 as a pointer
+    panic!("this should never print: {}", x);
+}
diff --git a/tests/compile-fail/dangling_zst_deref.rs b/tests/compile-fail/dangling_zst_deref.rs
deleted file mode 100644 (file)
index 13e5f9d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-fn main() {
-    let p = {
-        let b = Box::new(42);
-        &*b as *const i32 as *const ()
-    };
-    let _x = unsafe { *p }; //~ ERROR dereferenced after this allocation got freed
-}
diff --git a/tests/compile-fail/deallocate-bad-alignment.rs b/tests/compile-fail/deallocate-bad-alignment.rs
deleted file mode 100644 (file)
index 621c053..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-use std::alloc::{alloc, dealloc, Layout};
-
-// error-pattern: allocation has size 1 and alignment 1, but gave size 1 and alignment 2
-
-fn main() {
-    unsafe {
-        let x = alloc(Layout::from_size_align_unchecked(1, 1));
-        dealloc(x, Layout::from_size_align_unchecked(1, 2));
-    }
-}
diff --git a/tests/compile-fail/deallocate-bad-size.rs b/tests/compile-fail/deallocate-bad-size.rs
deleted file mode 100644 (file)
index 386bb56..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-use std::alloc::{alloc, dealloc, Layout};
-
-// error-pattern: allocation has size 1 and alignment 1, but gave size 2 and alignment 1
-
-fn main() {
-    unsafe {
-        let x = alloc(Layout::from_size_align_unchecked(1, 1));
-        dealloc(x, Layout::from_size_align_unchecked(2, 1));
-    }
-}
diff --git a/tests/compile-fail/deallocate-twice.rs b/tests/compile-fail/deallocate-twice.rs
deleted file mode 100644 (file)
index 67312b0..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-use std::alloc::{alloc, dealloc, Layout};
-
-// error-pattern: dereferenced after this allocation got freed
-
-fn main() {
-    unsafe {
-        let x = alloc(Layout::from_size_align_unchecked(1, 1));
-        dealloc(x, Layout::from_size_align_unchecked(1, 1));
-        dealloc(x, Layout::from_size_align_unchecked(1, 1));
-    }
-}
diff --git a/tests/compile-fail/deref-invalid-ptr.rs b/tests/compile-fail/deref-invalid-ptr.rs
deleted file mode 100644 (file)
index 5610172..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-// This should fail even without validation.
-// compile-flags: -Zmiri-disable-validation
-
-fn main() {
-    let x = 2usize as *const u32;
-    let _y = unsafe { &*x as *const u32 }; //~ ERROR invalid use of 2 as a pointer
-}
diff --git a/tests/compile-fail/deref-partially-dangling.rs b/tests/compile-fail/deref-partially-dangling.rs
deleted file mode 100644 (file)
index a6d3aae..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-// Deref a raw ptr to access a field of a large struct, where the field
-// is allocated but not the entire struct is.
-fn main() {
-    let x = (1, 13);
-    let xptr = &x as *const _ as *const (i32, i32, i32);
-    let val = unsafe { (*xptr).1 }; //~ ERROR pointer must be in-bounds at offset 12, but is outside bounds of alloc
-    assert_eq!(val, 13);
-}
diff --git a/tests/compile-fail/deref_fn_ptr.rs b/tests/compile-fail/deref_fn_ptr.rs
deleted file mode 100644 (file)
index e604f96..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-fn f() {}
-
-fn main() {
-    let x: u8 = unsafe {
-        *std::mem::transmute::<fn(), *const u8>(f) //~ ERROR contains a function
-    };
-    panic!("this should never print: {}", x);
-}
diff --git a/tests/compile-fail/div-by-zero-1.rs b/tests/compile-fail/div-by-zero-1.rs
deleted file mode 100644 (file)
index d67d06d..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#![feature(core_intrinsics)]
-
-use std::intrinsics::*;
-
-fn main() {
-    unsafe {
-        let _n = unchecked_div(1i64, 0); //~ERROR dividing by zero
-    }
-}
diff --git a/tests/compile-fail/div-by-zero-2.rs b/tests/compile-fail/div-by-zero-2.rs
deleted file mode 100644 (file)
index e904049..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#![feature(core_intrinsics)]
-
-use std::intrinsics::*;
-
-fn main() {
-    unsafe {
-        let _n = unchecked_rem(3u32, 0); //~ ERROR calculating the remainder with a divisor of zero
-    }
-}
diff --git a/tests/compile-fail/exact_div1.rs b/tests/compile-fail/exact_div1.rs
deleted file mode 100644 (file)
index 171bede..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#![feature(core_intrinsics)]
-fn main() {
-    // divison by 0
-    unsafe { std::intrinsics::exact_div(2, 0); } //~ ERROR divisor of zero
-}
diff --git a/tests/compile-fail/exact_div2.rs b/tests/compile-fail/exact_div2.rs
deleted file mode 100644 (file)
index 9b9ae80..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#![feature(core_intrinsics)]
-fn main() {
-    // divison with a remainder
-    unsafe { std::intrinsics::exact_div(2u16, 3); } //~ ERROR 2u16 cannot be divided by 3u16 without remainder
-}
diff --git a/tests/compile-fail/exact_div3.rs b/tests/compile-fail/exact_div3.rs
deleted file mode 100644 (file)
index 1cd112a..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#![feature(core_intrinsics)]
-fn main() {
-    // signed divison with a remainder
-    unsafe { std::intrinsics::exact_div(-19i8, 2); } //~ ERROR -19i8 cannot be divided by 2i8 without remainder
-}
diff --git a/tests/compile-fail/exact_div4.rs b/tests/compile-fail/exact_div4.rs
deleted file mode 100644 (file)
index c241b2d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#![feature(core_intrinsics)]
-fn main() {
-    // divison of MIN by -1
-    unsafe { std::intrinsics::exact_div(i64::MIN, -1); } //~ ERROR result of dividing MIN by -1 cannot be represented
-}
diff --git a/tests/compile-fail/execute_memory.rs b/tests/compile-fail/execute_memory.rs
deleted file mode 100644 (file)
index 2e6b58a..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Validation makes this fail in the wrong place
-// compile-flags: -Zmiri-disable-validation
-
-#![feature(box_syntax)]
-
-fn main() {
-    let x = box 42;
-    unsafe {
-        let f = std::mem::transmute::<Box<i32>, fn()>(x);
-        f() //~ ERROR function pointer but it does not point to a function
-    }
-}
diff --git a/tests/compile-fail/fn_ptr_offset.rs b/tests/compile-fail/fn_ptr_offset.rs
deleted file mode 100644 (file)
index 7e509d5..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// Validation makes this fail in the wrong place
-// compile-flags: -Zmiri-disable-validation
-
-use std::mem;
-
-fn f() {}
-
-fn main() {
-    let x : fn() = f;
-    let y : *mut u8 = unsafe { mem::transmute(x) };
-    let y = y.wrapping_offset(1);
-    let x : fn() = unsafe { mem::transmute(y) };
-    x(); //~ ERROR function pointer but it does not point to a function
-}
diff --git a/tests/compile-fail/function_pointers/cast_box_int_to_fn_ptr.rs b/tests/compile-fail/function_pointers/cast_box_int_to_fn_ptr.rs
new file mode 100644 (file)
index 0000000..9eea9d9
--- /dev/null
@@ -0,0 +1,11 @@
+// Validation makes this fail in the wrong place
+// compile-flags: -Zmiri-disable-validation
+
+fn main() {
+    let b = Box::new(42);
+    let g = unsafe {
+        std::mem::transmute::<&Box<usize>, &fn(i32)>(&b)
+    };
+
+    (*g)(42) //~ ERROR it does not point to a function
+}
diff --git a/tests/compile-fail/function_pointers/cast_fn_ptr1.rs b/tests/compile-fail/function_pointers/cast_fn_ptr1.rs
new file mode 100644 (file)
index 0000000..3702ec8
--- /dev/null
@@ -0,0 +1,9 @@
+fn main() {
+    fn f() {}
+
+    let g = unsafe {
+        std::mem::transmute::<fn(), fn(i32)>(f)
+    };
+
+    g(42) //~ ERROR calling a function with more arguments than it expected
+}
diff --git a/tests/compile-fail/function_pointers/cast_fn_ptr2.rs b/tests/compile-fail/function_pointers/cast_fn_ptr2.rs
new file mode 100644 (file)
index 0000000..39f0867
--- /dev/null
@@ -0,0 +1,9 @@
+fn main() {
+    fn f(_ : (i32,i32)) {}
+
+    let g = unsafe {
+        std::mem::transmute::<fn((i32,i32)), fn(i32)>(f)
+    };
+
+    g(42) //~ ERROR calling a function with argument of type (i32, i32) passing data of type i32
+}
diff --git a/tests/compile-fail/function_pointers/cast_fn_ptr3.rs b/tests/compile-fail/function_pointers/cast_fn_ptr3.rs
new file mode 100644 (file)
index 0000000..3523db2
--- /dev/null
@@ -0,0 +1,10 @@
+fn main() {
+    fn f(_ : (i32,i32)) {}
+
+    let g = unsafe {
+        std::mem::transmute::<fn((i32,i32)), fn()>(f)
+    };
+
+    g() //~ ERROR calling a function with fewer arguments than it requires
+}
+
diff --git a/tests/compile-fail/function_pointers/cast_fn_ptr4.rs b/tests/compile-fail/function_pointers/cast_fn_ptr4.rs
new file mode 100644 (file)
index 0000000..22a36a7
--- /dev/null
@@ -0,0 +1,9 @@
+fn main() {
+    fn f(_ : *const [i32]) {}
+
+    let g = unsafe {
+        std::mem::transmute::<fn(*const [i32]), fn(*const i32)>(f)
+    };
+
+    g(&42 as *const i32) //~ ERROR calling a function with argument of type *const [i32] passing data of type *const i32
+}
diff --git a/tests/compile-fail/function_pointers/cast_fn_ptr5.rs b/tests/compile-fail/function_pointers/cast_fn_ptr5.rs
new file mode 100644 (file)
index 0000000..fb2b440
--- /dev/null
@@ -0,0 +1,9 @@
+fn main() {
+    fn f() -> u32 { 42 }
+
+    let g = unsafe {
+        std::mem::transmute::<fn() -> u32, fn()>(f)
+    };
+
+    g() //~ ERROR calling a function with return type u32 passing return place of type ()
+}
diff --git a/tests/compile-fail/function_pointers/cast_int_to_fn_ptr.rs b/tests/compile-fail/function_pointers/cast_int_to_fn_ptr.rs
new file mode 100644 (file)
index 0000000..3000779
--- /dev/null
@@ -0,0 +1,10 @@
+// Validation makes this fail in the wrong place
+// compile-flags: -Zmiri-disable-validation
+
+fn main() {
+    let g = unsafe {
+        std::mem::transmute::<usize, fn(i32)>(42)
+    };
+
+    g(42) //~ ERROR invalid use of 42 as a pointer
+}
diff --git a/tests/compile-fail/function_pointers/deref_fn_ptr.rs b/tests/compile-fail/function_pointers/deref_fn_ptr.rs
new file mode 100644 (file)
index 0000000..e604f96
--- /dev/null
@@ -0,0 +1,8 @@
+fn f() {}
+
+fn main() {
+    let x: u8 = unsafe {
+        *std::mem::transmute::<fn(), *const u8>(f) //~ ERROR contains a function
+    };
+    panic!("this should never print: {}", x);
+}
diff --git a/tests/compile-fail/function_pointers/execute_memory.rs b/tests/compile-fail/function_pointers/execute_memory.rs
new file mode 100644 (file)
index 0000000..2e6b58a
--- /dev/null
@@ -0,0 +1,12 @@
+// Validation makes this fail in the wrong place
+// compile-flags: -Zmiri-disable-validation
+
+#![feature(box_syntax)]
+
+fn main() {
+    let x = box 42;
+    unsafe {
+        let f = std::mem::transmute::<Box<i32>, fn()>(x);
+        f() //~ ERROR function pointer but it does not point to a function
+    }
+}
diff --git a/tests/compile-fail/function_pointers/fn_ptr_offset.rs b/tests/compile-fail/function_pointers/fn_ptr_offset.rs
new file mode 100644 (file)
index 0000000..7e509d5
--- /dev/null
@@ -0,0 +1,14 @@
+// Validation makes this fail in the wrong place
+// compile-flags: -Zmiri-disable-validation
+
+use std::mem;
+
+fn f() {}
+
+fn main() {
+    let x : fn() = f;
+    let y : *mut u8 = unsafe { mem::transmute(x) };
+    let y = y.wrapping_offset(1);
+    let x : fn() = unsafe { mem::transmute(y) };
+    x(); //~ ERROR function pointer but it does not point to a function
+}
diff --git a/tests/compile-fail/intptrcast_alignment_check.rs b/tests/compile-fail/intptrcast_alignment_check.rs
deleted file mode 100644 (file)
index 1a8df5e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Even with intptrcast and without validation, we want to be *sure* to catch bugs
-// that arise from pointers being insufficiently aligned. The only way to achieve
-// that is not not let programs exploit integer information for alignment, so here
-// we test that this is indeed the case.
-fn main() {
-    let x = &mut [0u8; 3];
-    let base_addr = x as *mut _ as usize;
-    let base_addr_aligned = if base_addr % 2 == 0 { base_addr } else { base_addr+1 };
-    let u16_ptr = base_addr_aligned as *mut u16;
-    unsafe { *u16_ptr = 2; } //~ ERROR memory with alignment 1, but alignment 2 is required
-    println!("{:?}", x);
-}
diff --git a/tests/compile-fail/intrinsics/assume.rs b/tests/compile-fail/intrinsics/assume.rs
new file mode 100644 (file)
index 0000000..7b18cab
--- /dev/null
@@ -0,0 +1,10 @@
+#![feature(core_intrinsics)]
+
+fn main() {
+    let x = 5;
+    unsafe {
+        std::intrinsics::assume(x < 10);
+        std::intrinsics::assume(x > 1);
+        std::intrinsics::assume(x > 42); //~ `assume` intrinsic called with `false`
+    }
+}
diff --git a/tests/compile-fail/intrinsics/copy_null.rs b/tests/compile-fail/intrinsics/copy_null.rs
new file mode 100644 (file)
index 0000000..b14bdc4
--- /dev/null
@@ -0,0 +1,13 @@
+#![feature(intrinsics)]
+
+// Directly call intrinsic to avoid debug assertions in libstd
+extern "rust-intrinsic" {
+    fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
+}
+
+fn main() {
+    let mut data = [0u16; 4];
+    let ptr = &mut data[0] as *mut u16;
+    // Even copying 0 elements from NULL should error.
+    unsafe { copy_nonoverlapping(std::ptr::null(), ptr, 0); } //~ ERROR: invalid use of NULL pointer
+}
diff --git a/tests/compile-fail/intrinsics/copy_overflow.rs b/tests/compile-fail/intrinsics/copy_overflow.rs
new file mode 100644 (file)
index 0000000..c75cf69
--- /dev/null
@@ -0,0 +1,10 @@
+// error-pattern: overflow computing total size of `copy`
+use std::mem;
+
+fn main() {
+    let x = 0;
+    let mut y = 0;
+    unsafe {
+        (&mut y as *mut i32).copy_from(&x, 1usize << (mem::size_of::<usize>() * 8 - 1));
+    }
+}
diff --git a/tests/compile-fail/intrinsics/copy_overlapping.rs b/tests/compile-fail/intrinsics/copy_overlapping.rs
new file mode 100644 (file)
index 0000000..76e1e20
--- /dev/null
@@ -0,0 +1,16 @@
+//error-pattern: copy_nonoverlapping called on overlapping ranges
+#![feature(intrinsics)]
+
+// Directly call intrinsic to avoid debug assertions in libstd
+extern "rust-intrinsic" {
+    fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
+}
+
+fn main() {
+    let mut data = [0u8; 16];
+    unsafe {
+        let a = data.as_mut_ptr();
+        let b = a.wrapping_offset(1) as *mut _;
+        copy_nonoverlapping(a, b, 2);
+    }
+}
diff --git a/tests/compile-fail/intrinsics/copy_unaligned.rs b/tests/compile-fail/intrinsics/copy_unaligned.rs
new file mode 100644 (file)
index 0000000..a2a4762
--- /dev/null
@@ -0,0 +1,14 @@
+//error-pattern: accessing memory with alignment 1, but alignment 2 is required
+#![feature(intrinsics)]
+
+// Directly call intrinsic to avoid debug assertions in libstd
+extern "rust-intrinsic" {
+    fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
+}
+
+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 { copy_nonoverlapping(&data[5], ptr, 0); }
+}
diff --git a/tests/compile-fail/intrinsics/ctlz_nonzero.rs b/tests/compile-fail/intrinsics/ctlz_nonzero.rs
new file mode 100644 (file)
index 0000000..e82ed89
--- /dev/null
@@ -0,0 +1,15 @@
+#![feature(intrinsics)]
+
+mod rusti {
+    extern "rust-intrinsic" {
+        pub fn ctlz_nonzero<T>(x: T) -> T;
+    }
+}
+
+pub fn main() {
+    unsafe {
+        use crate::rusti::*;
+
+        ctlz_nonzero(0u8); //~ ERROR `ctlz_nonzero` called on 0
+    }
+}
diff --git a/tests/compile-fail/intrinsics/cttz_nonzero.rs b/tests/compile-fail/intrinsics/cttz_nonzero.rs
new file mode 100644 (file)
index 0000000..205b552
--- /dev/null
@@ -0,0 +1,15 @@
+#![feature(intrinsics)]
+
+mod rusti {
+    extern "rust-intrinsic" {
+        pub fn cttz_nonzero<T>(x: T) -> T;
+    }
+}
+
+pub fn main() {
+    unsafe {
+        use crate::rusti::*;
+
+        cttz_nonzero(0u8); //~ ERROR `cttz_nonzero` called on 0
+    }
+}
diff --git a/tests/compile-fail/intrinsics/div-by-zero-1.rs b/tests/compile-fail/intrinsics/div-by-zero-1.rs
new file mode 100644 (file)
index 0000000..d67d06d
--- /dev/null
@@ -0,0 +1,9 @@
+#![feature(core_intrinsics)]
+
+use std::intrinsics::*;
+
+fn main() {
+    unsafe {
+        let _n = unchecked_div(1i64, 0); //~ERROR dividing by zero
+    }
+}
diff --git a/tests/compile-fail/intrinsics/div-by-zero-2.rs b/tests/compile-fail/intrinsics/div-by-zero-2.rs
new file mode 100644 (file)
index 0000000..e904049
--- /dev/null
@@ -0,0 +1,9 @@
+#![feature(core_intrinsics)]
+
+use std::intrinsics::*;
+
+fn main() {
+    unsafe {
+        let _n = unchecked_rem(3u32, 0); //~ ERROR calculating the remainder with a divisor of zero
+    }
+}
diff --git a/tests/compile-fail/intrinsics/exact_div1.rs b/tests/compile-fail/intrinsics/exact_div1.rs
new file mode 100644 (file)
index 0000000..171bede
--- /dev/null
@@ -0,0 +1,5 @@
+#![feature(core_intrinsics)]
+fn main() {
+    // divison by 0
+    unsafe { std::intrinsics::exact_div(2, 0); } //~ ERROR divisor of zero
+}
diff --git a/tests/compile-fail/intrinsics/exact_div2.rs b/tests/compile-fail/intrinsics/exact_div2.rs
new file mode 100644 (file)
index 0000000..9b9ae80
--- /dev/null
@@ -0,0 +1,5 @@
+#![feature(core_intrinsics)]
+fn main() {
+    // divison with a remainder
+    unsafe { std::intrinsics::exact_div(2u16, 3); } //~ ERROR 2u16 cannot be divided by 3u16 without remainder
+}
diff --git a/tests/compile-fail/intrinsics/exact_div3.rs b/tests/compile-fail/intrinsics/exact_div3.rs
new file mode 100644 (file)
index 0000000..1cd112a
--- /dev/null
@@ -0,0 +1,5 @@
+#![feature(core_intrinsics)]
+fn main() {
+    // signed divison with a remainder
+    unsafe { std::intrinsics::exact_div(-19i8, 2); } //~ ERROR -19i8 cannot be divided by 2i8 without remainder
+}
diff --git a/tests/compile-fail/intrinsics/exact_div4.rs b/tests/compile-fail/intrinsics/exact_div4.rs
new file mode 100644 (file)
index 0000000..c241b2d
--- /dev/null
@@ -0,0 +1,5 @@
+#![feature(core_intrinsics)]
+fn main() {
+    // divison of MIN by -1
+    unsafe { std::intrinsics::exact_div(i64::MIN, -1); } //~ ERROR result of dividing MIN by -1 cannot be represented
+}
diff --git a/tests/compile-fail/intrinsics/out_of_bounds_ptr_1.rs b/tests/compile-fail/intrinsics/out_of_bounds_ptr_1.rs
new file mode 100644 (file)
index 0000000..20bcc36
--- /dev/null
@@ -0,0 +1,8 @@
+// error-pattern: must be in-bounds at offset 5, but is outside bounds of alloc
+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) };
+    panic!("this should never print: {:?}", x);
+}
diff --git a/tests/compile-fail/intrinsics/out_of_bounds_ptr_2.rs b/tests/compile-fail/intrinsics/out_of_bounds_ptr_2.rs
new file mode 100644 (file)
index 0000000..1e4759d
--- /dev/null
@@ -0,0 +1,7 @@
+// error-pattern: overflowing in-bounds pointer arithmetic
+fn main() {
+    let v = [0i8; 4];
+    let x = &v as *const i8;
+    let x = unsafe { x.offset(-1) };
+    panic!("this should never print: {:?}", x);
+}
diff --git a/tests/compile-fail/intrinsics/overflowing-unchecked-rsh.rs b/tests/compile-fail/intrinsics/overflowing-unchecked-rsh.rs
new file mode 100644 (file)
index 0000000..730d015
--- /dev/null
@@ -0,0 +1,11 @@
+#![feature(core_intrinsics)]
+
+use std::intrinsics::*;
+
+//error-pattern: overflowing shift by 64 in `unchecked_shr`
+
+fn main() {
+    unsafe {
+        let _n = unchecked_shr(1i64, 64);
+    }
+}
diff --git a/tests/compile-fail/intrinsics/ptr_offset_0_plus_0.rs b/tests/compile-fail/intrinsics/ptr_offset_0_plus_0.rs
new file mode 100644 (file)
index 0000000..96a9fb8
--- /dev/null
@@ -0,0 +1,7 @@
+// error-pattern: invalid use of NULL pointer
+
+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
+}
diff --git a/tests/compile-fail/intrinsics/ptr_offset_int_plus_int.rs b/tests/compile-fail/intrinsics/ptr_offset_int_plus_int.rs
new file mode 100644 (file)
index 0000000..f0cf008
--- /dev/null
@@ -0,0 +1,8 @@
+// error-pattern: invalid use of 1 as a pointer
+
+fn main() {
+    // Can't offset an integer pointer by non-zero offset.
+    unsafe {
+        let _val = (1 as *mut u8).offset(1);
+    }
+}
diff --git a/tests/compile-fail/intrinsics/ptr_offset_int_plus_ptr.rs b/tests/compile-fail/intrinsics/ptr_offset_int_plus_ptr.rs
new file mode 100644 (file)
index 0000000..705ca68
--- /dev/null
@@ -0,0 +1,9 @@
+// error-pattern: invalid use of 1 as a pointer
+
+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);
+    }
+}
diff --git a/tests/compile-fail/intrinsics/ptr_offset_overflow.rs b/tests/compile-fail/intrinsics/ptr_offset_overflow.rs
new file mode 100644 (file)
index 0000000..452bf34
--- /dev/null
@@ -0,0 +1,6 @@
+//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) };
+}
diff --git a/tests/compile-fail/intrinsics/ptr_offset_ptr_plus_0.rs b/tests/compile-fail/intrinsics/ptr_offset_ptr_plus_0.rs
new file mode 100644 (file)
index 0000000..d07ecc4
--- /dev/null
@@ -0,0 +1,7 @@
+// error-pattern: outside bounds of alloc
+
+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
+}
diff --git a/tests/compile-fail/intrinsics/unchecked_add1.rs b/tests/compile-fail/intrinsics/unchecked_add1.rs
new file mode 100644 (file)
index 0000000..f48b914
--- /dev/null
@@ -0,0 +1,5 @@
+#![feature(core_intrinsics)]
+fn main() {
+    // MAX overflow
+    unsafe { std::intrinsics::unchecked_add(40000u16, 30000); } //~ ERROR overflow executing `unchecked_add`
+}
diff --git a/tests/compile-fail/intrinsics/unchecked_add2.rs b/tests/compile-fail/intrinsics/unchecked_add2.rs
new file mode 100644 (file)
index 0000000..1509865
--- /dev/null
@@ -0,0 +1,5 @@
+#![feature(core_intrinsics)]
+fn main() {
+    // MIN overflow
+    unsafe { std::intrinsics::unchecked_add(-30000i16, -8000); } //~ ERROR overflow executing `unchecked_add`
+}
diff --git a/tests/compile-fail/intrinsics/unchecked_div1.rs b/tests/compile-fail/intrinsics/unchecked_div1.rs
new file mode 100644 (file)
index 0000000..53d8000
--- /dev/null
@@ -0,0 +1,5 @@
+#![feature(core_intrinsics)]
+fn main() {
+    // MIN/-1 cannot be represented
+    unsafe { std::intrinsics::unchecked_div(i16::MIN, -1); } //~ ERROR overflow executing `unchecked_div`
+}
diff --git a/tests/compile-fail/intrinsics/unchecked_mul1.rs b/tests/compile-fail/intrinsics/unchecked_mul1.rs
new file mode 100644 (file)
index 0000000..050e3ff
--- /dev/null
@@ -0,0 +1,5 @@
+#![feature(core_intrinsics)]
+fn main() {
+    // MAX overflow
+    unsafe { std::intrinsics::unchecked_mul(300u16, 250u16); } //~ ERROR overflow executing `unchecked_mul`
+}
diff --git a/tests/compile-fail/intrinsics/unchecked_mul2.rs b/tests/compile-fail/intrinsics/unchecked_mul2.rs
new file mode 100644 (file)
index 0000000..4fb7778
--- /dev/null
@@ -0,0 +1,5 @@
+#![feature(core_intrinsics)]
+fn main() {
+    // MIN overflow
+    unsafe { std::intrinsics::unchecked_mul(1_000_000_000i32, -4); } //~ ERROR overflow executing `unchecked_mul`
+}
diff --git a/tests/compile-fail/intrinsics/unchecked_sub1.rs b/tests/compile-fail/intrinsics/unchecked_sub1.rs
new file mode 100644 (file)
index 0000000..69b32dd
--- /dev/null
@@ -0,0 +1,5 @@
+#![feature(core_intrinsics)]
+fn main() {
+    // MIN overflow
+    unsafe { std::intrinsics::unchecked_sub(14u32, 22); } //~ ERROR overflow executing `unchecked_sub`
+}
diff --git a/tests/compile-fail/intrinsics/unchecked_sub2.rs b/tests/compile-fail/intrinsics/unchecked_sub2.rs
new file mode 100644 (file)
index 0000000..5609ea7
--- /dev/null
@@ -0,0 +1,5 @@
+#![feature(core_intrinsics)]
+fn main() {
+    // MAX overflow
+    unsafe { std::intrinsics::unchecked_sub(30000i16, -7000); } //~ ERROR overflow executing `unchecked_sub`
+}
diff --git a/tests/compile-fail/intrinsics/write_bytes_null.rs b/tests/compile-fail/intrinsics/write_bytes_null.rs
new file mode 100644 (file)
index 0000000..e802221
--- /dev/null
@@ -0,0 +1,10 @@
+#![feature(intrinsics)]
+
+// Directly call intrinsic to avoid debug assertions in libstd
+extern "rust-intrinsic" {
+    fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
+}
+
+fn main() {
+    unsafe { write_bytes::<u8>(std::ptr::null_mut(), 0, 0) }; //~ ERROR invalid use of NULL pointer
+}
diff --git a/tests/compile-fail/intrinsics/write_bytes_overflow.rs b/tests/compile-fail/intrinsics/write_bytes_overflow.rs
new file mode 100644 (file)
index 0000000..a6bf2ac
--- /dev/null
@@ -0,0 +1,9 @@
+// error-pattern: overflow computing total size of `write_bytes`
+use std::mem;
+
+fn main() {
+    let mut y = 0;
+    unsafe {
+        (&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
+    }
+}
diff --git a/tests/compile-fail/libc_pthread_mutex_destroy_locked.rs b/tests/compile-fail/libc_pthread_mutex_destroy_locked.rs
deleted file mode 100644 (file)
index e7ed8ad..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// ignore-windows: No libc on Windows
-
-#![feature(rustc_private)]
-
-extern crate libc;
-
-fn main() {
-    unsafe {
-        let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed();
-        assert_eq!(libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), 0);
-        let mut mutex: libc::pthread_mutex_t = std::mem::zeroed();
-        assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0);
-        assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0);
-        libc::pthread_mutex_destroy(&mut mutex as *mut _); //~ ERROR destroyed a locked mutex
-    }
-}
diff --git a/tests/compile-fail/libc_pthread_mutex_normal_deadlock.rs b/tests/compile-fail/libc_pthread_mutex_normal_deadlock.rs
deleted file mode 100644 (file)
index 7034bf6..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// ignore-windows: No libc on Windows
-
-#![feature(rustc_private)]
-
-extern crate libc;
-
-fn main() {
-    unsafe {
-        let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed();
-        assert_eq!(libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), 0);
-        let mut mutex: libc::pthread_mutex_t = std::mem::zeroed();
-        assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0);
-        assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0);
-        libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR deadlock
-    }
-}
diff --git a/tests/compile-fail/libc_pthread_mutex_normal_unlock_unlocked.rs b/tests/compile-fail/libc_pthread_mutex_normal_unlock_unlocked.rs
deleted file mode 100644 (file)
index 65de624..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// ignore-windows: No libc on Windows
-
-#![feature(rustc_private)]
-
-extern crate libc;
-
-fn main() {
-    unsafe {
-        let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed();
-        assert_eq!(libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), 0);
-        let mut mutex: libc::pthread_mutex_t = std::mem::zeroed();
-        assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0);
-        assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0);
-        assert_eq!(libc::pthread_mutex_unlock(&mut mutex as *mut _), 0);
-        libc::pthread_mutex_unlock(&mut mutex as *mut _); //~ ERROR was not locked
-    }
-}
diff --git a/tests/compile-fail/libc_pthread_rwlock_destroy_read_locked.rs b/tests/compile-fail/libc_pthread_rwlock_destroy_read_locked.rs
deleted file mode 100644 (file)
index 8750a73..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// ignore-windows: No libc on Windows
-
-#![feature(rustc_private)]
-
-extern crate libc;
-
-fn main() {
-    let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);
-    unsafe {
-        assert_eq!(libc::pthread_rwlock_rdlock(rw.get()), 0);
-        libc::pthread_rwlock_destroy(rw.get()); //~ ERROR destroyed a locked rwlock
-    }
-}
diff --git a/tests/compile-fail/libc_pthread_rwlock_destroy_write_locked.rs b/tests/compile-fail/libc_pthread_rwlock_destroy_write_locked.rs
deleted file mode 100644 (file)
index aecccfa..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// ignore-windows: No libc on Windows
-
-#![feature(rustc_private)]
-
-extern crate libc;
-
-fn main() {
-    let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);
-    unsafe {
-        assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0);
-        libc::pthread_rwlock_destroy(rw.get()); //~ ERROR destroyed a locked rwlock
-    }
-}
diff --git a/tests/compile-fail/libc_pthread_rwlock_read_write_deadlock.rs b/tests/compile-fail/libc_pthread_rwlock_read_write_deadlock.rs
deleted file mode 100644 (file)
index dd4707d..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// ignore-windows: No libc on Windows
-
-#![feature(rustc_private)]
-
-extern crate libc;
-
-fn main() {
-    let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);
-    unsafe {
-        assert_eq!(libc::pthread_rwlock_rdlock(rw.get()), 0);
-        libc::pthread_rwlock_wrlock(rw.get()); //~ ERROR: deadlock
-    }
-}
diff --git a/tests/compile-fail/libc_pthread_rwlock_unlock_unlocked.rs b/tests/compile-fail/libc_pthread_rwlock_unlock_unlocked.rs
deleted file mode 100644 (file)
index 8b3de53..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// ignore-windows: No libc on Windows
-
-#![feature(rustc_private)]
-
-extern crate libc;
-
-fn main() {
-    let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);
-    unsafe {
-        libc::pthread_rwlock_unlock(rw.get()); //~ ERROR was not locked
-    }
-}
diff --git a/tests/compile-fail/libc_pthread_rwlock_write_read_deadlock.rs b/tests/compile-fail/libc_pthread_rwlock_write_read_deadlock.rs
deleted file mode 100644 (file)
index 1b460e7..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// ignore-windows: No libc on Windows
-
-#![feature(rustc_private)]
-
-extern crate libc;
-
-fn main() {
-    let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);
-    unsafe {
-        assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0);
-        libc::pthread_rwlock_rdlock(rw.get()); //~ ERROR: deadlock
-    }
-}
diff --git a/tests/compile-fail/libc_pthread_rwlock_write_write_deadlock.rs b/tests/compile-fail/libc_pthread_rwlock_write_write_deadlock.rs
deleted file mode 100644 (file)
index cc327ec..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// ignore-windows: No libc on Windows
-
-#![feature(rustc_private)]
-
-extern crate libc;
-
-fn main() {
-    let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);
-    unsafe {
-        assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0);
-        libc::pthread_rwlock_wrlock(rw.get()); //~ ERROR: deadlock
-    }
-}
diff --git a/tests/compile-fail/maybe_null_pointer_deref_zst.rs b/tests/compile-fail/maybe_null_pointer_deref_zst.rs
deleted file mode 100644 (file)
index d9f5ad4..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-fn main() {
-    // This pointer *could* be NULL so we cannot load from it, not even at ZST
-    let ptr = (&0u8 as *const u8).wrapping_sub(0x800) as *const ();
-    let _x: () = unsafe { *ptr }; //~ ERROR outside bounds
-}
diff --git a/tests/compile-fail/maybe_null_pointer_write_zst.rs b/tests/compile-fail/maybe_null_pointer_write_zst.rs
deleted file mode 100644 (file)
index ef46a46..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-fn main() {
-    // This pointer *could* be NULL so we cannot load from it, not even at ZST.
-    // Not using the () type here, as writes of that type do not even have MIR generated.
-    // Also not assigning directly as that's array initialization, not assignment.
-    let zst_val = [1u8; 0];
-    let ptr = (&0u8 as *const u8).wrapping_sub(0x800) as *mut [u8; 0];
-    unsafe { *ptr = zst_val; } //~ ERROR outside bounds
-}
diff --git a/tests/compile-fail/out_of_bounds_ptr_1.rs b/tests/compile-fail/out_of_bounds_ptr_1.rs
deleted file mode 100644 (file)
index 20bcc36..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-// error-pattern: must be in-bounds at offset 5, but is outside bounds of alloc
-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) };
-    panic!("this should never print: {:?}", x);
-}
diff --git a/tests/compile-fail/out_of_bounds_ptr_2.rs b/tests/compile-fail/out_of_bounds_ptr_2.rs
deleted file mode 100644 (file)
index 1e4759d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-// error-pattern: overflowing in-bounds pointer arithmetic
-fn main() {
-    let v = [0i8; 4];
-    let x = &v as *const i8;
-    let x = unsafe { x.offset(-1) };
-    panic!("this should never print: {:?}", x);
-}
diff --git a/tests/compile-fail/out_of_bounds_read1.rs b/tests/compile-fail/out_of_bounds_read1.rs
deleted file mode 100644 (file)
index 0c175af..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-fn main() {
-    let v: Vec<u8> = vec![1, 2];
-    let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR outside bounds of alloc
-    panic!("this should never print: {}", x);
-}
diff --git a/tests/compile-fail/out_of_bounds_read2.rs b/tests/compile-fail/out_of_bounds_read2.rs
deleted file mode 100644 (file)
index 0c175af..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-fn main() {
-    let v: Vec<u8> = vec![1, 2];
-    let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR outside bounds of alloc
-    panic!("this should never print: {}", x);
-}
diff --git a/tests/compile-fail/overflowing-unchecked-rsh.rs b/tests/compile-fail/overflowing-unchecked-rsh.rs
deleted file mode 100644 (file)
index 730d015..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#![feature(core_intrinsics)]
-
-use std::intrinsics::*;
-
-//error-pattern: overflowing shift by 64 in `unchecked_shr`
-
-fn main() {
-    unsafe {
-        let _n = unchecked_shr(1i64, 64);
-    }
-}
diff --git a/tests/compile-fail/ptr_offset_0_plus_0.rs b/tests/compile-fail/ptr_offset_0_plus_0.rs
deleted file mode 100644 (file)
index 96a9fb8..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-// error-pattern: invalid use of NULL pointer
-
-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
-}
diff --git a/tests/compile-fail/ptr_offset_int_plus_int.rs b/tests/compile-fail/ptr_offset_int_plus_int.rs
deleted file mode 100644 (file)
index f0cf008..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-// error-pattern: invalid use of 1 as a pointer
-
-fn main() {
-    // Can't offset an integer pointer by non-zero offset.
-    unsafe {
-        let _val = (1 as *mut u8).offset(1);
-    }
-}
diff --git a/tests/compile-fail/ptr_offset_int_plus_ptr.rs b/tests/compile-fail/ptr_offset_int_plus_ptr.rs
deleted file mode 100644 (file)
index 705ca68..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// error-pattern: invalid use of 1 as a pointer
-
-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);
-    }
-}
diff --git a/tests/compile-fail/ptr_offset_overflow.rs b/tests/compile-fail/ptr_offset_overflow.rs
deleted file mode 100644 (file)
index 452bf34..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-//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) };
-}
diff --git a/tests/compile-fail/ptr_offset_ptr_plus_0.rs b/tests/compile-fail/ptr_offset_ptr_plus_0.rs
deleted file mode 100644 (file)
index d07ecc4..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-// error-pattern: outside bounds of alloc
-
-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
-}
diff --git a/tests/compile-fail/reallocate-bad-size.rs b/tests/compile-fail/reallocate-bad-size.rs
deleted file mode 100644 (file)
index 7826f26..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-use std::alloc::{alloc, realloc, Layout};
-
-// error-pattern: allocation has size 1 and alignment 1, but gave size 2 and alignment 1
-
-fn main() {
-    unsafe {
-        let x = alloc(Layout::from_size_align_unchecked(1, 1));
-        realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
-    }
-}
diff --git a/tests/compile-fail/reallocate-change-alloc.rs b/tests/compile-fail/reallocate-change-alloc.rs
deleted file mode 100644 (file)
index 2970296..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-use std::alloc::{alloc, realloc, Layout};
-
-fn main() {
-    unsafe {
-        let x = alloc(Layout::from_size_align_unchecked(1, 1));
-        realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
-        let _z = *x; //~ ERROR dereferenced after this allocation got freed
-    }
-}
diff --git a/tests/compile-fail/reallocate-dangling.rs b/tests/compile-fail/reallocate-dangling.rs
deleted file mode 100644 (file)
index 702ddc0..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-use std::alloc::{alloc, dealloc, realloc, Layout};
-
-// error-pattern: dereferenced after this allocation got freed
-
-fn main() {
-    unsafe {
-        let x = alloc(Layout::from_size_align_unchecked(1, 1));
-        dealloc(x, Layout::from_size_align_unchecked(1, 1));
-        realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
-    }
-}
diff --git a/tests/compile-fail/reference_to_packed.rs b/tests/compile-fail/reference_to_packed.rs
deleted file mode 100644 (file)
index 08104e9..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// This should fail even without validation/SB
-// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
-
-#![allow(dead_code, unused_variables)]
-
-#[repr(packed)]
-struct Foo {
-    x: i32,
-    y: i32,
-}
-
-fn main() {
-    let foo = Foo {
-        x: 42,
-        y: 99,
-    };
-    let p = unsafe { &foo.x };
-    let i = *p; //~ ERROR memory with alignment 1, but alignment 4 is required
-}
diff --git a/tests/compile-fail/stack_free.rs b/tests/compile-fail/stack_free.rs
deleted file mode 100644 (file)
index 50a590e..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// Validation/SB changes why we fail
-// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
-
-// error-pattern: deallocating stack variable memory using Rust heap deallocation operation
-
-fn main() {
-    let x = 42;
-    let bad_box = unsafe { std::mem::transmute::<&i32, Box<i32>>(&x) };
-    drop(bad_box);
-}
diff --git a/tests/compile-fail/sync/libc_pthread_mutex_destroy_locked.rs b/tests/compile-fail/sync/libc_pthread_mutex_destroy_locked.rs
new file mode 100644 (file)
index 0000000..e7ed8ad
--- /dev/null
@@ -0,0 +1,16 @@
+// ignore-windows: No libc on Windows
+
+#![feature(rustc_private)]
+
+extern crate libc;
+
+fn main() {
+    unsafe {
+        let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed();
+        assert_eq!(libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), 0);
+        let mut mutex: libc::pthread_mutex_t = std::mem::zeroed();
+        assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0);
+        assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0);
+        libc::pthread_mutex_destroy(&mut mutex as *mut _); //~ ERROR destroyed a locked mutex
+    }
+}
diff --git a/tests/compile-fail/sync/libc_pthread_mutex_normal_deadlock.rs b/tests/compile-fail/sync/libc_pthread_mutex_normal_deadlock.rs
new file mode 100644 (file)
index 0000000..7034bf6
--- /dev/null
@@ -0,0 +1,16 @@
+// ignore-windows: No libc on Windows
+
+#![feature(rustc_private)]
+
+extern crate libc;
+
+fn main() {
+    unsafe {
+        let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed();
+        assert_eq!(libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), 0);
+        let mut mutex: libc::pthread_mutex_t = std::mem::zeroed();
+        assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0);
+        assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0);
+        libc::pthread_mutex_lock(&mut mutex as *mut _); //~ ERROR deadlock
+    }
+}
diff --git a/tests/compile-fail/sync/libc_pthread_mutex_normal_unlock_unlocked.rs b/tests/compile-fail/sync/libc_pthread_mutex_normal_unlock_unlocked.rs
new file mode 100644 (file)
index 0000000..65de624
--- /dev/null
@@ -0,0 +1,17 @@
+// ignore-windows: No libc on Windows
+
+#![feature(rustc_private)]
+
+extern crate libc;
+
+fn main() {
+    unsafe {
+        let mut mutexattr: libc::pthread_mutexattr_t = std::mem::zeroed();
+        assert_eq!(libc::pthread_mutexattr_settype(&mut mutexattr as *mut _, libc::PTHREAD_MUTEX_NORMAL), 0);
+        let mut mutex: libc::pthread_mutex_t = std::mem::zeroed();
+        assert_eq!(libc::pthread_mutex_init(&mut mutex as *mut _, &mutexattr as *const _), 0);
+        assert_eq!(libc::pthread_mutex_lock(&mut mutex as *mut _), 0);
+        assert_eq!(libc::pthread_mutex_unlock(&mut mutex as *mut _), 0);
+        libc::pthread_mutex_unlock(&mut mutex as *mut _); //~ ERROR was not locked
+    }
+}
diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_destroy_read_locked.rs b/tests/compile-fail/sync/libc_pthread_rwlock_destroy_read_locked.rs
new file mode 100644 (file)
index 0000000..8750a73
--- /dev/null
@@ -0,0 +1,13 @@
+// ignore-windows: No libc on Windows
+
+#![feature(rustc_private)]
+
+extern crate libc;
+
+fn main() {
+    let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);
+    unsafe {
+        assert_eq!(libc::pthread_rwlock_rdlock(rw.get()), 0);
+        libc::pthread_rwlock_destroy(rw.get()); //~ ERROR destroyed a locked rwlock
+    }
+}
diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_destroy_write_locked.rs b/tests/compile-fail/sync/libc_pthread_rwlock_destroy_write_locked.rs
new file mode 100644 (file)
index 0000000..aecccfa
--- /dev/null
@@ -0,0 +1,13 @@
+// ignore-windows: No libc on Windows
+
+#![feature(rustc_private)]
+
+extern crate libc;
+
+fn main() {
+    let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);
+    unsafe {
+        assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0);
+        libc::pthread_rwlock_destroy(rw.get()); //~ ERROR destroyed a locked rwlock
+    }
+}
diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_read_write_deadlock.rs b/tests/compile-fail/sync/libc_pthread_rwlock_read_write_deadlock.rs
new file mode 100644 (file)
index 0000000..dd4707d
--- /dev/null
@@ -0,0 +1,13 @@
+// ignore-windows: No libc on Windows
+
+#![feature(rustc_private)]
+
+extern crate libc;
+
+fn main() {
+    let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);
+    unsafe {
+        assert_eq!(libc::pthread_rwlock_rdlock(rw.get()), 0);
+        libc::pthread_rwlock_wrlock(rw.get()); //~ ERROR: deadlock
+    }
+}
diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_unlock_unlocked.rs b/tests/compile-fail/sync/libc_pthread_rwlock_unlock_unlocked.rs
new file mode 100644 (file)
index 0000000..8b3de53
--- /dev/null
@@ -0,0 +1,12 @@
+// ignore-windows: No libc on Windows
+
+#![feature(rustc_private)]
+
+extern crate libc;
+
+fn main() {
+    let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);
+    unsafe {
+        libc::pthread_rwlock_unlock(rw.get()); //~ ERROR was not locked
+    }
+}
diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_write_read_deadlock.rs b/tests/compile-fail/sync/libc_pthread_rwlock_write_read_deadlock.rs
new file mode 100644 (file)
index 0000000..1b460e7
--- /dev/null
@@ -0,0 +1,13 @@
+// ignore-windows: No libc on Windows
+
+#![feature(rustc_private)]
+
+extern crate libc;
+
+fn main() {
+    let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);
+    unsafe {
+        assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0);
+        libc::pthread_rwlock_rdlock(rw.get()); //~ ERROR: deadlock
+    }
+}
diff --git a/tests/compile-fail/sync/libc_pthread_rwlock_write_write_deadlock.rs b/tests/compile-fail/sync/libc_pthread_rwlock_write_write_deadlock.rs
new file mode 100644 (file)
index 0000000..cc327ec
--- /dev/null
@@ -0,0 +1,13 @@
+// ignore-windows: No libc on Windows
+
+#![feature(rustc_private)]
+
+extern crate libc;
+
+fn main() {
+    let rw = std::cell::UnsafeCell::new(libc::PTHREAD_RWLOCK_INITIALIZER);
+    unsafe {
+        assert_eq!(libc::pthread_rwlock_wrlock(rw.get()), 0);
+        libc::pthread_rwlock_wrlock(rw.get()); //~ ERROR: deadlock
+    }
+}
diff --git a/tests/compile-fail/unaligned_pointers/alignment.rs b/tests/compile-fail/unaligned_pointers/alignment.rs
new file mode 100644 (file)
index 0000000..bac1b92
--- /dev/null
@@ -0,0 +1,11 @@
+fn main() {
+    // miri always gives allocations the worst possible alignment, so a `u8` array is guaranteed
+    // to be at the virtual location 1 (so one byte offset from the ultimate alignemnt location 0)
+    let mut x = [0u8; 20];
+    let x_ptr: *mut u8 = &mut x[0];
+    let y_ptr = x_ptr as *mut u64;
+    unsafe {
+        *y_ptr = 42; //~ ERROR accessing memory with alignment 1, but alignment
+    }
+    panic!("unreachable in miri");
+}
diff --git a/tests/compile-fail/unaligned_pointers/atomic_unaligned.rs b/tests/compile-fail/unaligned_pointers/atomic_unaligned.rs
new file mode 100644 (file)
index 0000000..bdec0ff
--- /dev/null
@@ -0,0 +1,12 @@
+#![feature(core_intrinsics)]
+
+fn main() {
+    // Do a 4-aligned u64 atomic access. That should be UB on all platforms,
+    // even if u64 only has alignment 4.
+    let z = [0u32; 2];
+    let zptr = &z as *const _ as *const u64;
+    unsafe {
+        ::std::intrinsics::atomic_load(zptr);
+        //~^ ERROR accessing memory with alignment 4, but alignment 8 is required
+    }
+}
diff --git a/tests/compile-fail/unaligned_pointers/intptrcast_alignment_check.rs b/tests/compile-fail/unaligned_pointers/intptrcast_alignment_check.rs
new file mode 100644 (file)
index 0000000..1a8df5e
--- /dev/null
@@ -0,0 +1,12 @@
+// Even with intptrcast and without validation, we want to be *sure* to catch bugs
+// that arise from pointers being insufficiently aligned. The only way to achieve
+// that is not not let programs exploit integer information for alignment, so here
+// we test that this is indeed the case.
+fn main() {
+    let x = &mut [0u8; 3];
+    let base_addr = x as *mut _ as usize;
+    let base_addr_aligned = if base_addr % 2 == 0 { base_addr } else { base_addr+1 };
+    let u16_ptr = base_addr_aligned as *mut u16;
+    unsafe { *u16_ptr = 2; } //~ ERROR memory with alignment 1, but alignment 2 is required
+    println!("{:?}", x);
+}
diff --git a/tests/compile-fail/unaligned_pointers/reference_to_packed.rs b/tests/compile-fail/unaligned_pointers/reference_to_packed.rs
new file mode 100644 (file)
index 0000000..08104e9
--- /dev/null
@@ -0,0 +1,19 @@
+// This should fail even without validation/SB
+// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
+
+#![allow(dead_code, unused_variables)]
+
+#[repr(packed)]
+struct Foo {
+    x: i32,
+    y: i32,
+}
+
+fn main() {
+    let foo = Foo {
+        x: 42,
+        y: 99,
+    };
+    let p = unsafe { &foo.x };
+    let i = *p; //~ ERROR memory with alignment 1, but alignment 4 is required
+}
diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr1.rs b/tests/compile-fail/unaligned_pointers/unaligned_ptr1.rs
new file mode 100644 (file)
index 0000000..ee1a130
--- /dev/null
@@ -0,0 +1,9 @@
+// This should fail even without validation
+// compile-flags: -Zmiri-disable-validation
+
+fn main() {
+    let x = [2u16, 3, 4]; // Make it big enough so we don't get an out-of-bounds error.
+    let x = &x[0] as *const _ as *const u32;
+    // This must fail because alignment is violated: the allocation's base is not sufficiently aligned.
+    let _x = unsafe { *x }; //~ ERROR memory with alignment 2, but alignment 4 is required
+}
diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr2.rs b/tests/compile-fail/unaligned_pointers/unaligned_ptr2.rs
new file mode 100644 (file)
index 0000000..853d890
--- /dev/null
@@ -0,0 +1,10 @@
+// This should fail even without validation.
+// compile-flags: -Zmiri-disable-validation
+
+fn main() {
+    let x = [2u32, 3]; // Make it big enough so we don't get an out-of-bounds error.
+    let x = (x.as_ptr() as *const u8).wrapping_offset(3) as *const u32;
+    // This must fail because alignment is violated: the offset is not sufficiently aligned.
+    // Also make the offset not a power of 2, that used to ICE.
+    let _x = unsafe { *x }; //~ ERROR memory with alignment 1, but alignment 4 is required
+}
diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr3.rs b/tests/compile-fail/unaligned_pointers/unaligned_ptr3.rs
new file mode 100644 (file)
index 0000000..43f6b47
--- /dev/null
@@ -0,0 +1,11 @@
+// This should fail even without validation.
+// compile-flags: -Zmiri-disable-validation
+
+fn main() {
+    let x = [2u16, 3, 4, 5]; // Make it big enough so we don't get an out-of-bounds error.
+    let x = &x[0] as *const _ as *const *const u8; // cast to ptr-to-ptr, so that we load a ptr
+    // This must fail because alignment is violated. Test specifically for loading pointers,
+    // which have special code in miri's memory.
+    let _x = unsafe { *x };
+    //~^ ERROR memory with alignment 2, but alignment
+}
diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.rs b/tests/compile-fail/unaligned_pointers/unaligned_ptr_zst.rs
new file mode 100644 (file)
index 0000000..31f88c8
--- /dev/null
@@ -0,0 +1,10 @@
+// This should fail even without validation
+// compile-flags: -Zmiri-disable-validation
+
+fn main() {
+    let x = &2u16;
+    let x = x as *const _ as *const [u32; 0];
+    // This must fail because alignment is violated. Test specifically for loading ZST.
+    let _x = unsafe { *x };
+    //~^ ERROR memory with alignment 2, but alignment 4 is required
+}
diff --git a/tests/compile-fail/unaligned_ptr1.rs b/tests/compile-fail/unaligned_ptr1.rs
deleted file mode 100644 (file)
index ee1a130..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// This should fail even without validation
-// compile-flags: -Zmiri-disable-validation
-
-fn main() {
-    let x = [2u16, 3, 4]; // Make it big enough so we don't get an out-of-bounds error.
-    let x = &x[0] as *const _ as *const u32;
-    // This must fail because alignment is violated: the allocation's base is not sufficiently aligned.
-    let _x = unsafe { *x }; //~ ERROR memory with alignment 2, but alignment 4 is required
-}
diff --git a/tests/compile-fail/unaligned_ptr2.rs b/tests/compile-fail/unaligned_ptr2.rs
deleted file mode 100644 (file)
index 853d890..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// This should fail even without validation.
-// compile-flags: -Zmiri-disable-validation
-
-fn main() {
-    let x = [2u32, 3]; // Make it big enough so we don't get an out-of-bounds error.
-    let x = (x.as_ptr() as *const u8).wrapping_offset(3) as *const u32;
-    // This must fail because alignment is violated: the offset is not sufficiently aligned.
-    // Also make the offset not a power of 2, that used to ICE.
-    let _x = unsafe { *x }; //~ ERROR memory with alignment 1, but alignment 4 is required
-}
diff --git a/tests/compile-fail/unaligned_ptr3.rs b/tests/compile-fail/unaligned_ptr3.rs
deleted file mode 100644 (file)
index 43f6b47..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-// This should fail even without validation.
-// compile-flags: -Zmiri-disable-validation
-
-fn main() {
-    let x = [2u16, 3, 4, 5]; // Make it big enough so we don't get an out-of-bounds error.
-    let x = &x[0] as *const _ as *const *const u8; // cast to ptr-to-ptr, so that we load a ptr
-    // This must fail because alignment is violated. Test specifically for loading pointers,
-    // which have special code in miri's memory.
-    let _x = unsafe { *x };
-    //~^ ERROR memory with alignment 2, but alignment
-}
diff --git a/tests/compile-fail/unaligned_ptr_zst.rs b/tests/compile-fail/unaligned_ptr_zst.rs
deleted file mode 100644 (file)
index 31f88c8..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// This should fail even without validation
-// compile-flags: -Zmiri-disable-validation
-
-fn main() {
-    let x = &2u16;
-    let x = x as *const _ as *const [u32; 0];
-    // This must fail because alignment is violated. Test specifically for loading ZST.
-    let _x = unsafe { *x };
-    //~^ ERROR memory with alignment 2, but alignment 4 is required
-}
diff --git a/tests/compile-fail/unchecked_add1.rs b/tests/compile-fail/unchecked_add1.rs
deleted file mode 100644 (file)
index f48b914..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#![feature(core_intrinsics)]
-fn main() {
-    // MAX overflow
-    unsafe { std::intrinsics::unchecked_add(40000u16, 30000); } //~ ERROR overflow executing `unchecked_add`
-}
diff --git a/tests/compile-fail/unchecked_add2.rs b/tests/compile-fail/unchecked_add2.rs
deleted file mode 100644 (file)
index 1509865..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#![feature(core_intrinsics)]
-fn main() {
-    // MIN overflow
-    unsafe { std::intrinsics::unchecked_add(-30000i16, -8000); } //~ ERROR overflow executing `unchecked_add`
-}
diff --git a/tests/compile-fail/unchecked_div1.rs b/tests/compile-fail/unchecked_div1.rs
deleted file mode 100644 (file)
index 53d8000..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#![feature(core_intrinsics)]
-fn main() {
-    // MIN/-1 cannot be represented
-    unsafe { std::intrinsics::unchecked_div(i16::MIN, -1); } //~ ERROR overflow executing `unchecked_div`
-}
diff --git a/tests/compile-fail/unchecked_mul1.rs b/tests/compile-fail/unchecked_mul1.rs
deleted file mode 100644 (file)
index 050e3ff..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#![feature(core_intrinsics)]
-fn main() {
-    // MAX overflow
-    unsafe { std::intrinsics::unchecked_mul(300u16, 250u16); } //~ ERROR overflow executing `unchecked_mul`
-}
diff --git a/tests/compile-fail/unchecked_mul2.rs b/tests/compile-fail/unchecked_mul2.rs
deleted file mode 100644 (file)
index 4fb7778..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#![feature(core_intrinsics)]
-fn main() {
-    // MIN overflow
-    unsafe { std::intrinsics::unchecked_mul(1_000_000_000i32, -4); } //~ ERROR overflow executing `unchecked_mul`
-}
diff --git a/tests/compile-fail/unchecked_sub1.rs b/tests/compile-fail/unchecked_sub1.rs
deleted file mode 100644 (file)
index 69b32dd..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#![feature(core_intrinsics)]
-fn main() {
-    // MIN overflow
-    unsafe { std::intrinsics::unchecked_sub(14u32, 22); } //~ ERROR overflow executing `unchecked_sub`
-}
diff --git a/tests/compile-fail/unchecked_sub2.rs b/tests/compile-fail/unchecked_sub2.rs
deleted file mode 100644 (file)
index 5609ea7..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-#![feature(core_intrinsics)]
-fn main() {
-    // MAX overflow
-    unsafe { std::intrinsics::unchecked_sub(30000i16, -7000); } //~ ERROR overflow executing `unchecked_sub`
-}
diff --git a/tests/compile-fail/wild_pointer_deref.rs b/tests/compile-fail/wild_pointer_deref.rs
deleted file mode 100644 (file)
index 5780ccc..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-fn main() {
-    let p = 44 as *const i32;
-    let x = unsafe { *p }; //~ ERROR invalid use of 44 as a pointer
-    panic!("this should never print: {}", x);
-}
diff --git a/tests/compile-fail/write_bytes_null.rs b/tests/compile-fail/write_bytes_null.rs
deleted file mode 100644 (file)
index e802221..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#![feature(intrinsics)]
-
-// Directly call intrinsic to avoid debug assertions in libstd
-extern "rust-intrinsic" {
-    fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
-}
-
-fn main() {
-    unsafe { write_bytes::<u8>(std::ptr::null_mut(), 0, 0) }; //~ ERROR invalid use of NULL pointer
-}
diff --git a/tests/compile-fail/write_bytes_overflow.rs b/tests/compile-fail/write_bytes_overflow.rs
deleted file mode 100644 (file)
index a6bf2ac..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-// error-pattern: overflow computing total size of `write_bytes`
-use std::mem;
-
-fn main() {
-    let mut y = 0;
-    unsafe {
-        (&mut y as *mut i32).write_bytes(0u8, 1usize << (mem::size_of::<usize>() * 8 - 1));
-    }
-}