about summary refs log tree commit diff
path: root/src/test/compile-fail/lint-unnecessary-parens.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-01-20 15:06:41 +0000
committerbors <bors@rust-lang.org>2018-01-20 15:06:41 +0000
commit15a1e2844dfea7850be5c6c901b67ceff370b0eb (patch)
tree2929f026038000e5f0ecfdbe6e1e0fb378157a6b /src/test/compile-fail/lint-unnecessary-parens.rs
parentbdda8d61151a91fcc95b059918dd834c8e7ac09e (diff)
parent14982db2d68268458a3de03e395b2e9afe518b50 (diff)
downloadrust-15a1e2844dfea7850be5c6c901b67ceff370b0eb.tar.gz
rust-15a1e2844dfea7850be5c6c901b67ceff370b0eb.zip
Auto merge of #46980 - zackmdavis:and_the_case_of_the_needlessly_parenthesized_arguments, r=petrochenkov
in which the unused-parens lint comes to cover function and method args

Resolves #46137.
Diffstat (limited to 'src/test/compile-fail/lint-unnecessary-parens.rs')
-rw-r--r--src/test/compile-fail/lint-unnecessary-parens.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/test/compile-fail/lint-unnecessary-parens.rs b/src/test/compile-fail/lint-unnecessary-parens.rs
index b5eac73a55d..7cd0a6bbf0f 100644
--- a/src/test/compile-fail/lint-unnecessary-parens.rs
+++ b/src/test/compile-fail/lint-unnecessary-parens.rs
@@ -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