3 #![warn(clippy::let_unit_value)]
4 #![allow(clippy::no_effect)]
5 #![allow(unused_variables)]
7 macro_rules! let_and_return {
15 let _y = 1; // this is fine
16 let _z = ((), 1); // this as well
21 consume_units_with_for_loop(); // should be fine as well
25 let_and_return!(()) // should be fine
28 // Related to issue #1964
29 fn consume_units_with_for_loop() {
30 // `for_let_unit` lint should not be triggered by consuming them using for loop.
31 let v = vec![(), (), ()];
38 // Same for consuming from some other Iterator<Item = ()>.
39 let (tx, rx) = ::std::sync::mpsc::channel();
51 let v: Vec<u8> = vec![2];
56 .filter(|i| i % 2 == 0)
62 #[derive(Copy, Clone)]
63 pub struct ContainsUnit(()); // should be fine
65 fn _returns_generic() {
69 fn f2<T, U>(_: T) -> U {
75 fn f4<T>(mut x: Vec<T>) -> T {
79 let _: () = f(); // Ok
80 let _: () = f(); // Lint.
82 let _: () = f2(0i32); // Ok
83 let _: () = f2(0i32); // Lint.
97 let _: () = if true { f() } else { f2(0) }; // Ok
98 let _: () = if true { f() } else { f2(0) }; // Lint
101 let _: () = match Some(0) {