Skip to content

Commit 37d0472

Browse files
fbqPeter Zijlstra
authored andcommitted
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
1 parent 795aab3 commit 37d0472

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

rust/kernel/debugfs/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub trait Reader {
5050
fn read_from_slice(&self, reader: &mut UserSliceReader) -> Result;
5151
}
5252

53-
impl<T: FromStr> Reader for Mutex<T> {
53+
impl<T: FromStr + Unpin> Reader for Mutex<T> {
5454
fn read_from_slice(&self, reader: &mut UserSliceReader) -> Result {
5555
let mut buf = [0u8; 128];
5656
if reader.len() > buf.len() {

0 commit comments

Comments
 (0)