diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-05-20 14:21:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-20 14:21:13 +0200 |
| commit | 51f80b7630d8b9c3878f59cbd0cf93579f8fcdcb (patch) | |
| tree | 45f7bb10d259dc687ebfe532667daf95123bc9ee /src/liballoc | |
| parent | c93ddbf8110e135f9f673549058608184aef2c72 (diff) | |
| parent | 9eb0399a9d506f5f421180fa00ee3eec61a3a41e (diff) | |
| download | rust-51f80b7630d8b9c3878f59cbd0cf93579f8fcdcb.tar.gz rust-51f80b7630d8b9c3878f59cbd0cf93579f8fcdcb.zip | |
Rollup merge of #72366 - nnethercote:tiny-vecs-are-dumb-followup, r=Amanieu
Adjust the zero check in `RawVec::grow`. This was supposed to land as part of #72227. (I wish `git push` would abort when you have uncommited changes.) r? @Amanieu
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/raw_vec.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index f348b5b6978..2bd4733db42 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -401,16 +401,15 @@ impl<T, A: AllocRef> RawVec<T, A> { needed_extra_capacity: usize, placement: ReallocPlacement, ) -> Result<(), TryReserveError> { + // This is ensured by the calling contexts. + debug_assert!(needed_extra_capacity > 0); + if mem::size_of::<T>() == 0 { // Since we return a capacity of `usize::MAX` when `elem_size` is // 0, getting to here necessarily means the `RawVec` is overfull. return Err(CapacityOverflow); } - if needed_extra_capacity == 0 { - return Ok(()); - } - // Nothing we can really do about these checks, sadly. let required_cap = used_capacity.checked_add(needed_extra_capacity).ok_or(CapacityOverflow)?; |
