mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 02:00:00 +03:00
Cast to ExprStmt, style fixes
This commit is contained in:
@@ -334,18 +334,17 @@ fn validate_missing_tail_expr(
|
||||
None => return,
|
||||
};
|
||||
|
||||
let possible_tail_ty =
|
||||
if let Some(possible_tail_ty) = self.infer.type_of_expr.get(possible_tail_id) {
|
||||
possible_tail_ty
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
let possible_tail_ty = match self.infer.type_of_expr.get(possible_tail_id) {
|
||||
Some(ty) => ty,
|
||||
None => return,
|
||||
};
|
||||
|
||||
if mismatch.actual != Ty::unit() || mismatch.expected != *possible_tail_ty {
|
||||
return;
|
||||
}
|
||||
|
||||
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 });
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
use syntax::{
|
||||
algo,
|
||||
ast::{self, edit::IndentLevel, make},
|
||||
AstNode, Direction, T,
|
||||
AstNode,
|
||||
};
|
||||
use text_edit::TextEdit;
|
||||
|
||||
@@ -110,9 +110,9 @@ fn fix(&self, sema: &Semantics<RootDatabase>) -> Option<Fix> {
|
||||
.expr
|
||||
.to_node(&root)
|
||||
.syntax()
|
||||
.siblings_with_tokens(Direction::Next)
|
||||
.filter_map(|it| it.into_token())
|
||||
.find(|it| it.kind() == T![;])?
|
||||
.parent()
|
||||
.and_then(ast::ExprStmt::cast)
|
||||
.and_then(|expr| expr.semicolon_token())?
|
||||
.text_range();
|
||||
|
||||
let edit = TextEdit::delete(semicolon);
|
||||
|
||||
Reference in New Issue
Block a user