remove trailing return in trailing match expression

This commit is contained in:
davidsemakula 2024-01-31 07:04:49 +03:00
parent cad222ff1b
commit 98e6f43a2f
3 changed files with 72 additions and 8 deletions

View file

@ -272,6 +272,12 @@ impl ExprValidator {
self.check_for_trailing_return(*else_branch, body);
}
}
Expr::Match { arms, .. } => {
for arm in arms.iter() {
let MatchArm { expr, .. } = arm;
self.check_for_trailing_return(*expr, body);
}
}
Expr::Return { .. } => {
self.diagnostics.push(BodyValidationDiagnostic::RemoveTrailingReturn {
return_expr: body_expr,