diff options
-rw-r--r-- | crates/hir_ty/src/diagnostics/expr.rs | 11 | ||||
-rw-r--r-- | crates/ide/src/diagnostics/fixes.rs | 8 |
2 files changed, 9 insertions, 10 deletions
diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 9e461e0b0..849415706 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs | |||
@@ -334,18 +334,17 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
334 | None => return, | 334 | None => return, |
335 | }; | 335 | }; |
336 | 336 | ||
337 | let possible_tail_ty = | 337 | let possible_tail_ty = match self.infer.type_of_expr.get(possible_tail_id) { |
338 | if let Some(possible_tail_ty) = self.infer.type_of_expr.get(possible_tail_id) { | 338 | Some(ty) => ty, |
339 | possible_tail_ty | 339 | None => return, |
340 | } else { | 340 | }; |
341 | return; | ||
342 | }; | ||
343 | 341 | ||
344 | if mismatch.actual != Ty::unit() || mismatch.expected != *possible_tail_ty { | 342 | if mismatch.actual != Ty::unit() || mismatch.expected != *possible_tail_ty { |
345 | return; | 343 | return; |
346 | } | 344 | } |
347 | 345 | ||
348 | let (_, source_map) = db.body_with_source_map(self.owner.into()); | 346 | let (_, source_map) = db.body_with_source_map(self.owner.into()); |
347 | |||
349 | if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) { | 348 | if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) { |
350 | self.sink | 349 | self.sink |
351 | .push(RemoveThisSemicolon { file: source_ptr.file_id, expr: source_ptr.value }); | 350 | .push(RemoveThisSemicolon { file: source_ptr.file_id, expr: source_ptr.value }); |
diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs index c235b5bf4..ba046232a 100644 --- a/crates/ide/src/diagnostics/fixes.rs +++ b/crates/ide/src/diagnostics/fixes.rs | |||
@@ -16,7 +16,7 @@ use ide_db::{ | |||
16 | use syntax::{ | 16 | use syntax::{ |
17 | algo, | 17 | algo, |
18 | ast::{self, edit::IndentLevel, make}, | 18 | ast::{self, edit::IndentLevel, make}, |
19 | AstNode, Direction, T, | 19 | AstNode, |
20 | }; | 20 | }; |
21 | use text_edit::TextEdit; | 21 | use text_edit::TextEdit; |
22 | 22 | ||
@@ -110,9 +110,9 @@ impl DiagnosticWithFix for RemoveThisSemicolon { | |||
110 | .expr | 110 | .expr |
111 | .to_node(&root) | 111 | .to_node(&root) |
112 | .syntax() | 112 | .syntax() |
113 | .siblings_with_tokens(Direction::Next) | 113 | .parent() |
114 | .filter_map(|it| it.into_token()) | 114 | .and_then(ast::ExprStmt::cast) |
115 | .find(|it| it.kind() == T![;])? | 115 | .and_then(|expr| expr.semicolon_token())? |
116 | .text_range(); | 116 | .text_range(); |
117 | 117 | ||
118 | let edit = TextEdit::delete(semicolon); | 118 | let edit = TextEdit::delete(semicolon); |