blob: 7e7ef6867ed075c2cd8e790575763d6164a8e321 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
// check-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete
use std::mem;
// Neither of the uninits below are currently accepted as not UB, however,
// this code does not run and is merely checking that we do not ICE on this pattern,
// so this is fine.
fn foo<const SIZE: usize>() {
let arr: [u8; SIZE] = unsafe {
#[allow(deprecated)]
let array: [u8; SIZE] = mem::uninitialized();
array
};
}
fn bar<const SIZE: usize>() {
let arr: [u8; SIZE] = unsafe {
let array: [u8; SIZE] = mem::MaybeUninit::uninit().assume_init();
array
};
}
fn main() {}
|