[tip: locking/core] rust: debugfs: Implement Reader for Mutex<T> only when T is Unpin

tip-bot2 for Boqun Feng posted 1 patch 3 months, 2 weeks ago
rust/kernel/debugfs/traits.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[tip: locking/core] rust: debugfs: Implement Reader for Mutex<T> only when T is Unpin
Posted by tip-bot2 for Boqun Feng 3 months, 2 weeks ago
The following commit has been merged into the locking/core branch of tip:

Commit-ID:     37d0472c8ac441af8bc10fc4959ad9d62dd5fa4c
Gitweb:        https://git.kernel.org/tip/37d0472c8ac441af8bc10fc4959ad9d62dd5fa4c
Author:        Boqun Feng <boqun.feng@gmail.com>
AuthorDate:    Tue, 21 Oct 2025 23:42:37 -04:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 22 Oct 2025 15:21:51 +02:00

rust: debugfs: Implement Reader for Mutex<T> only when T is Unpin

Since we are going to make `Mutex<T>` 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<T>` to that.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/20251022034237.70431-1-boqun.feng@gmail.com
---
 rust/kernel/debugfs/traits.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/debugfs/traits.rs b/rust/kernel/debugfs/traits.rs
index ab009eb..ba7ec5a 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<T: FromStr> Reader for Mutex<T> {
+impl<T: FromStr + Unpin> Reader for Mutex<T> {
     fn read_from_slice(&self, reader: &mut UserSliceReader) -> Result {
         let mut buf = [0u8; 128];
         if reader.len() > buf.len() {