2014-10-27 17:37:07 -05:00
|
|
|
#![deny(unused_parens)]
|
2014-01-18 21:57:47 -06:00
|
|
|
|
2014-12-30 22:32:49 -06:00
|
|
|
#[derive(Eq, PartialEq)]
|
2014-06-24 18:00:46 -05:00
|
|
|
struct X { y: bool }
|
|
|
|
impl X {
|
2017-12-23 21:28:33 -06:00
|
|
|
fn foo(&self, conjunct: bool) -> bool { self.y && conjunct }
|
2014-06-24 18:00:46 -05:00
|
|
|
}
|
|
|
|
|
2015-01-08 04:54:35 -06:00
|
|
|
fn foo() -> isize {
|
2015-01-31 10:23:42 -06:00
|
|
|
return (1); //~ ERROR unnecessary parentheses around `return` value
|
2014-01-18 21:57:47 -06:00
|
|
|
}
|
2017-12-23 21:28:33 -06:00
|
|
|
fn bar(y: bool) -> X {
|
|
|
|
return (X { y }); //~ ERROR unnecessary parentheses around `return` value
|
2014-06-24 18:00:46 -05:00
|
|
|
}
|
2014-01-18 21:57:47 -06:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
foo();
|
2017-12-23 21:28:33 -06:00
|
|
|
bar((true)); //~ ERROR unnecessary parentheses around function argument
|
2014-01-18 21:57:47 -06:00
|
|
|
|
|
|
|
if (true) {} //~ ERROR unnecessary parentheses around `if` condition
|
|
|
|
while (true) {} //~ ERROR unnecessary parentheses around `while` condition
|
2019-06-21 18:30:24 -05:00
|
|
|
//~^ WARN denote infinite loops with
|
2014-01-18 21:57:47 -06:00
|
|
|
match (true) { //~ ERROR unnecessary parentheses around `match` head expression
|
|
|
|
_ => {}
|
|
|
|
}
|
2019-05-17 18:22:43 -05:00
|
|
|
if let 1 = (1) {} //~ ERROR unnecessary parentheses around `let` head expression
|
|
|
|
while let 1 = (2) {} //~ ERROR unnecessary parentheses around `let` head expression
|
2014-06-24 18:00:46 -05:00
|
|
|
let v = X { y: false };
|
|
|
|
// struct lits needs parens, so these shouldn't warn.
|
|
|
|
if (v == X { y: true }) {}
|
|
|
|
if (X { y: true } == v) {}
|
|
|
|
if (X { y: false }.y) {}
|
|
|
|
|
2017-12-23 21:28:33 -06:00
|
|
|
while (X { y: false }.foo(true)) {}
|
2014-06-24 18:00:46 -05:00
|
|
|
while (true | X { y: false }.y) {}
|
|
|
|
|
|
|
|
match (X { y: false }) {
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
|
2017-12-23 21:28:33 -06:00
|
|
|
X { y: false }.foo((true)); //~ ERROR unnecessary parentheses around method argument
|
|
|
|
|
2015-01-31 10:23:42 -06:00
|
|
|
let mut _a = (0); //~ ERROR unnecessary parentheses around assigned value
|
|
|
|
_a = (0); //~ ERROR unnecessary parentheses around assigned value
|
|
|
|
_a += (1); //~ ERROR unnecessary parentheses around assigned value
|
2014-01-18 21:57:47 -06:00
|
|
|
}
|