]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/recursive-zst-static.rs
Rollup merge of #106963 - compiler-errors:scope-expr-dupe, r=michaelwoerister
[rust.git] / tests / ui / consts / recursive-zst-static.rs
1 // revisions: default unleash
2 //[unleash]compile-flags: -Zunleash-the-miri-inside-of-you
3
4 // This test ensures that we do not allow ZST statics to initialize themselves without ever
5 // actually creating a value of that type. This is important, as the ZST may have private fields
6 // that users can reasonably expect to only get initialized by their own code. Thus unsafe code
7 // can depend on this fact and will thus do unsound things when it is violated.
8 // See https://github.com/rust-lang/rust/issues/71078 for more details.
9
10 static FOO: () = FOO; //~ cycle detected when const-evaluating + checking `FOO`
11
12 fn main() {
13     FOO
14 }