1
Fork 0

Add invariant to Vec::pop that len < cap if pop successful

Fixes: https://github.com/rust-lang/rust/issues/114334
This commit is contained in:
Arthur Carcano 2023-08-02 14:47:38 +02:00
parent e7bdc5f9f8
commit 0bcac8a7f2
2 changed files with 25 additions and 0 deletions

View file

@ -1956,6 +1956,7 @@ impl<T, A: Allocator> Vec<T, A> {
} else {
unsafe {
self.len -= 1;
core::intrinsics::assume(self.len < self.capacity());
Some(ptr::read(self.as_ptr().add(self.len())))
}
}