1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
10 #![warn(clippy::let_unit_value)]
11 #![allow(unused_variables)]
13 macro_rules! let_and_return {
20 let _x = println!("x");
21 let _y = 1; // this is fine
22 let _z = ((), 1); // this as well
27 consume_units_with_for_loop(); // should be fine as well
29 let_and_return!(()) // should be fine
32 // Related to issue #1964
33 fn consume_units_with_for_loop() {
34 // `for_let_unit` lint should not be triggered by consuming them using for loop.
35 let v = vec![(), (), ()];
42 // Same for consuming from some other Iterator<Item = ()>.
43 let (tx, rx) = ::std::sync::mpsc::channel();
54 #[derive(Copy, Clone)]
55 pub struct ContainsUnit(()); // should be fine