rust/tests/ui/uninit-empty-types.rs
许杰友 Jieyou Xu (Joe) 95ff642797 tests: remove //@ pretty-expanded usages
Done with

```bash
sd '//@ pretty-expanded.*\n' '' tests/ui/**/*.rs
```

and

```
sd '//@pretty-expanded.*\n' '' tests/ui/**/*.rs
```
2024-11-26 02:50:48 +08:00

18 lines
488 B
Rust

//@ build-pass
// Test the uninit() construct returning various empty types.
use std::mem::MaybeUninit;
struct Foo;
#[allow(deprecated)]
pub fn main() {
unsafe {
// `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();
}
}