Apply suggestions from code review
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
This commit is contained in:
parent
7738467e0a
commit
86c183716c
@ -77,13 +77,11 @@ pub(super) fn validate_body(&mut self, db: &dyn HirDatabase) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let body_expr = &body[body.body_expr];
|
let body_expr = &body[body.body_expr];
|
||||||
if let Expr::Block { tail: Some(t), .. } = body_expr {
|
if let Expr::Block { statements, tail, .. } = body_expr {
|
||||||
self.validate_results_in_tail_expr(body.body_expr, *t, db);
|
if let Some(t) = tail {
|
||||||
} else {
|
self.validate_results_in_tail_expr(body.body_expr, *t, db);
|
||||||
if let Expr::Block { statements, .. } = body_expr {
|
} else if let Some(Statement::Expr(id)) = statements.last() {
|
||||||
if let Some(Statement::Expr(id)) = statements.last() {
|
self.validate_missing_tail_expr(body.body_expr, *id, db);
|
||||||
self.validate_missing_tail_expr(body.body_expr, *id, db);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,17 +334,22 @@ fn validate_missing_tail_expr(
|
|||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(possible_tail_ty) = self.infer.type_of_expr.get(possible_tail_id) {
|
let possible_tail_ty = if let Some(possible_tail_ty) = self.infer.type_of_expr.get(possible_tail_id) {
|
||||||
if mismatch.actual == Ty::unit() && mismatch.expected == *possible_tail_ty {
|
possible_tail_ty
|
||||||
let (_, source_map) = db.body_with_source_map(self.owner.into());
|
} else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) {
|
if mismatch.actual != Ty::unit() || mismatch.expected != *possible_tail_ty {
|
||||||
self.sink.push(RemoveThisSemicolon {
|
return;
|
||||||
file: source_ptr.file_id,
|
}
|
||||||
expr: source_ptr.value,
|
|
||||||
});
|
let (_, source_map) = db.body_with_source_map(self.owner.into());
|
||||||
}
|
if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) {
|
||||||
}
|
self.sink.push(RemoveThisSemicolon {
|
||||||
|
file: source_ptr.file_id,
|
||||||
|
expr: source_ptr.value,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user