Skip to contentSkip to conversation

rust: pin-init: examples: fix `useless_borrows_in_formatting` clippy warning

PATCH Applied Gary Guo 2 participants 2 messages May 5 – May 10

Subsystems (2)
lore
Share & tools
lore

Gary Guo

author
#0 lore raw

PATCH 1/1 rust: pin-init: examples: fix `useless_borrows_in_formatting` clippy warning

From: Gary Guo <[email protected]>

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.

---
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(-)
rust/pin-init/examples/mutex.rs +1 -1
index d53671f0edb8..8d4902c584e4 100644
@@ -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);
     }
 }
rust/pin-init/examples/pthread_mutex.rs +1 -1
index f3b5cc9b7134..7c5c78b2ded1 100644
@@ -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);
     }
 }
rust/pin-init/examples/static_init.rs +1 -1
index f7e53d1a5ae6..3f4d4e20216b 100644
@@ -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

Signature · 1 line
2.51.2
maintainer Applied
#1 lore raw
Quoted 7 lines · Gary Guo

From: Gary Guo <[email protected]>

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.

Applied to pin-init-next.

Best,
Gary