Re: [PATCH v9 00/29] Generic `Allocator` support for Rust
From: Janne Grunau
Date: Sat Nov 16 2024 - 09:21:21 EST
On Fri, Nov 15, 2024 at 03:00:43PM +0100, Alice Ryhl wrote:
> 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.
I have branch rebased onto rust-next and Danilo's "Device / Driver PCI /
Platform Rust abstractions". In addition to coerce_unsized for kbox
kvec misses the unproblematic methods clear and truncate and
array_try_from_vec. drain() as taken from the rust library looks like
more effort considering kvec's IntoIter.
Janne