about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authordaxpedda <daxpedda@users.noreply.github.com>2019-01-20 13:45:22 +0100
committerdaxpedda <daxpedda@users.noreply.github.com>2019-01-20 13:45:22 +0100
commit2183cfcc13c12f21571879dcc8ef40c4dfc9d8a7 (patch)
treed3c85160b03efbf41f28d6ccf1e7d6874fe30d6e /tests/ui
parente648adf0866a1cea7db6ce2d33ea86e442f25377 (diff)
downloadrust-2183cfcc13c12f21571879dcc8ef40c4dfc9d8a7.tar.gz
rust-2183cfcc13c12f21571879dcc8ef40c4dfc9d8a7.zip
Fix `implicit_return` false positives.
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/implicit_return.rs19
-rw-r--r--tests/ui/implicit_return.stderr10
2 files changed, 24 insertions, 5 deletions
diff --git a/tests/ui/implicit_return.rs b/tests/ui/implicit_return.rs
index 0fe4a283abf..d1c63ca1697 100644
--- a/tests/ui/implicit_return.rs
+++ b/tests/ui/implicit_return.rs
@@ -26,6 +26,14 @@ fn test_match(x: bool) -> bool {
     }
 }
 
+#[allow(clippy::match_bool, clippy::needless_return)]
+fn test_match_with_unreachable(x: bool) -> bool {
+    match x {
+        true => return false,
+        false => unreachable!(),
+    }
+}
+
 #[allow(clippy::never_loop)]
 fn test_loop() -> bool {
     loop {
@@ -53,6 +61,15 @@ fn test_loop_with_nests() -> bool {
     }
 }
 
+#[allow(clippy::redundant_pattern_matching)]
+fn test_loop_with_if_let() -> bool {
+    loop {
+        if let Some(x) = Some(true) {
+            return x;
+        }
+    }
+}
+
 fn test_closure() {
     #[rustfmt::skip]
     let _ = || { true };
@@ -63,8 +80,10 @@ fn main() {
     let _ = test_end_of_fn();
     let _ = test_if_block();
     let _ = test_match(true);
+    let _ = test_match_with_unreachable(true);
     let _ = test_loop();
     let _ = test_loop_with_block();
     let _ = test_loop_with_nests();
+    let _ = test_loop_with_if_let();
     test_closure();
 }
diff --git a/tests/ui/implicit_return.stderr b/tests/ui/implicit_return.stderr
index c07fced1259..98b588f1a74 100644
--- a/tests/ui/implicit_return.stderr
+++ b/tests/ui/implicit_return.stderr
@@ -31,31 +31,31 @@ LL |         false => { true },
    |                    ^^^^ help: add `return` as shown: `return true`
 
 error: missing return statement
-  --> $DIR/implicit_return.rs:32:9
+  --> $DIR/implicit_return.rs:40:9
    |
 LL |         break true;
    |         ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
 
 error: missing return statement
-  --> $DIR/implicit_return.rs:40:13
+  --> $DIR/implicit_return.rs:48:13
    |
 LL |             break true;
    |             ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
 
 error: missing return statement
-  --> $DIR/implicit_return.rs:49:13
+  --> $DIR/implicit_return.rs:57:13
    |
 LL |             break true;
    |             ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
 
 error: missing return statement
-  --> $DIR/implicit_return.rs:58:18
+  --> $DIR/implicit_return.rs:75:18
    |
 LL |     let _ = || { true };
    |                  ^^^^ help: add `return` as shown: `return true`
 
 error: missing return statement
-  --> $DIR/implicit_return.rs:59:16
+  --> $DIR/implicit_return.rs:76:16
    |
 LL |     let _ = || true;
    |                ^^^^ help: add `return` as shown: `return true`