blob: dc5813d8c7834e694be1d35c7178a9de32634f45 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
//! Ensure that writing to `S` while initializing `S` errors.
//! Regression test for <https://github.com/rust-lang/rust/issues/142404>.
#![allow(dead_code)]
struct Foo {
x: i32,
y: (),
}
static S: Foo = Foo {
x: 0,
y: unsafe {
(&raw const S.x).cast_mut().write(1); //~ERROR access itself during initialization
},
};
static mut S2: Foo = Foo {
x: 0,
y: unsafe {
S2.x = 1; //~ERROR access itself during initialization
},
};
fn main() {}
|