1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![deny(unused_parens)]
13 #[derive(Eq, PartialEq)]
16 fn foo(&self, conjunct: bool) -> bool { self.y && conjunct }
20 return (1); //~ ERROR unnecessary parentheses around `return` value
22 fn bar(y: bool) -> X {
23 return (X { y }); //~ ERROR unnecessary parentheses around `return` value
28 bar((true)); //~ ERROR unnecessary parentheses around function argument
30 if (true) {} //~ ERROR unnecessary parentheses around `if` condition
31 while (true) {} //~ ERROR unnecessary parentheses around `while` condition
32 match (true) { //~ ERROR unnecessary parentheses around `match` head expression
35 if let 1 = (1) {} //~ ERROR unnecessary parentheses around `if let` head expression
36 while let 1 = (2) {} //~ ERROR unnecessary parentheses around `while let` head expression
37 let v = X { y: false };
38 // struct lits needs parens, so these shouldn't warn.
39 if (v == X { y: true }) {}
40 if (X { y: true } == v) {}
41 if (X { y: false }.y) {}
43 while (X { y: false }.foo(true)) {}
44 while (true | X { y: false }.y) {}
46 match (X { y: false }) {
50 X { y: false }.foo((true)); //~ ERROR unnecessary parentheses around method argument
52 let mut _a = (0); //~ ERROR unnecessary parentheses around assigned value
53 _a = (0); //~ ERROR unnecessary parentheses around assigned value
54 _a += (1); //~ ERROR unnecessary parentheses around assigned value