From 7738467e0a11c9878d9e9486daeb0dc18d93b8e8 Mon Sep 17 00:00:00 2001 From: ivan770 Date: Tue, 8 Dec 2020 19:25:21 +0000 Subject: Format code --- crates/hir/src/diagnostics.rs | 2 +- crates/hir_ty/src/diagnostics/expr.rs | 17 +++++++++++++---- crates/ide/src/diagnostics/fixes.rs | 13 ++++++++++--- 3 files changed, 24 insertions(+), 8 deletions(-) (limited to 'crates') diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index 0f2ed4bb1..b1c924167 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs @@ -5,5 +5,5 @@ pub use hir_expand::diagnostics::{ }; pub use hir_ty::diagnostics::{ IncorrectCase, MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, - NoSuchField, RemoveThisSemicolon + NoSuchField, RemoveThisSemicolon, }; diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 6ec15c180..98b3cade2 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs @@ -2,7 +2,7 @@ use std::sync::Arc; -use hir_def::{AdtId, DefWithBodyId, expr::Statement, path::path, resolver::HasResolver}; +use hir_def::{expr::Statement, path::path, resolver::HasResolver, AdtId, DefWithBodyId}; use hir_expand::diagnostics::DiagnosticSink; use rustc_hash::FxHashSet; use syntax::{ast, AstPtr}; @@ -11,7 +11,8 @@ use crate::{ db::HirDatabase, diagnostics::{ match_check::{is_useful, MatchCheckCtx, Matrix, PatStack, Usefulness}, - MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, MissingPatFields, RemoveThisSemicolon + MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, MissingPatFields, + RemoveThisSemicolon, }, utils::variant_data, ApplicationTy, InferenceResult, Ty, TypeCtor, @@ -324,7 +325,12 @@ impl<'a, 'b> ExprValidator<'a, 'b> { } } - fn validate_missing_tail_expr(&mut self, body_id: ExprId, possible_tail_id: ExprId, db: &dyn HirDatabase) { + fn validate_missing_tail_expr( + &mut self, + body_id: ExprId, + possible_tail_id: ExprId, + db: &dyn HirDatabase, + ) { let mismatch = match self.infer.type_mismatch_for_expr(body_id) { Some(m) => m, None => return, @@ -335,7 +341,10 @@ impl<'a, 'b> ExprValidator<'a, 'b> { 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 }); + self.sink.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 7b05e87f2..c235b5bf4 100644 --- a/crates/ide/src/diagnostics/fixes.rs +++ b/crates/ide/src/diagnostics/fixes.rs @@ -13,7 +13,11 @@ use ide_db::{ source_change::{FileSystemEdit, SourceFileEdit}, RootDatabase, }; -use syntax::{AstNode, Direction, T, algo, ast::{self, edit::IndentLevel, make}}; +use syntax::{ + algo, + ast::{self, edit::IndentLevel, make}, + AstNode, Direction, T, +}; use text_edit::TextEdit; use crate::{diagnostics::Fix, references::rename::rename_with_semantics, FilePosition}; @@ -102,7 +106,9 @@ impl DiagnosticWithFix for RemoveThisSemicolon { fn fix(&self, sema: &Semantics) -> Option { let root = sema.db.parse_or_expand(self.file)?; - let semicolon = self.expr.to_node(&root) + let semicolon = self + .expr + .to_node(&root) .syntax() .siblings_with_tokens(Direction::Next) .filter_map(|it| it.into_token()) @@ -110,7 +116,8 @@ impl DiagnosticWithFix for RemoveThisSemicolon { .text_range(); let edit = TextEdit::delete(semicolon); - let source_change = SourceFileEdit { file_id: self.file.original_file(sema.db), edit }.into(); + let source_change = + SourceFileEdit { file_id: self.file.original_file(sema.db), edit }.into(); Some(Fix::new("Remove this semicolon", source_change, semicolon)) } -- cgit v1.2.3