-
-
-
-#![warn(drop_copy, forget_copy)]
-#![allow(toplevel_ref_arg, drop_ref, forget_ref, unused_mut)]
+#![warn(clippy::drop_copy, clippy::forget_copy)]
+#![allow(clippy::toplevel_ref_arg, clippy::drop_ref, clippy::forget_ref, unused_mut)]
use std::mem::{drop, forget};
use std::vec::Vec;
#[derive(Copy, Clone)]
-struct SomeStruct {
-}
+struct SomeStruct;
struct AnotherStruct {
x: u8,
y: u8,
- z: Vec<u8>
+ z: Vec<u8>,
}
impl Clone for AnotherStruct {
- fn clone(& self) -> AnotherStruct {
- AnotherStruct{x: self.x, y: self.y, z: self.z.clone()}
+ fn clone(&self) -> AnotherStruct {
+ AnotherStruct {
+ x: self.x,
+ y: self.y,
+ z: self.z.clone(),
+ }
}
}
forget(s4);
forget(s5);
- let a1 = AnotherStruct {x: 255, y: 0, z: vec![1, 2, 3]};
+ let a1 = AnotherStruct {
+ x: 255,
+ y: 0,
+ z: vec![1, 2, 3],
+ };
let a2 = &a1;
let mut a3 = a1.clone();
let ref a4 = a1;
let a5 = a1.clone();
forget(a5);
}
+
+#[allow(unused)]
+#[allow(clippy::unit_cmp)]
+fn issue9482(x: u8) {
+ fn println_and<T>(t: T) -> T {
+ println!("foo");
+ t
+ }
+
+ match x {
+ 0 => drop(println_and(12)), // Don't lint (copy type), we only care about side-effects
+ 1 => drop(println_and(String::new())), // Don't lint (no copy type), we only care about side-effects
+ 2 => {
+ drop(println_and(13)); // Lint, even if we only care about the side-effect, it's already in a block
+ },
+ 3 if drop(println_and(14)) == () => (), // Lint, idiomatic use is only in body of `Arm`
+ 4 => drop(2), // Lint, not a fn/method call
+ _ => (),
+ }
+}