in which the unused-parens lint comes to cover function and method args
Resolves #46137.
This commit is contained in:
parent
44afd76788
commit
14982db2d6
7 changed files with 25 additions and 11 deletions
|
|
@ -13,19 +13,19 @@
|
|||
#[derive(Eq, PartialEq)]
|
||||
struct X { y: bool }
|
||||
impl X {
|
||||
fn foo(&self) -> bool { self.y }
|
||||
fn foo(&self, conjunct: bool) -> bool { self.y && conjunct }
|
||||
}
|
||||
|
||||
fn foo() -> isize {
|
||||
return (1); //~ ERROR unnecessary parentheses around `return` value
|
||||
}
|
||||
fn bar() -> X {
|
||||
return (X { y: true }); //~ ERROR unnecessary parentheses around `return` value
|
||||
fn bar(y: bool) -> X {
|
||||
return (X { y }); //~ ERROR unnecessary parentheses around `return` value
|
||||
}
|
||||
|
||||
fn main() {
|
||||
foo();
|
||||
bar();
|
||||
bar((true)); //~ ERROR unnecessary parentheses around function argument
|
||||
|
||||
if (true) {} //~ ERROR unnecessary parentheses around `if` condition
|
||||
while (true) {} //~ ERROR unnecessary parentheses around `while` condition
|
||||
|
|
@ -40,13 +40,15 @@ fn main() {
|
|||
if (X { y: true } == v) {}
|
||||
if (X { y: false }.y) {}
|
||||
|
||||
while (X { y: false }.foo()) {}
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue