Skip to content

Commit b15c527

Browse files
committed
Check if stmt is if-else stmt
1 parent c274c61 commit b15c527

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/expr.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,18 @@ pub fn stmt_is_expr(stmt: &ast::Stmt) -> bool {
11361136
}
11371137
}
11381138

1139+
fn stmt_is_if(stmt: &ast::Stmt) -> bool {
1140+
match stmt.node {
1141+
ast::StmtKind::Semi(ref e) | ast::StmtKind::Expr(ref e) => {
1142+
match e.node {
1143+
ast::ExprKind::If(..) => true,
1144+
_ => false,
1145+
}
1146+
},
1147+
_ => false,
1148+
}
1149+
}
1150+
11391151
pub fn is_unsafe_block(block: &ast::Block) -> bool {
11401152
if let ast::BlockCheckMode::Unsafe(..) = block.rules {
11411153
true

0 commit comments

Comments
 (0)