Skip to content

Commit 46d056e

Browse files
committed
check last statement
1 parent 4a02ae9 commit 46d056e

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

clippy_utils/src/hir_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
8888
}
8989

9090
fn cannot_be_compared_block(&mut self, block: &Block<'_>) -> bool {
91-
if block.stmts.first().map_or(false, |stmt| {
91+
if block.stmts.last().map_or(false, |stmt| {
9292
matches!(
9393
stmt.kind,
9494
StmtKind::Semi(semi_expr) if self.should_ignore(semi_expr)

tests/ui/if_same_then_else.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,38 @@ mod issue_8836 {
179179
} else {
180180
unimplemented!();
181181
}
182+
183+
if true {
184+
println!("FOO");
185+
todo!();
186+
} else {
187+
println!("FOO");
188+
todo!();
189+
}
190+
191+
if true {
192+
println!("FOO");
193+
unimplemented!();
194+
} else {
195+
println!("FOO");
196+
unimplemented!();
197+
}
198+
199+
if true {
200+
println!("FOO");
201+
todo!()
202+
} else {
203+
println!("FOO");
204+
todo!()
205+
}
206+
207+
if true {
208+
println!("FOO");
209+
unimplemented!()
210+
} else {
211+
println!("FOO");
212+
unimplemented!()
213+
}
182214
}
183215
}
184216

0 commit comments

Comments
 (0)