Skip to content

Commit 7738467

Browse files
authored
Format code
1 parent f2950a1 commit 7738467

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

crates/hir/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ pub use hir_expand::diagnostics::{
55
};
66
pub use hir_ty::diagnostics::{
77
IncorrectCase, MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr,
8-
NoSuchField, RemoveThisSemicolon
8+
NoSuchField, RemoveThisSemicolon,
99
};

crates/hir_ty/src/diagnostics/expr.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::sync::Arc;
44

5-
use hir_def::{AdtId, DefWithBodyId, expr::Statement, path::path, resolver::HasResolver};
5+
use hir_def::{expr::Statement, path::path, resolver::HasResolver, AdtId, DefWithBodyId};
66
use hir_expand::diagnostics::DiagnosticSink;
77
use rustc_hash::FxHashSet;
88
use syntax::{ast, AstPtr};
@@ -11,7 +11,8 @@ use crate::{
1111
db::HirDatabase,
1212
diagnostics::{
1313
match_check::{is_useful, MatchCheckCtx, Matrix, PatStack, Usefulness},
14-
MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, MissingPatFields, RemoveThisSemicolon
14+
MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, MissingPatFields,
15+
RemoveThisSemicolon,
1516
},
1617
utils::variant_data,
1718
ApplicationTy, InferenceResult, Ty, TypeCtor,
@@ -324,7 +325,12 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
324325
}
325326
}
326327

327-
fn validate_missing_tail_expr(&mut self, body_id: ExprId, possible_tail_id: ExprId, db: &dyn HirDatabase) {
328+
fn validate_missing_tail_expr(
329+
&mut self,
330+
body_id: ExprId,
331+
possible_tail_id: ExprId,
332+
db: &dyn HirDatabase,
333+
) {
328334
let mismatch = match self.infer.type_mismatch_for_expr(body_id) {
329335
Some(m) => m,
330336
None => return,
@@ -335,7 +341,10 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
335341
let (_, source_map) = db.body_with_source_map(self.owner.into());
336342

337343
if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) {
338-
self.sink.push(RemoveThisSemicolon { file: source_ptr.file_id, expr: source_ptr.value });
344+
self.sink.push(RemoveThisSemicolon {
345+
file: source_ptr.file_id,
346+
expr: source_ptr.value,
347+
});
339348
}
340349
}
341350
}

crates/ide/src/diagnostics/fixes.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ use ide_db::{
1313
source_change::{FileSystemEdit, SourceFileEdit},
1414
RootDatabase,
1515
};
16-
use syntax::{AstNode, Direction, T, algo, ast::{self, edit::IndentLevel, make}};
16+
use syntax::{
17+
algo,
18+
ast::{self, edit::IndentLevel, make},
19+
AstNode, Direction, T,
20+
};
1721
use text_edit::TextEdit;
1822

1923
use crate::{diagnostics::Fix, references::rename::rename_with_semantics, FilePosition};
@@ -102,15 +106,18 @@ impl DiagnosticWithFix for RemoveThisSemicolon {
102106
fn fix(&self, sema: &Semantics<RootDatabase>) -> Option<Fix> {
103107
let root = sema.db.parse_or_expand(self.file)?;
104108

105-
let semicolon = self.expr.to_node(&root)
109+
let semicolon = self
110+
.expr
111+
.to_node(&root)
106112
.syntax()
107113
.siblings_with_tokens(Direction::Next)
108114
.filter_map(|it| it.into_token())
109115
.find(|it| it.kind() == T![;])?
110116
.text_range();
111117

112118
let edit = TextEdit::delete(semicolon);
113-
let source_change = SourceFileEdit { file_id: self.file.original_file(sema.db), edit }.into();
119+
let source_change =
120+
SourceFileEdit { file_id: self.file.original_file(sema.db), edit }.into();
114121

115122
Some(Fix::new("Remove this semicolon", source_change, semicolon))
116123
}

0 commit comments

Comments
 (0)