mirror of
https://github.com/rust-lang/rust
synced 2024-09-06 01:11:17 +00:00
5e5f3341e3
Make `core::mem::zeroed` const stable. Newly stable API: // core::mem pub const unsafe fn zeroed<T>() -> T; This is stabilized with `const_maybe_uninit_zeroed` since it is a simple wrapper. In order to make this possible, intrinsics `assert_zero_valid` was made const stable under `const_assert_type2`. `assert_mem_uninitialized_valid` was also made const stable since it is under the same gate.
23 lines
588 B
Rust
23 lines
588 B
Rust
#![feature(never_type)]
|
|
#![feature(core_intrinsics)]
|
|
|
|
use std::intrinsics;
|
|
|
|
#[allow(invalid_value)]
|
|
fn main() {
|
|
use std::mem::MaybeUninit;
|
|
|
|
const _BAD1: () = unsafe {
|
|
MaybeUninit::<!>::uninit().assume_init();
|
|
//~^ERROR: evaluation of constant value failed
|
|
};
|
|
const _BAD2: () = {
|
|
intrinsics::assert_mem_uninitialized_valid::<&'static i32>();
|
|
//~^ERROR: evaluation of constant value failed
|
|
};
|
|
const _BAD3: () = {
|
|
intrinsics::assert_zero_valid::<&'static i32>();
|
|
//~^ERROR: evaluation of constant value failed
|
|
};
|
|
}
|