Skip to content

Commit bbb0bc7

Browse files
committed
Cast to ExprStmt, style fixes
1 parent 35006eb commit bbb0bc7

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

crates/hir_ty/src/diagnostics/expr.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,18 +334,17 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
334334
None => return,
335335
};
336336

337-
let possible_tail_ty =
338-
if let Some(possible_tail_ty) = self.infer.type_of_expr.get(possible_tail_id) {
339-
possible_tail_ty
340-
} else {
341-
return;
342-
};
337+
let possible_tail_ty = match self.infer.type_of_expr.get(possible_tail_id) {
338+
Some(ty) => ty,
339+
None => return,
340+
};
343341

344342
if mismatch.actual != Ty::unit() || mismatch.expected != *possible_tail_ty {
345343
return;
346344
}
347345

348346
let (_, source_map) = db.body_with_source_map(self.owner.into());
347+
349348
if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) {
350349
self.sink
351350
.push(RemoveThisSemicolon { file: source_ptr.file_id, expr: source_ptr.value });

crates/ide/src/diagnostics/fixes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use ide_db::{
1616
use syntax::{
1717
algo,
1818
ast::{self, edit::IndentLevel, make},
19-
AstNode, Direction, T,
19+
AstNode,
2020
};
2121
use text_edit::TextEdit;
2222

@@ -110,9 +110,9 @@ impl DiagnosticWithFix for RemoveThisSemicolon {
110110
.expr
111111
.to_node(&root)
112112
.syntax()
113-
.siblings_with_tokens(Direction::Next)
114-
.filter_map(|it| it.into_token())
115-
.find(|it| it.kind() == T![;])?
113+
.parent()
114+
.and_then(ast::ExprStmt::cast)
115+
.and_then(|expr| expr.semicolon_token())?
116116
.text_range();
117117

118118
let edit = TextEdit::delete(semicolon);

0 commit comments

Comments
 (0)