From 09248ed8cdb6345afc883c02aecd79dfbd9c2a9c Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Thu, 18 Dec 2025 08:25:13 +0000 Subject: [PATCH] rust: sync: Implement Unpin for ARef The default implementation of Unpin for ARef is conditional on T being Unpin due to its PhantomData 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, because almost any type that ARef is used with is !Unpin. Reviewed-by: Daniel Almeida Signed-off-by: Alice Ryhl Reviewed-by: Alexandre Courbot Reviewed-by: Benno Lossin Signed-off-by: Boqun Feng Link: https://patch.msgid.link/20251218-unpin-for-aref-v2-1-30d77129cbc6@google.com --- rust/kernel/sync/aref.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rust/kernel/sync/aref.rs b/rust/kernel/sync/aref.rs index 0d24a0432015d..0616c0353c2b3 100644 --- a/rust/kernel/sync/aref.rs +++ b/rust/kernel/sync/aref.rs @@ -83,6 +83,9 @@ unsafe impl Send for ARef {} // example, when the reference count reaches zero and `T` is dropped. unsafe impl Sync for ARef {} +// Even if `T` is pinned, pointers to `T` can still move. +impl Unpin for ARef {} + impl ARef { /// Creates a new instance of [`ARef`]. /// -- 2.47.3