Skip to contentSkip to conversation

bindings: rust: remove useless clone

PATCH Applied Erik Schilling 3 participants 3 messages Sep 28, 2023 – Sep 29, 2023 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bindings: rust: remove useless clone

Reported by 1.74.0-nightly:

warning: call to .clone() on a reference in this situation does nothing

    --> libgpiod/tests/line_request.rs:71:44
     |
  71 |             let chip_name = sim.chip_name().clone();
     |                                            ^^^^^^^^ help: remove this redundant call
     |

= note: the type str does not implement Clone, so calling clone on &str copies the reference, which does not do anything and can be removed = note: #[warn(noop_method_call)] on by default

---
Found while running nightly toolchains in order to run tests under the AddressSanitizers.

To: Linux-GPIO <[email protected]>
Cc: Viresh Kumar <[email protected]>

---
 bindings/rust/libgpiod/tests/line_request.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bindings/rust/libgpiod/tests/line_request.rs +1 -1
index 9af5226..da22bea 100644
@@ -68,7 +68,7 @@ mod line_request {
 
             let arc = config.sim();
             let sim = arc.lock().unwrap();
-            let chip_name = sim.chip_name().clone();
+            let chip_name = sim.chip_name();
 
             assert_eq!(config.request().chip_name().unwrap(), chip_name);
         }

---
base-commit: ced90e79217793957b11414f47f8aa8a77c7a2d5
change-id: 20230928-useless-clone-af75c3a58df7

Best regards,

Signature · 1 line
Erik Schilling <[email protected]>
Acked-by on v1 1/1
#1 lore raw
Quoted 27 lines · Erik Schilling

Reported by 1.74.0-nightly:

warning: call to .clone() on a reference in this situation does nothing

    --> libgpiod/tests/line_request.rs:71:44
     |
  71 |             let chip_name = sim.chip_name().clone();
     |                                            ^^^^^^^^ help: remove this redundant call
     |

= note: the type str does not implement Clone, so calling clone on &str copies the reference, which does not do anything and can be removed = note: #[warn(noop_method_call)] on by default

---
Found while running nightly toolchains in order to run tests under the AddressSanitizers.

To: Linux-GPIO <[email protected]>
Cc: Viresh Kumar <[email protected]>

---
 bindings/rust/libgpiod/tests/line_request.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bindings/rust/libgpiod/tests/line_request.rs +0 -0
index 9af5226..da22bea 100644

bindings/rust/libgpiod/tests/line_request.rs mod line_request { · line 74

Quoted 8 lines
bindings/rust/libgpiod/tests/line_request.rs +1 -1
@@ -68,7 +68,7 @@ mod line_request {
 
             let arc = config.sim();
             let sim = arc.lock().unwrap();
-            let chip_name = sim.chip_name().clone();
+            let chip_name = sim.chip_name();
 
             assert_eq!(config.request().chip_name().unwrap(), chip_name);
         }
Signature · 1 line
viresh
#2 lore raw
In reply to Erik Schilling
Quoted 41 lines · Erik Schilling

Reported by 1.74.0-nightly:

warning: call to .clone() on a reference in this situation does nothing

    --> libgpiod/tests/line_request.rs:71:44
     |
  71 |             let chip_name = sim.chip_name().clone();
     |                                            ^^^^^^^^ help: remove this redundant call
     |

= note: the type str does not implement Clone, so calling clone on &str copies the reference, which does not do anything and can be removed = note: #[warn(noop_method_call)] on by default

---
Found while running nightly toolchains in order to run tests under the AddressSanitizers.

To: Linux-GPIO <[email protected]>
Cc: Viresh Kumar <[email protected]>

---
 bindings/rust/libgpiod/tests/line_request.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bindings/rust/libgpiod/tests/line_request.rs +1 -2
index 9af5226..da22bea 100644
@@ -68,7 +68,7 @@ mod line_request {
 
             let arc = config.sim();
             let sim = arc.lock().unwrap();
-            let chip_name = sim.chip_name().clone();
+            let chip_name = sim.chip_name();
 
             assert_eq!(config.request().chip_name().unwrap(), chip_name);
         }
 
---

base-commit: ced90e79217793957b11414f47f8aa8a77c7a2d5
change-id: 20230928-useless-clone-af75c3a58df7

Quoted 4 lines

Best regards,
--
Erik Schilling <[email protected]>

Applied, thanks!

Bart