check last statement

This commit is contained in:
kyoto7250 2022-06-20 11:05:40 +09:00
parent 4a02ae9636
commit 46d056e2eb
2 changed files with 33 additions and 1 deletions
clippy_utils/src
tests/ui

@ -88,7 +88,7 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
} }
fn cannot_be_compared_block(&mut self, block: &Block<'_>) -> bool { 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!( matches!(
stmt.kind, stmt.kind,
StmtKind::Semi(semi_expr) if self.should_ignore(semi_expr) StmtKind::Semi(semi_expr) if self.should_ignore(semi_expr)

@ -179,6 +179,38 @@ mod issue_8836 {
} else { } else {
unimplemented!(); 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!()
}
} }
} }