Re: [PATCH v2 6/6] rust: workqueue: add ScopedWork for non-'static work items
From: Danilo Krummrich
Date: Fri Aug 07 2026 - 14:35:31 EST
On Fri Aug 7, 2026 at 6:52 PM CEST, Danilo Krummrich wrote:
> +#[pinned_drop]
> +impl<T: ScopedWorkItem> PinnedDrop for ScopedWork<T> {
> + #[inline]
> + fn drop(self: Pin<&mut Self>) {
> + let inner = self.inner.get();
> +
> + // SAFETY: `inner` points to a valid `ScopedWorkRef`. After `cancel_work_sync()` returns,
> + // the work function is guaranteed to not be running.
> + unsafe { bindings::cancel_work_sync(Work::raw_get(&raw const (*inner).work)) };
// SAFETY: `inner` is valid and no longer accessed by the work function.
unsafe { core::ptr::drop_in_place(inner) };
> + }
> +}