]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/partial_ptr_overwrite.rs
Rollup merge of #85766 - workingjubilee:file-options, r=yaahc
[rust.git] / src / test / ui / consts / const-eval / partial_ptr_overwrite.rs
1 // Test for the behavior described in <https://github.com/rust-lang/rust/issues/87184>.
2 #![feature(const_mut_refs)]
3
4 const PARTIAL_OVERWRITE: () = {
5     let mut p = &42;
6     unsafe {
7         let ptr: *mut _ = &mut p;
8         *(ptr as *mut u8) = 123; //~ ERROR any use of this value
9         //~| unable to overwrite parts of a pointer
10         //~| WARN previously accepted
11     }
12     let x = *p;
13 };
14
15 fn main() {}