Closed
Description
VecDeque
has an internal method called buffer_as_slice
, which returns an &[T]
containing the entire capacity of the VecDeque
. This is undefined behavior if the VecDeque
is not full, since some elements of the backing RawVec
may be uninitialized. However, this invariant is not documented on buffer_as_slice
and is not respected in practice. For example, VecDeque::iter
calls buffer_as_slice
unconditionally:
rust/src/liballoc/collections/vec_deque.rs
Lines 959 to 962 in 34c5cd9
This one seems so obvious that I'm wondering if I've overlooked something. cc @rust-lang/wg-unsafe-code-guidelines
Found while doing #74172.