File tree Expand file tree Collapse file tree 4 files changed +18
-9
lines changed
src/test/ui/consts/miri_unleashed Expand file tree Collapse file tree 4 files changed +18
-9
lines changed Original file line number Diff line number Diff line change 11// compile-flags: -Zunleash-the-miri-inside-of-you
2+ // normalize-stderr-test "alloc[0-9]+" -> "allocN"
23
34#![ feature( const_raw_ptr_deref) ]
45#![ feature( const_mut_refs) ]
5- #![ deny( const_err) ] // FIXME: ICEs with allow! See #71316.
6+ #![ deny( const_err) ] // The `allow` variant is tested by `mutable_const2`.
7+ //~^ NOTE lint level
8+ // Here we check that even though `MUTABLE_BEHIND_RAW` is created from a mutable
9+ // allocation, we intern that allocation as *immutable* and reject writes to it.
10+ // We avoid the `delay_span_bug` ICE by having compilation fail via the `deny` above.
611
712use std:: cell:: UnsafeCell ;
813
914// make sure we do not just intern this as mutable
1015const MUTABLE_BEHIND_RAW : * mut i32 = & UnsafeCell :: new ( 42 ) as * const _ as * mut _ ;
1116//~^ WARN: skipping const checks
1217
13- const MUTATING_BEHIND_RAW : ( ) = {
18+ const MUTATING_BEHIND_RAW : ( ) = { //~ NOTE
1419 // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
1520 unsafe {
1621 * MUTABLE_BEHIND_RAW = 99 //~ ERROR any use of this value will cause an error
22+ //~^ NOTE: which is read-only
23+ // FIXME would be good to match more of the error message here, but looks like we
24+ // normalize *after* checking the annoations here.
1725 }
1826} ;
1927
Original file line number Diff line number Diff line change 11warning: skipping const checks
2- --> $DIR/mutable_const.rs:10 :38
2+ --> $DIR/mutable_const.rs:15 :38
33 |
44LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
55 | ^^^^^^^^^^^^^^^^^^^^
66
77error: any use of this value will cause an error
8- --> $DIR/mutable_const.rs:16 :9
8+ --> $DIR/mutable_const.rs:21 :9
99 |
1010LL | / const MUTATING_BEHIND_RAW: () = {
1111LL | | // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
1212LL | | unsafe {
1313LL | | *MUTABLE_BEHIND_RAW = 99
14- | | ^^^^^^^^^^^^^^^^^^^^^^^^ writing to alloc2 which is read-only
14+ | | ^^^^^^^^^^^^^^^^^^^^^^^^ writing to allocN which is read-only
15+ ... |
1516LL | | }
1617LL | | };
1718 | |__-
1819 |
1920note: the lint level is defined here
20- --> $DIR/mutable_const.rs:5 :9
21+ --> $DIR/mutable_const.rs:6 :9
2122 |
22- LL | #![deny(const_err)] // FIXME: ICEs with allow! See #71316 .
23+ LL | #![deny(const_err)] // The `allow` variant is tested by `mutable_const2` .
2324 | ^^^^^^^^^
2425
2526error: aborting due to previous error; 1 warning emitted
Original file line number Diff line number Diff line change 33// rustc-env:RUST_BACKTRACE=0
44// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET"
55// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS"
6- // normalize-stderr-test "interpret/intern.rs:[0-9]* :[0-9]* " -> "interpret/intern.rs:LL:CC"
6+ // normalize-stderr-test "interpret/intern.rs:[0-9]+ :[0-9]+ " -> "interpret/intern.rs:LL:CC"
77
88#![ feature( const_raw_ptr_deref) ]
99#![ feature( const_mut_refs) ]
Original file line number Diff line number Diff line change 33// rustc-env:RUST_BACKTRACE=0
44// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET"
55// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS"
6- // normalize-stderr-test "interpret/intern.rs:[0-9]* :[0-9]* " -> "interpret/intern.rs:LL:CC"
6+ // normalize-stderr-test "interpret/intern.rs:[0-9]+ :[0-9]+ " -> "interpret/intern.rs:LL:CC"
77
88#![ allow( const_err) ]
99
You can’t perform that action at this time.
0 commit comments