2019-12-22 02:43:13 +00:00
|
|
|
//@ build-pass
|
2014-01-16 23:47:42 +00:00
|
|
|
// Test the uninit() construct returning various empty types.
|
|
|
|
|
2015-03-22 20:13:15 +00:00
|
|
|
//@ pretty-expanded FIXME #23616
|
|
|
|
|
2019-12-22 02:43:13 +00:00
|
|
|
use std::mem::MaybeUninit;
|
2014-01-16 23:47:42 +00:00
|
|
|
|
|
|
|
struct Foo;
|
|
|
|
|
2019-07-04 15:24:56 +00:00
|
|
|
#[allow(deprecated)]
|
2014-01-17 06:02:16 +00:00
|
|
|
pub fn main() {
|
2014-01-16 23:47:42 +00:00
|
|
|
unsafe {
|
2019-12-22 02:43:13 +00: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 23:47:42 +00:00
|
|
|
}
|
|
|
|
}
|