diff options
Diffstat (limited to 'tests/ui/consts/const-eval/ub-write-through-immutable.rs')
| -rw-r--r-- | tests/ui/consts/const-eval/ub-write-through-immutable.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/tests/ui/consts/const-eval/ub-write-through-immutable.rs b/tests/ui/consts/const-eval/ub-write-through-immutable.rs index 795ac602a1c..28c7a617a4d 100644 --- a/tests/ui/consts/const-eval/ub-write-through-immutable.rs +++ b/tests/ui/consts/const-eval/ub-write-through-immutable.rs @@ -1,21 +1,19 @@ //! Ensure we catch UB due to writing through a shared reference. #![allow(invalid_reference_casting)] -use std::mem; use std::cell::UnsafeCell; +use std::mem; const WRITE_AFTER_CAST: () = unsafe { let mut x = 0; let ptr = &x as *const i32 as *mut i32; - *ptr = 0; //~ERROR: evaluation of constant value failed - //~| NOTE immutable + *ptr = 0; //~ERROR: immutable }; const WRITE_AFTER_TRANSMUTE: () = unsafe { let mut x = 0; let ptr: *mut i32 = mem::transmute(&x); - *ptr = 0; //~ERROR: evaluation of constant value failed - //~| NOTE immutable + *ptr = 0; //~ERROR: immutable }; // it's okay when there is interior mutability; |
