blob: 9f42b855a870d7b4e44abb0e86f4e23c3a6ef5a7 [file] [log] [blame]
#![deny(unused_parens)]
#[derive(Eq, PartialEq)]
struct X { y: bool }
impl X {
fn foo(&self, conjunct: bool) -> bool { self.y && conjunct }
}
fn foo() -> isize {
return (1); //~ ERROR unnecessary parentheses around `return` value
}
fn bar(y: bool) -> X {
return (X { y }); //~ ERROR unnecessary parentheses around `return` value
}
fn unused_parens_around_return_type() -> (u32) { //~ ERROR unnecessary parentheses around type
panic!()
}
trait Trait {
fn test(&self);
}
fn passes_unused_parens_lint() -> &'static (dyn Trait) {
panic!()
}
fn main() {
foo();
bar((true)); //~ ERROR unnecessary parentheses around function argument
if (true) {} //~ ERROR unnecessary parentheses around `if` condition
while (true) {} //~ ERROR unnecessary parentheses around `while` condition
//~^ WARN denote infinite loops with
match (true) { //~ ERROR unnecessary parentheses around `match` head expression
_ => {}
}
if let 1 = (1) {} //~ ERROR unnecessary parentheses around `let` head expression
while let 1 = (2) {} //~ ERROR unnecessary parentheses around `let` head expression
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) {}
while (X { y: false }.foo(true)) {}
while (true | X { y: false }.y) {}
match (X { y: false }) {
_ => {}
}
X { y: false }.foo((true)); //~ ERROR unnecessary parentheses around method argument
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
}