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:
parent
e7bdc5f9f8
commit
0bcac8a7f2
2 changed files with 25 additions and 0 deletions
|
@ -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())))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue