Skip to content

Commit f2218e7

Browse files
committed
refactor: remove body parameter for "unnecessary else" diagnostic
1 parent 7dfeb2c commit f2218e7

File tree

1 file changed

+3
-9
lines changed
  • crates/hir-ty/src/diagnostics

1 file changed

+3
-9
lines changed

crates/hir-ty/src/diagnostics/expr.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl ExprValidator {
109109
self.check_for_trailing_return(*body_expr, &body);
110110
}
111111
Expr::If { .. } => {
112-
self.check_for_unnecessary_else(id, expr, &body, db);
112+
self.check_for_unnecessary_else(id, expr, db);
113113
}
114114
Expr::Block { .. } => {
115115
self.validate_block(db, expr);
@@ -337,18 +337,12 @@ impl ExprValidator {
337337
}
338338
}
339339

340-
fn check_for_unnecessary_else(
341-
&mut self,
342-
id: ExprId,
343-
expr: &Expr,
344-
body: &Body,
345-
db: &dyn HirDatabase,
346-
) {
340+
fn check_for_unnecessary_else(&mut self, id: ExprId, expr: &Expr, db: &dyn HirDatabase) {
347341
if let Expr::If { condition: _, then_branch, else_branch } = expr {
348342
if else_branch.is_none() {
349343
return;
350344
}
351-
if let Expr::Block { statements, tail, .. } = &body.exprs[*then_branch] {
345+
if let Expr::Block { statements, tail, .. } = &self.body.exprs[*then_branch] {
352346
let last_then_expr = tail.or_else(|| match statements.last()? {
353347
Statement::Expr { expr, .. } => Some(*expr),
354348
_ => None,

0 commit comments

Comments
 (0)