]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
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. | |
4 | // | |
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. | |
10 | ||
11 | #![deny(unused_parens)] | |
12 | ||
13 | #[derive(Eq, PartialEq)] | |
14 | struct X { y: bool } | |
15 | impl X { | |
16 | fn foo(&self) -> bool { self.y } | |
17 | } | |
18 | ||
19 | fn foo() -> isize { | |
85aaf69f | 20 | return (1); //~ ERROR unnecessary parentheses around `return` value |
1a4d82fc JJ |
21 | } |
22 | fn bar() -> X { | |
23 | return (X { y: true }); //~ ERROR unnecessary parentheses around `return` value | |
24 | } | |
25 | ||
26 | fn main() { | |
27 | foo(); | |
28 | bar(); | |
29 | ||
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 | |
33 | _ => {} | |
34 | } | |
85aaf69f SL |
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 | |
1a4d82fc JJ |
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) {} | |
42 | ||
43 | while (X { y: false }.foo()) {} | |
44 | while (true | X { y: false }.y) {} | |
45 | ||
46 | match (X { y: false }) { | |
47 | _ => {} | |
48 | } | |
49 | ||
85aaf69f SL |
50 | let mut _a = (0); //~ ERROR unnecessary parentheses around assigned value |
51 | _a = (0); //~ ERROR unnecessary parentheses around assigned value | |
52 | _a += (1); //~ ERROR unnecessary parentheses around assigned value | |
1a4d82fc | 53 | } |