Skip to content

Commit 51f80b7

Browse files
authored
Rollup merge of rust-lang#72366 - nnethercote:tiny-vecs-are-dumb-followup, r=Amanieu
Adjust the zero check in `RawVec::grow`. This was supposed to land as part of rust-lang#72227. (I wish `git push` would abort when you have uncommited changes.) r? @Amanieu
2 parents c93ddbf + 9eb0399 commit 51f80b7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/liballoc/raw_vec.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,15 @@ impl<T, A: AllocRef> RawVec<T, A> {
401401
needed_extra_capacity: usize,
402402
placement: ReallocPlacement,
403403
) -> Result<(), TryReserveError> {
404+
// This is ensured by the calling contexts.
405+
debug_assert!(needed_extra_capacity > 0);
406+
404407
if mem::size_of::<T>() == 0 {
405408
// Since we return a capacity of `usize::MAX` when `elem_size` is
406409
// 0, getting to here necessarily means the `RawVec` is overfull.
407410
return Err(CapacityOverflow);
408411
}
409412

410-
if needed_extra_capacity == 0 {
411-
return Ok(());
412-
}
413-
414413
// Nothing we can really do about these checks, sadly.
415414
let required_cap =
416415
used_capacity.checked_add(needed_extra_capacity).ok_or(CapacityOverflow)?;

0 commit comments

Comments
 (0)