mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 01:04:03 +00:00
Uninitialized boxes: add test for zero-size allocations
This commit is contained in:
parent
ca1cfdab78
commit
227db40a98
18
src/liballoc/tests/boxed.rs
Normal file
18
src/liballoc/tests/boxed.rs
Normal file
@ -0,0 +1,18 @@
|
||||
use std::ptr::NonNull;
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
#[test]
|
||||
fn unitialized_zero_size_box() {
|
||||
assert_eq!(
|
||||
&*Box::<()>::new_uninit() as *const _,
|
||||
NonNull::<MaybeUninit<()>>::dangling().as_ptr(),
|
||||
);
|
||||
assert_eq!(
|
||||
Box::<[()]>::new_uninit_slice(4).as_ptr(),
|
||||
NonNull::<MaybeUninit<()>>::dangling().as_ptr(),
|
||||
);
|
||||
assert_eq!(
|
||||
Box::<[String]>::new_uninit_slice(0).as_ptr(),
|
||||
NonNull::<MaybeUninit<String>>::dangling().as_ptr(),
|
||||
);
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
#![feature(box_syntax)]
|
||||
#![feature(drain_filter)]
|
||||
#![feature(exact_size_is_empty)]
|
||||
#![feature(new_uninit)]
|
||||
#![feature(option_flattening)]
|
||||
#![feature(pattern)]
|
||||
#![feature(repeat_generic_slice)]
|
||||
@ -15,6 +16,7 @@ use std::collections::hash_map::DefaultHasher;
|
||||
|
||||
mod arc;
|
||||
mod binary_heap;
|
||||
mod boxed;
|
||||
mod btree;
|
||||
mod cow_str;
|
||||
mod fmt;
|
||||
|
Loading…
Reference in New Issue
Block a user