Closed
Description
Location
https://doc.rust-lang.org/std/vec/struct.Vec.html#method.reserve (and several other methods)
Summary
Vec::<()>::new().capacity()
is usize::MAX
, which is greater than isize::MAX
. Calling reserve(1)
on this vector does not panic, and the capacity afterwards is still greater than isize::MAX
. The docs say this should unconditionally panic.
I would find it reasonable to rely on this documentation as part of ensuring soundness of some unsafe code interacting with Vec
, without duplicating the assertion in my code.
This same comment is repeated on several other Vec
methods, and the same thing applies.
For reference, #117437 and #99790 are another issue and a PR touching on this same sentence of the documentation.