[PATCH] rust: pin-init: examples: fix `useless_borrows_in_formatting` clippy warning

Gary Guo posted 1 patch 1 month, 1 week ago
rust/pin-init/examples/mutex.rs         | 2 +-
rust/pin-init/examples/pthread_mutex.rs | 2 +-
rust/pin-init/examples/static_init.rs   | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
[PATCH] rust: pin-init: examples: fix `useless_borrows_in_formatting` clippy warning
Posted by Gary Guo 1 month, 1 week ago
From: Gary Guo <gary@garyguo.net>

Clippy 1.97 introduces new `useless_borrows_in_formatting` warning which
fires on the examples as we have `&*expr` where the format macro takes
reference already. Remove the extra borrow.

Signed-off-by: Gary Guo <gary@garyguo.net>
---
The examples are not built in the kernel tree and they're really just
examples for reference purpose.

They're, however, built and required to kept lint-clean in pin-init CI.
---
 rust/pin-init/examples/mutex.rs         | 2 +-
 rust/pin-init/examples/pthread_mutex.rs | 2 +-
 rust/pin-init/examples/static_init.rs   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/rust/pin-init/examples/mutex.rs b/rust/pin-init/examples/mutex.rs
index d53671f0edb8..8d4902c584e4 100644
--- a/rust/pin-init/examples/mutex.rs
+++ b/rust/pin-init/examples/mutex.rs
@@ -220,7 +220,7 @@ fn main() {
         for h in handles {
             h.join().expect("thread panicked");
         }
-        println!("{:?}", &*mtx.lock());
+        println!("{:?}", *mtx.lock());
         assert_eq!(*mtx.lock(), workload * thread_count * 2);
     }
 }
diff --git a/rust/pin-init/examples/pthread_mutex.rs b/rust/pin-init/examples/pthread_mutex.rs
index f3b5cc9b7134..7c5c78b2ded1 100644
--- a/rust/pin-init/examples/pthread_mutex.rs
+++ b/rust/pin-init/examples/pthread_mutex.rs
@@ -179,7 +179,7 @@ fn main() {
         for h in handles {
             h.join().expect("thread panicked");
         }
-        println!("{:?}", &*mtx.lock());
+        println!("{:?}", *mtx.lock());
         assert_eq!(*mtx.lock(), workload * thread_count * 2);
     }
 }
diff --git a/rust/pin-init/examples/static_init.rs b/rust/pin-init/examples/static_init.rs
index f7e53d1a5ae6..3f4d4e20216b 100644
--- a/rust/pin-init/examples/static_init.rs
+++ b/rust/pin-init/examples/static_init.rs
@@ -119,7 +119,7 @@ fn main() {
         for h in handles {
             h.join().expect("thread panicked");
         }
-        println!("{:?}, {:?}", &*mtx.lock(), &*COUNT.lock());
+        println!("{:?}, {:?}", *mtx.lock(), *COUNT.lock());
         assert_eq!(*mtx.lock(), workload * thread_count * 2);
     }
 }

base-commit: 97e797263a5e963da3d1e66e743fd518567dfe37
-- 
2.51.2
Re: [PATCH] rust: pin-init: examples: fix `useless_borrows_in_formatting` clippy warning
Posted by Gary Guo 1 month ago
On Tue May 5, 2026 at 12:51 PM BST, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.net>
>
> Clippy 1.97 introduces new `useless_borrows_in_formatting` warning which
> fires on the examples as we have `&*expr` where the format macro takes
> reference already. Remove the extra borrow.
>
> Signed-off-by: Gary Guo <gary@garyguo.net>

Applied to pin-init-next.

Best,
Gary