Re: [PATCH 2/2] rust: workqueue: remove HasWork::OFFSET
From: Tamir Duberstein
Date: Sun Mar 16 2025 - 08:56:23 EST
On Sat, Mar 15, 2025 at 2:12 PM Tamir Duberstein <tamird@xxxxxxxxx> wrote:
>
> On Sat, Mar 15, 2025 at 2:06 PM Benno Lossin <benno.lossin@xxxxxxxxx> wrote:
> >
> > On Sat Mar 15, 2025 at 4:37 PM CET, Tamir Duberstein wrote:
> > > On Sat, Mar 15, 2025 at 5:30 AM Benno Lossin <benno.lossin@xxxxxxxxx> wrote:
> > >>
> > >> On Fri Mar 14, 2025 at 9:44 PM CET, Tamir Duberstein wrote:
> > >> > On Fri, Mar 14, 2025 at 3:20 PM Benno Lossin <benno.lossin@xxxxxxxxx> wrote:
> > >> >>
> > >> >> On Fri Mar 7, 2025 at 10:58 PM CET, Tamir Duberstein wrote:
> > >> >> > /// Returns a pointer to the struct containing the [`Work<T, ID>`] field.
> > >> >> > ///
> > >> >> > /// # Safety
> > >> >> > ///
> > >> >> > /// The pointer must point at a [`Work<T, ID>`] field in a struct of type `Self`.
> > >> >> > - #[inline]
> > >> >> > - unsafe fn work_container_of(ptr: *mut Work<T, ID>) -> *mut Self
> > >> >> > - where
> > >> >> > - Self: Sized,
> > >> >>
> > >> >> This bound is required in order to allow the usage of `dyn HasWork` (ie
> > >> >> object safety), so it should stay.
> > >> >>
> > >> >> Maybe add a comment explaining why it's there.
> > >> >
> > >> > I guess a doctest would be better, but I still don't understand why
> > >> > the bound is needed. Sorry, can you cite something or explain in more
> > >> > detail please?
> > >>
> > >> Here is a link: https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility
> > >>
> > >> But I realized that the trait wasn't object safe to begin with due to
> > >> the `OFFSET` associated constant. So I'm not sure we need this. Alice,
> > >> do you need `dyn HasWork`?
> > >
> > > I wrote a simple test:
> >
> > [...]
> >
> > > so I don't think adding the Sized bound makes sense - we'd end up
> > > adding it on every item in the trait.
> >
> > Yeah the `Sized` bound was probably to make the cast work, so let's
> > remove it.
>
> It's already removed, right?
Ping. Can you help me understand what change, if any, you think is required?