]> git.lizzy.rs Git - rust.git/commitdiff
check last statement
authorkyoto7250 <50972773+kyoto7250@users.noreply.github.com>
Mon, 20 Jun 2022 02:05:40 +0000 (11:05 +0900)
committerkyoto7250 <50972773+kyoto7250@users.noreply.github.com>
Mon, 20 Jun 2022 02:05:40 +0000 (11:05 +0900)
clippy_utils/src/hir_utils.rs
tests/ui/if_same_then_else.rs

index 97a15108d0c367c093e797425797549ca1992316..3eb01bf75a67abf0f6fcdbc94239b3ad0ca2b08f 100644 (file)
@@ -88,7 +88,7 @@ pub fn eq_path_segments(&mut self, left: &[PathSegment<'_>], right: &[PathSegmen
     }
 
     fn cannot_be_compared_block(&mut self, block: &Block<'_>) -> bool {
-        if block.stmts.first().map_or(false, |stmt| {
+        if block.stmts.last().map_or(false, |stmt| {
             matches!(
                 stmt.kind,
                 StmtKind::Semi(semi_expr) if self.should_ignore(semi_expr)
index 4110d1a9c01781166810b3603cc316ad7e189822..2598c2ab426d31fbf46d770da687bff9f2bcda2e 100644 (file)
@@ -179,6 +179,38 @@ fn do_not_lint() {
         } else {
             unimplemented!();
         }
+
+        if true {
+            println!("FOO");
+            todo!();
+        } else {
+            println!("FOO");
+            todo!();
+        }
+
+        if true {
+            println!("FOO");
+            unimplemented!();
+        } else {
+            println!("FOO");
+            unimplemented!();
+        }
+
+        if true {
+            println!("FOO");
+            todo!()
+        } else {
+            println!("FOO");
+            todo!()
+        }
+
+        if true {
+            println!("FOO");
+            unimplemented!()
+        } else {
+            println!("FOO");
+            unimplemented!()
+        }
     }
 }