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(unnecessary_parens)]
13 #[deriving(Eq, PartialEq)]
16 fn foo(&self) -> bool { self.y }
20 return (1i); //~ ERROR unnecessary parentheses around `return` value
23 return (X { y: true }); //~ ERROR unnecessary parentheses around `return` value
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 let v = X { y: false };
36 // struct lits needs parens, so these shouldn't warn.
37 if (v == X { y: true }) {}
38 if (X { y: true } == v) {}
39 if (X { y: false }.y) {}
41 while (X { y: false }.foo()) {}
42 while (true | X { y: false }.y) {}
44 match (X { y: false }) {
48 let mut _a = (0i); //~ ERROR unnecessary parentheses around assigned value
49 _a = (0i); //~ ERROR unnecessary parentheses around assigned value
50 _a += (1i); //~ ERROR unnecessary parentheses around assigned value