Expand description
Reconstruct rustc’s vec![..] lowering based on Box<MaybeUninit<[T; N]>>.
In inline_selected_functions, we inline the special box_assume_init_into_vec_unsafe
function. After that, a vec![elems...] expression ends up looking something like:
ⓘ
let mut box = Box::new_uninit::<[T; N]>();
(((*box).1).0).0 = [elems...];
let box = Box::assume_init(box);
..The split between assignment and assume_init is for performance. The assume_init call is
unsafe, so we rewrite it to use Box::write instead, and even Box::new if possible.
ⓘ
let box_uninit = Box::new_uninit::<[T; N]>();
let arr = [elems...];
let box = Box::write::<[T; N]>(box_uninit, arr);
..Structs§
Functions§
- assume_
init_ 🔒fn_ ptr - box_
generics 🔒 - box_
inner 🔒 - branched_
before 🔒 - find_
array_ 🔒assign - Given
src, find the unique statement of the formsrc = [elems...]where the rvalue is an array aggregate. - find_
assume_ 🔒init_ tail - find_
move_ 🔒in_ block - find_
next_ 🔒drop - find_
next_ 🔒move_ of - is_
new_ 🔒uninit_ call - unique_
target 🔒