diff options
| author | Arthur Carcano <arthur.carcano@ocamlpro.com> | 2023-08-02 14:47:38 +0200 |
|---|---|---|
| committer | Arthur Carcano <arthur.carcano@ocamlpro.com> | 2023-10-16 18:49:25 +0200 |
| commit | 0bcac8a7f25b994ddd3c2deda74dae04c677b816 (patch) | |
| tree | 2608c9c74afb59f2d8ae4542638f78c05e03b695 /library/alloc/src/vec | |
| parent | e7bdc5f9f869219e8d20060b42a09ea10a837851 (diff) | |
| download | rust-0bcac8a7f25b994ddd3c2deda74dae04c677b816.tar.gz rust-0bcac8a7f25b994ddd3c2deda74dae04c677b816.zip | |
Add invariant to Vec::pop that len < cap if pop successful
Fixes: https://github.com/rust-lang/rust/issues/114334
Diffstat (limited to 'library/alloc/src/vec')
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 35015238e6e..3b12c1bee0b 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -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()))) } } |
