]> git.lizzy.rs Git - rust.git/blob - src/test/ui/uninit-empty-types.rs
Merge commit 'efa8f5521d3813cc897ba29ea0ef98c7aef66bb6' into rustfmt-subtree
[rust.git] / src / test / ui / uninit-empty-types.rs
1 // build-pass
2 // Test the uninit() construct returning various empty types.
3
4 // pretty-expanded FIXME #23616
5
6 use std::mem::MaybeUninit;
7
8 struct Foo;
9
10 #[allow(deprecated)]
11 pub fn main() {
12     unsafe {
13         // `Foo` and `[Foo; 2]` are both zero sized and inhabited, so this is safe.
14         let _x: Foo = MaybeUninit::uninit().assume_init();
15         let _x: [Foo; 2] = MaybeUninit::uninit().assume_init();
16         let _x: Foo = std::mem::uninitialized();
17         let _x: [Foo; 2] = std::mem::uninitialized();
18     }
19 }