3 #![deny(unused_parens)]
4 #![allow(while_true)] // for rustfix
6 #[derive(Eq, PartialEq)]
9 fn foo(&self, conjunct: bool) -> bool { self.y && conjunct }
13 return (1); //~ ERROR unnecessary parentheses around `return` value
15 fn bar(y: bool) -> X {
16 return (X { y }); //~ ERROR unnecessary parentheses around `return` value
19 pub fn unused_parens_around_return_type() -> (u32) { //~ ERROR unnecessary parentheses around type
23 pub fn unused_parens_around_block_return() -> u32 {
25 (5) //~ ERROR unnecessary parentheses around block return value
27 (5) //~ ERROR unnecessary parentheses around block return value
34 pub fn passes_unused_parens_lint() -> &'static (dyn Trait) {
44 pub const CONST_ITEM: usize = (10); //~ ERROR unnecessary parentheses around assigned value
45 pub static STATIC_ITEM: usize = (10); //~ ERROR unnecessary parentheses around assigned value
49 bar((true)); //~ ERROR unnecessary parentheses around function argument
51 if (true) {} //~ ERROR unnecessary parentheses around `if` condition
52 while (true) {} //~ ERROR unnecessary parentheses around `while` condition
53 match (true) { //~ ERROR unnecessary parentheses around `match` scrutinee expression
56 if let 1 = (1) {} //~ ERROR unnecessary parentheses around `let` scrutinee expression
57 while let 1 = (2) {} //~ ERROR unnecessary parentheses around `let` scrutinee expression
58 let v = X { y: false };
59 // struct lits needs parens, so these shouldn't warn.
60 if (v == X { y: true }) {}
61 if (X { y: true } == v) {}
62 if (X { y: false }.y) {}
63 // this shouldn't warn, because the parens are necessary to disambiguate let chains
64 if let true = (true && false) {}
66 while (X { y: false }.foo(true)) {}
67 while (true | X { y: false }.y) {}
69 match (X { y: false }) {
73 X { y: false }.foo((true)); //~ ERROR unnecessary parentheses around method argument
75 let mut _a = (0); //~ ERROR unnecessary parentheses around assigned value
76 _a = (0); //~ ERROR unnecessary parentheses around assigned value
77 _a += (1); //~ ERROR unnecessary parentheses around assigned value