Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: sync: Implement Unpin for ARef

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@collabora.com>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://patch.msgid.link/20251218-unpin-for-aref-v2-1-30d77129cbc6@google.com

authored by

Alice Ryhl and committed by
Boqun Feng
09248ed8 8a581130

+3
+3
rust/kernel/sync/aref.rs
··· 83 83 // example, when the reference count reaches zero and `T` is dropped. 84 84 unsafe impl<T: AlwaysRefCounted + Sync + Send> Sync for ARef<T> {} 85 85 86 + // Even if `T` is pinned, pointers to `T` can still move. 87 + impl<T: AlwaysRefCounted> Unpin for ARef<T> {} 88 + 86 89 impl<T: AlwaysRefCounted> ARef<T> { 87 90 /// Creates a new instance of [`ARef`]. 88 91 ///