Re: [PATCH v9 00/29] Generic `Allocator` support for Rust
From: Alice Ryhl
Date: Fri Nov 15 2024 - 09:01:53 EST
On Fri, Nov 15, 2024 at 12:33 PM Asahi Lina <lina@xxxxxxxxxxxxx> wrote:
>
> We (Asahi Linux) noticed that this doesn't support unsized types, which
> is a regression from the alloc Box. drm/asahi uses boxed trait objects
> to generalize across certain object types like render commands, so this
> breaks the driver.
>
> Is there a plan to add this back in? AIUI this would need the
> coerce_unsized unstable feature, but is there any other blocker?
We're already using coerce_unsized for Arc, so I see no reason we
can't just add that for KBox too. Soon, we should be able to use the
derive macro [1] I proposed to do this without unstable language
features. The limitation that the RFC mentions for custom allocators
does not apply to KBox because it uses PhantomData<A> instead of A for
the allocator field.
Alice
[1]: https://rust-lang.github.io/rfcs/3621-derive-smart-pointer.html