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.
11 #![feature(tool_lints)]
14 #![warn(clippy::let_unit_value)]
15 #![allow(unused_variables)]
17 macro_rules! let_and_return {
24 let _x = println!("x");
25 let _y = 1; // this is fine
26 let _z = ((), 1); // this as well
31 consume_units_with_for_loop(); // should be fine as well
33 let_and_return!(()) // should be fine
36 // Related to issue #1964
37 fn consume_units_with_for_loop() {
38 // `for_let_unit` lint should not be triggered by consuming them using for loop.
39 let v = vec![(), (), ()];
46 // Same for consuming from some other Iterator<Item = ()>.
47 let (tx, rx) = ::std::sync::mpsc::channel();
58 #[derive(Copy, Clone)]
59 pub struct ContainsUnit(()); // should be fine