Re: [PATCH] rust: alloc: Fix `ArrayLayout` allocations
From: Miguel Ojeda
Date: Sat Nov 23 2024 - 12:39:44 EST
On Sat, Nov 23, 2024 at 11:30 AM Asahi Lina <lina@xxxxxxxxxxxxx> wrote:
>
> We were accidentally allocating a layout for the *square* of the object
> size due to a variable shadowing mishap.
Good catch, thanks! (Square?)
`clippy::shadow_reuse` would catch this, but it does catch a lot more
things, sadly.
I sent:
https://github.com/rust-lang/rust-clippy/issues/3433#issuecomment-2495547322
and added it to the Clippy list. If one of the ideas in the issue are
implemented, then I think we should easily enable it.
Similarly, we could do `shadow_unrelated` -- that one seems easier,
and perhaps we should do it anyway, at least a couple cases I saw
would make the code clearer.
Cheers,
Miguel