2019-12-21 21:43:13 -05:00
|
|
|
// build-pass
|
2014-01-16 18:47:42 -05:00
|
|
|
// Test the uninit() construct returning various empty types.
|
|
|
|
|
2015-03-22 13:13:15 -07:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2019-12-21 21:43:13 -05:00
|
|
|
use std::mem::MaybeUninit;
|
2014-01-16 18:47:42 -05:00
|
|
|
|
|
|
|
struct Foo;
|
|
|
|
|
2019-07-04 11:24:56 -04:00
|
|
|
#[allow(deprecated)]
|
2014-01-17 01:02:16 -05:00
|
|
|
pub fn main() {
|
2014-01-16 18:47:42 -05:00
|
|
|
unsafe {
|
2019-12-21 21:43:13 -05:00
|
|
|
// `Foo` and `[Foo; 2]` are both zero sized and inhabited, so this is safe.
|
|
|
|
let _x: Foo = MaybeUninit::uninit().assume_init();
|
|
|
|
let _x: [Foo; 2] = MaybeUninit::uninit().assume_init();
|
|
|
|
let _x: Foo = std::mem::uninitialized();
|
|
|
|
let _x: [Foo; 2] = std::mem::uninitialized();
|
2014-01-16 18:47:42 -05:00
|
|
|
}
|
|
|
|
}
|