From: Boqun Feng Date: Wed, 22 Oct 2025 03:42:37 +0000 (-0400) Subject: rust: debugfs: Implement Reader for Mutex only when T is Unpin X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=37d0472c8ac441af8bc10fc4959ad9d62dd5fa4c;p=thirdparty%2Flinux.git rust: debugfs: Implement Reader for Mutex only when T is Unpin Since we are going to make `Mutex` structurally pin the data (i.e. `T`), therefore `.lock()` function only returns a `Guard` that can dereference a mutable reference to `T` if only `T` is `Unpin`, therefore restrict the impl `Reader` block of `Mutex` to that. Signed-off-by: Boqun Feng Signed-off-by: Peter Zijlstra (Intel) Acked-by: Danilo Krummrich Link: https://patch.msgid.link/20251022034237.70431-1-boqun.feng@gmail.com --- diff --git a/rust/kernel/debugfs/traits.rs b/rust/kernel/debugfs/traits.rs index ab009eb254b32..ba7ec5a900b8f 100644 --- a/rust/kernel/debugfs/traits.rs +++ b/rust/kernel/debugfs/traits.rs @@ -50,7 +50,7 @@ pub trait Reader { fn read_from_slice(&self, reader: &mut UserSliceReader) -> Result; } -impl Reader for Mutex { +impl Reader for Mutex { fn read_from_slice(&self, reader: &mut UserSliceReader) -> Result { let mut buf = [0u8; 128]; if reader.len() > buf.len() {