Fixed statement bodies

This commit is contained in:
2026-05-24 14:43:09 +02:00
parent 63cc20107c
commit f21cd5a927
6 changed files with 20 additions and 29 deletions
+2 -2
View File
@@ -84,9 +84,9 @@ pub enum Generic {
}
impl Expression {
pub fn is_soft_return(&self) -> bool {
pub fn is_block(&self) -> bool {
if let Expression::Statement(stmt) = self {
stmt.is_soft_return()
stmt.is_block()
} else {
false
}
+8 -21
View File
@@ -64,28 +64,15 @@ pub struct StatementBranch {
}
impl Statement {
pub fn is_soft_return(&self) -> bool {
pub fn is_block(&self) -> bool {
match self {
Self::Block(_) | Self::Match(_, _) => true,
Self::While(branch) => branch.body.is_soft_return(),
Self::For { body, .. } | Self::Loop(body) | Self::CStyleFor { body, .. } => {
body.is_soft_return()
}
Self::If {
initial,
else_if,
else_branch,
} => {
else_branch
.as_ref()
.map(|v| v.is_soft_return())
.unwrap_or_default()
|| else_if
.last()
.map(|b| b.body.is_soft_return())
.unwrap_or_default()
|| initial.body.is_soft_return()
}
Self::Block(_)
| Self::Match(_, _)
| Self::While(_)
| Self::For { .. }
| Self::Loop(..)
| Self::CStyleFor { .. }
| Self::If { .. } => true,
_ => false,
}
}