Re: [PATCH v7 06/10] rust: id_pool: take a NonZero capacity in with_capacity

From: Alexandre Courbot

Date: Fri Aug 21 2026 - 04:40:10 EST


On Mon Aug 17, 2026 at 4:04 PM JST, Eliot Courtney wrote:
> There is no good reason to allocate an IdPool with zero capacity.
> Reflect this in IdPool::with_capacity.
>
> Signed-off-by: Eliot Courtney <ecourtney@xxxxxxxxxx>

I am not sure this one is justifiable; `KVec::with_capacity(0)` is
doable, so why not here? As long as it doesn't introduce soundness
issues I'd say this is the caller's business; a driver with a legitimate
empty IdPool use-case would now need to special-case it.

Now we do have an actual soundness issue with zero-sized IdPools, which
is that `find_unused_id` would panic with `CONFIG_RUST_BITMAP_HARDENED`,
but as I said on patch 5 I don't think it should anyway. Another
potential issue is that `grow_request` would not grow anything; but that
should be fixed there by handling the `capacity == 0` case. Actually
that would give justification for empty IdPools to exist: just like a
vector can start empty and grow, so can an IdPool.