Skip to content

Commit 1582d50

Browse files
committed
Check if last stmt of a block is if-else
1 parent b15c527 commit 1582d50

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/expr.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,14 @@ fn stmt_is_if(stmt: &ast::Stmt) -> bool {
11481148
}
11491149
}
11501150

1151+
fn block_last_stmt_is_if(block: &ast::Block) -> bool {
1152+
if let Some(ref stmt) = block.stmts.last() {
1153+
stmt_is_if(stmt)
1154+
} else {
1155+
false
1156+
}
1157+
}
1158+
11511159
pub fn is_unsafe_block(block: &ast::Block) -> bool {
11521160
if let ast::BlockCheckMode::Unsafe(..) = block.rules {
11531161
true

0 commit comments

Comments
 (0)