]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.rs
Special sync of 'e89801553ddbaccdeb2eac4db08900edb51ac7ff'
[rust.git] / src / test / ui / consts / const-eval / assign-to-static-within-other-static-2.rs
1 // New test for #53818: modifying static memory at compile-time is not allowed.
2 // The test should never compile successfully
3
4 #![feature(const_raw_ptr_deref, const_mut_refs)]
5
6 use std::cell::UnsafeCell;
7
8 struct Foo(UnsafeCell<u32>);
9
10 unsafe impl Send for Foo {}
11 unsafe impl Sync for Foo {}
12
13 static FOO: Foo = Foo(UnsafeCell::new(42));
14
15 static BAR: () = unsafe {
16     *FOO.0.get() = 5; //~ ERROR
17 };
18
19 fn main() {}