about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-04-22 12:13:52 +0200
committerRalf Jung <post@ralfj.de>2020-04-23 21:25:27 +0200
commit6b76b0e558d3d5b412b627e953a94e4a93a0ad2a (patch)
tree9af77f3ba0d72609543d0b732493f9761444b640
parent6463ecfe766c60c6dd671725f0ac52e88004f6c9 (diff)
explain what we are testing in mutable_const
-rw-r--r--src/test/ui/consts/miri_unleashed/mutable_const.rs12
-rw-r--r--src/test/ui/consts/miri_unleashed/mutable_const.stderr11
-rw-r--r--src/test/ui/consts/miri_unleashed/mutable_const2.rs2
-rw-r--r--src/test/ui/consts/miri_unleashed/mutable_references_ice.rs2
4 files changed, 18 insertions, 9 deletions
diff --git a/src/test/ui/consts/miri_unleashed/mutable_const.rs b/src/test/ui/consts/miri_unleashed/mutable_const.rs
index 5866f8b4f24..5cc8808be5d 100644
--- a/src/test/ui/consts/miri_unleashed/mutable_const.rs
+++ b/src/test/ui/consts/miri_unleashed/mutable_const.rs
@@ -1,8 +1,13 @@
 // compile-flags: -Zunleash-the-miri-inside-of-you
+// normalize-stderr-test "alloc[0-9]+" -> "allocN"
 
 #![feature(const_raw_ptr_deref)]
 #![feature(const_mut_refs)]
-#![deny(const_err)] // FIXME: ICEs with allow! See #71316.
+#![deny(const_err)] // The `allow` variant is tested by `mutable_const2`.
+//~^ NOTE lint level
+// Here we check that even though `MUTABLE_BEHIND_RAW` is created from a mutable
+// allocation, we intern that allocation as *immutable* and reject writes to it.
+// We avoid the `delay_span_bug` ICE by having compilation fail via the `deny` above.
 
 use std::cell::UnsafeCell;
 
@@ -10,10 +15,13 @@ use std::cell::UnsafeCell;
 const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
 //~^ WARN: skipping const checks
 
-const MUTATING_BEHIND_RAW: () = {
+const MUTATING_BEHIND_RAW: () = { //~ NOTE
     // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
     unsafe {
         *MUTABLE_BEHIND_RAW = 99 //~ ERROR any use of this value will cause an error
+        //~^ NOTE: which is read-only
+        // FIXME would be good to match more of the error message here, but looks like we
+        // normalize *after* checking the annoations here.
     }
 };
 
diff --git a/src/test/ui/consts/miri_unleashed/mutable_const.stderr b/src/test/ui/consts/miri_unleashed/mutable_const.stderr
index 514c103263f..34993247fca 100644
--- a/src/test/ui/consts/miri_unleashed/mutable_const.stderr
+++ b/src/test/ui/consts/miri_unleashed/mutable_const.stderr
@@ -1,25 +1,26 @@
 warning: skipping const checks
-  --> $DIR/mutable_const.rs:10:38
+  --> $DIR/mutable_const.rs:15:38
    |
 LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
    |                                      ^^^^^^^^^^^^^^^^^^^^
 
 error: any use of this value will cause an error
-  --> $DIR/mutable_const.rs:16:9
+  --> $DIR/mutable_const.rs:21:9
    |
 LL | / const MUTATING_BEHIND_RAW: () = {
 LL | |     // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
 LL | |     unsafe {
 LL | |         *MUTABLE_BEHIND_RAW = 99
-   | |         ^^^^^^^^^^^^^^^^^^^^^^^^ writing to alloc2 which is read-only
+   | |         ^^^^^^^^^^^^^^^^^^^^^^^^ writing to allocN which is read-only
+...  |
 LL | |     }
 LL | | };
    | |__-
    |
 note: the lint level is defined here
-  --> $DIR/mutable_const.rs:5:9
+  --> $DIR/mutable_const.rs:6:9
    |
-LL | #![deny(const_err)] // FIXME: ICEs with allow! See #71316.
+LL | #![deny(const_err)] // The `allow` variant is tested by `mutable_const2`.
    |         ^^^^^^^^^
 
 error: aborting due to previous error; 1 warning emitted
diff --git a/src/test/ui/consts/miri_unleashed/mutable_const2.rs b/src/test/ui/consts/miri_unleashed/mutable_const2.rs
index c5b880ba309..c2c7fb18e2a 100644
--- a/src/test/ui/consts/miri_unleashed/mutable_const2.rs
+++ b/src/test/ui/consts/miri_unleashed/mutable_const2.rs
@@ -3,7 +3,7 @@
 // rustc-env:RUST_BACKTRACE=0
 // normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET"
 // normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS"
-// normalize-stderr-test "interpret/intern.rs:[0-9]*:[0-9]*" -> "interpret/intern.rs:LL:CC"
+// normalize-stderr-test "interpret/intern.rs:[0-9]+:[0-9]+" -> "interpret/intern.rs:LL:CC"
 
 #![feature(const_raw_ptr_deref)]
 #![feature(const_mut_refs)]
diff --git a/src/test/ui/consts/miri_unleashed/mutable_references_ice.rs b/src/test/ui/consts/miri_unleashed/mutable_references_ice.rs
index 635cad81c97..9d8d5f513c7 100644
--- a/src/test/ui/consts/miri_unleashed/mutable_references_ice.rs
+++ b/src/test/ui/consts/miri_unleashed/mutable_references_ice.rs
@@ -3,7 +3,7 @@
 // rustc-env:RUST_BACKTRACE=0
 // normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET"
 // normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS"
-// normalize-stderr-test "interpret/intern.rs:[0-9]*:[0-9]*" -> "interpret/intern.rs:LL:CC"
+// normalize-stderr-test "interpret/intern.rs:[0-9]+:[0-9]+" -> "interpret/intern.rs:LL:CC"
 
 #![allow(const_err)]