Re: [PATCH v2] rust: sync: implement Unpin for ARef

From: Benno Lossin
Date: Thu Dec 18 2025 - 05:25:24 EST


On Thu Dec 18, 2025 at 9:25 AM CET, Alice Ryhl wrote:
> The default implementation of Unpin for ARef<T> is conditional on T
> being Unpin due to its PhantomData<T> field. However, this is overly
> strict as pointers to T are legal to move even if T itself cannot move.
>
> Since commit 66f1ea83d9f8 ("rust: lock: Add a Pin<&mut T> accessor")
> this causes build failures when combined with a Mutex that contains an
> field ARef<T>, because almost any type that ARef is used with is !Unpin.
>
> Reviewed-by: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
> Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>

Reviewed-by: Benno Lossin <lossin@xxxxxxxxxx>

Cheers,
Benno

> ---
> Changes in v2:
> - Add T: AlwaysRefCounted bound.
> - Link to v1: https://lore.kernel.org/r/20251217-unpin-for-aref-v1-1-84711b747d02@xxxxxxxxxx
> ---
> rust/kernel/sync/aref.rs | 3 +++
> 1 file changed, 3 insertions(+)