diff options
| author | bors <bors@rust-lang.org> | 2020-05-20 19:29:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-05-20 19:29:01 +0000 |
| commit | 0aa6751c19d3ba80df5b0b02c00bf44e13c97e80 (patch) | |
| tree | 2ddddb42019aa9592270dedf9eb4ac4ce3229bf2 /src/liballoc | |
| parent | 8858a435f3eef655df3e4fb6bec15d33e44a374e (diff) | |
| parent | 51f80b7630d8b9c3878f59cbd0cf93579f8fcdcb (diff) | |
| download | rust-0aa6751c19d3ba80df5b0b02c00bf44e13c97e80.tar.gz rust-0aa6751c19d3ba80df5b0b02c00bf44e13c97e80.zip | |
Auto merge of #72378 - Dylan-DPC:rollup-m87bp2d, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #71863 (Suggest fixes and add error recovery for `use foo::self`) - #72139 (Make `fold` standalone.) - #72275 (Continue lowering for unsupported async generator instead of returning an error.) - #72361 (split_inclusive: add tracking issue number (72360)) - #72364 (Remove unused dependencies) - #72366 (Adjust the zero check in `RawVec::grow`.) Failed merges: r? @ghost
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)?; |
