mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 10:18:25 +00:00
Add regression test
This commit is contained in:
parent
5b74275f89
commit
e159cf0c9e
15
tests/ui/statics/read_before_init.rs
Normal file
15
tests/ui/statics/read_before_init.rs
Normal file
@ -0,0 +1,15 @@
|
||||
//@ check-pass
|
||||
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
pub static X: (i32, MaybeUninit<i32>) = (1, foo(&X.0));
|
||||
|
||||
const fn foo(x: &i32) -> MaybeUninit<i32> {
|
||||
let mut temp = MaybeUninit::<i32>::uninit();
|
||||
unsafe {
|
||||
std::ptr::copy(x, temp.as_mut_ptr(), 1);
|
||||
}
|
||||
temp
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
x
Reference in New Issue
Block a user