Re: [PATCH] rust: alloc: test drop behavior of Vec::drain_all

From: Miguel Ojeda

Date: Tue Nov 03 2026 - 06:59:18 EST


On Tue, Nov 3, 2026 at 11:32 AM Peder Bergan <peder.bergan@xxxxxxxxx> wrote:
>
> This adds KUnit coverage for the ownership and destruction behavior of
> Vec::drain_all. The existing example consumes integers to exhaustion,
> which cannot exercise destruction of unconsumed resource-owning values.
>
> The new tests cover partial, absent and complete consumption, plus an
> empty vector. In the partial case, the first yielded value stays alive
> after both the drain and the vector are dropped. Per-element counters
> check that each value is destroyed exactly once by its current owner.

[ A couple procedural nits, since the message joined my inbox while I
was there. ]

This seems to repeat part of the commit message -- is there a reason?

> Base: alloc-next at 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4.

The hash should go into `--base` in `git format-patch`, that way other
tooling can pick it up (it is good to mention the branch name here,
nevertheless).

> + // The caller owns the yielded value, while the drain drops
> the remaining values.

I think your patch may be wrapped and so it cannot be easily applied
-- please use `git send-email` or `b4` to handle that.

I hope that helps!

Cheers,
Miguel