]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/implicit_return.rs
iterate List by value
[rust.git] / tests / ui / implicit_return.rs
index 0fe4a283abfbc99ecd2e1abf4bbeb9760da5d786..c0d70ecf502ed6167fe7205866045f24d66c6ceb 100644 (file)
@@ -1,10 +1,14 @@
+// run-rustfix
+
 #![warn(clippy::implicit_return)]
+#![allow(clippy::needless_return, unused)]
 
 fn test_end_of_fn() -> bool {
     if true {
         // no error!
         return true;
     }
+
     true
 }
 
@@ -17,7 +21,6 @@ fn test_if_block() -> bool {
     }
 }
 
-#[allow(clippy::match_bool)]
 #[rustfmt::skip]
 fn test_match(x: bool) -> bool {
     match x {
@@ -26,6 +29,14 @@ fn test_match(x: bool) -> bool {
     }
 }
 
+#[allow(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,18 +64,38 @@ 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 };
     let _ = || true;
 }
 
+fn test_panic() -> bool {
+    panic!()
+}
+
+fn test_return_macro() -> String {
+    format!("test {}", "test")
+}
+
 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();
+    let _ = test_return_macro();
 }