mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Cast to ExprStmt, style fixes
This commit is contained in:
parent
35006eba79
commit
bbb0bc7b04
2 changed files with 9 additions and 10 deletions
|
@ -334,11 +334,9 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
let possible_tail_ty =
|
let possible_tail_ty = match self.infer.type_of_expr.get(possible_tail_id) {
|
||||||
if let Some(possible_tail_ty) = self.infer.type_of_expr.get(possible_tail_id) {
|
Some(ty) => ty,
|
||||||
possible_tail_ty
|
None => return,
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if mismatch.actual != Ty::unit() || mismatch.expected != *possible_tail_ty {
|
if mismatch.actual != Ty::unit() || mismatch.expected != *possible_tail_ty {
|
||||||
|
@ -346,6 +344,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let (_, source_map) = db.body_with_source_map(self.owner.into());
|
let (_, source_map) = db.body_with_source_map(self.owner.into());
|
||||||
|
|
||||||
if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) {
|
if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) {
|
||||||
self.sink
|
self.sink
|
||||||
.push(RemoveThisSemicolon { file: source_ptr.file_id, expr: source_ptr.value });
|
.push(RemoveThisSemicolon { file: source_ptr.file_id, expr: source_ptr.value });
|
||||||
|
|
|
@ -16,7 +16,7 @@ use ide_db::{
|
||||||
use syntax::{
|
use syntax::{
|
||||||
algo,
|
algo,
|
||||||
ast::{self, edit::IndentLevel, make},
|
ast::{self, edit::IndentLevel, make},
|
||||||
AstNode, Direction, T,
|
AstNode,
|
||||||
};
|
};
|
||||||
use text_edit::TextEdit;
|
use text_edit::TextEdit;
|
||||||
|
|
||||||
|
@ -110,9 +110,9 @@ impl DiagnosticWithFix for RemoveThisSemicolon {
|
||||||
.expr
|
.expr
|
||||||
.to_node(&root)
|
.to_node(&root)
|
||||||
.syntax()
|
.syntax()
|
||||||
.siblings_with_tokens(Direction::Next)
|
.parent()
|
||||||
.filter_map(|it| it.into_token())
|
.and_then(ast::ExprStmt::cast)
|
||||||
.find(|it| it.kind() == T![;])?
|
.and_then(|expr| expr.semicolon_token())?
|
||||||
.text_range();
|
.text_range();
|
||||||
|
|
||||||
let edit = TextEdit::delete(semicolon);
|
let edit = TextEdit::delete(semicolon);
|
||||||
|
|
Loading…
Reference in a new issue