]> git.lizzy.rs Git - rust.git/commitdiff
make sure our disable flags do not miss all bugs; move type-assert intrinsic tests...
authorRalf Jung <post@ralfj.de>
Tue, 14 Apr 2020 07:58:58 +0000 (09:58 +0200)
committerRalf Jung <post@ralfj.de>
Tue, 14 Apr 2020 08:23:47 +0000 (10:23 +0200)
tests/compile-fail/dangling_pointers/dangling_pointer_deref.rs
tests/compile-fail/dangling_pointers/dangling_zst_deref.rs
tests/compile-fail/intrinsics/uninit_uninhabited_type.rs [new file with mode: 0644]
tests/compile-fail/intrinsics/zero_fn_ptr.rs [new file with mode: 0644]
tests/compile-fail/invalid_bool.rs
tests/compile-fail/invalid_char.rs
tests/compile-fail/invalid_enum_discriminant.rs
tests/compile-fail/invalid_int.rs [new file with mode: 0644]
tests/compile-fail/invalid_zero_init.rs [deleted file]
tests/compile-fail/overwriting_part_of_relocation_makes_the_rest_undefined.rs
tests/compile-fail/uninit_uninhabited_type.rs [deleted file]

index f2c7ec584fefba2394b6eacf2f6b428b1710836a..e088a5532581fcae1e99035272570a17e36239a9 100644 (file)
@@ -1,3 +1,6 @@
+// Make sure we find these even with many checks disabled.
+// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
+
 fn main() {
     let p = {
         let b = Box::new(42);
index 13e5f9d321735c336139fe8eeb1303a32555481b..f1b5149dabb41ffc6c6e3bf6cfb1c270ee8bdea9 100644 (file)
@@ -1,3 +1,6 @@
+// Make sure we find these even with many checks disabled.
+// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
+
 fn main() {
     let p = {
         let b = Box::new(42);
diff --git a/tests/compile-fail/intrinsics/uninit_uninhabited_type.rs b/tests/compile-fail/intrinsics/uninit_uninhabited_type.rs
new file mode 100644 (file)
index 0000000..deb3586
--- /dev/null
@@ -0,0 +1,7 @@
+// error-pattern: the evaluated program aborted execution: attempted to instantiate uninhabited type `!`
+#![feature(never_type)]
+
+#[allow(deprecated, invalid_value)]
+fn main() {
+    unsafe { std::mem::uninitialized::<!>() };
+}
diff --git a/tests/compile-fail/intrinsics/zero_fn_ptr.rs b/tests/compile-fail/intrinsics/zero_fn_ptr.rs
new file mode 100644 (file)
index 0000000..81dbf6c
--- /dev/null
@@ -0,0 +1,6 @@
+// error-pattern: the evaluated program aborted execution: attempted to zero-initialize type `fn()`, which is invalid
+
+#[allow(deprecated, invalid_value)]
+fn main() {
+    unsafe { std::mem::zeroed::<fn()>() };
+}
index 6ccea35316365ca994780aae5a3dbd4b08d36895..38033146ade828ac0d66aad0959e9f3d654d528d 100644 (file)
@@ -1,5 +1,6 @@
 // Validation makes this fail in the wrong place
-// compile-flags: -Zmiri-disable-validation
+// Make sure we find these even with many checks disabled.
+// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
 
 fn main() {
     let b = unsafe { std::mem::transmute::<u8, bool>(2) };
index ed61fcbe9d52f35bde42439a756299d77b16ad6c..ab10ab1e2173dc266c5450e7dd0cbd569039e713 100644 (file)
@@ -1,5 +1,6 @@
 // Validation makes this fail in the wrong place
-// compile-flags: -Zmiri-disable-validation
+// Make sure we find these even with many checks disabled.
+// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
 
 fn main() {
     assert!(std::char::from_u32(-1_i32 as u32).is_none());
index c1b8727c129b9a17b4bc8553e497503e6c3341fc..cdbea6aa1223455df83a2a18c4722a3746e70709 100644 (file)
@@ -1,5 +1,6 @@
 // Validation makes this fail in the wrong place
-// compile-flags: -Zmiri-disable-validation
+// 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: invalid enum discriminant
 
diff --git a/tests/compile-fail/invalid_int.rs b/tests/compile-fail/invalid_int.rs
new file mode 100644 (file)
index 0000000..26a8580
--- /dev/null
@@ -0,0 +1,8 @@
+// Validation makes this fail in the wrong place
+// Make sure we find these even with many checks disabled.
+// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
+
+fn main() {
+    let i = unsafe { std::mem::MaybeUninit::<i32>::uninit().assume_init() };
+    let _x = i + 0; //~ ERROR this operation requires initialized memory
+}
diff --git a/tests/compile-fail/invalid_zero_init.rs b/tests/compile-fail/invalid_zero_init.rs
deleted file mode 100644 (file)
index 78c2b0f..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
- // error-pattern: the evaluated program aborted execution: attempted to zero-initialize type `fn()`, which is invalid
-
-#[allow(deprecated, invalid_value)]
-fn main() {
-    unsafe { std::mem::zeroed::<fn()>() };
-}
index d8182aaae662ef1d4c6f42f36fa09f7c9e2b21df..3eab4c0f3d5eb5f6bd2fa2a5f55cbe55a1e7dc50 100644 (file)
@@ -1,3 +1,6 @@
+// Make sure we find these even with many checks disabled.
+// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
+
 fn main() {
     let mut p = &42;
     unsafe {
diff --git a/tests/compile-fail/uninit_uninhabited_type.rs b/tests/compile-fail/uninit_uninhabited_type.rs
deleted file mode 100644 (file)
index b904883..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
- // error-pattern: the evaluated program aborted execution: attempted to instantiate uninhabited type `!`
-#![feature(never_type)]
-
-#[allow(deprecated, invalid_value)]
-fn main() {
-    unsafe { std::mem::uninitialized::<!>() };
-}