diff --git a/crates/hir_ty/src/diagnostics/expr.rs b/crates/hir_ty/src/diagnostics/expr.rs index 455b0d4aaa3..a1c484fdff4 100644 --- a/crates/hir_ty/src/diagnostics/expr.rs +++ b/crates/hir_ty/src/diagnostics/expr.rs @@ -11,8 +11,8 @@ db::HirDatabase, diagnostics::{ match_check::{is_useful, MatchCheckCtx, Matrix, PatStack, Usefulness}, - MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkOrSomeInTailExpr, MissingPatFields, - RemoveThisSemicolon, + MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkOrSomeInTailExpr, + MissingPatFields, RemoveThisSemicolon, }, utils::variant_data, ApplicationTy, InferenceResult, Ty, TypeCtor, @@ -324,10 +324,10 @@ fn validate_results_in_tail_expr(&mut self, body_id: ExprId, id: ExprId, db: &dy let (params, required) = match &mismatch.expected { Ty::Apply(ApplicationTy { ctor, parameters }) if ctor == &core_result_ctor => { (parameters, "Ok".to_string()) - }, + } Ty::Apply(ApplicationTy { ctor, parameters }) if ctor == &core_option_ctor => { (parameters, "Some".to_string()) - }, + } _ => return, }; @@ -335,8 +335,11 @@ fn validate_results_in_tail_expr(&mut self, body_id: ExprId, id: ExprId, db: &dy let (_, source_map) = db.body_with_source_map(self.owner.into()); if let Ok(source_ptr) = source_map.expr_syntax(id) { - self.sink - .push(MissingOkOrSomeInTailExpr { file: source_ptr.file_id, expr: source_ptr.value, required }); + self.sink.push(MissingOkOrSomeInTailExpr { + file: source_ptr.file_id, + expr: source_ptr.value, + required, + }); } } } diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs index 50c18d02b2a..d7ad88ed523 100644 --- a/crates/ide/src/diagnostics/fixes.rs +++ b/crates/ide/src/diagnostics/fixes.rs @@ -101,7 +101,8 @@ fn fix(&self, sema: &Semantics) -> Option { let tail_expr_range = tail_expr.syntax().text_range(); let replacement = format!("{}({})", self.required, tail_expr.syntax()); let edit = TextEdit::replace(tail_expr_range, replacement); - 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(); let name = if self.required == "Ok" { "Wrap with Ok" } else { "Wrap with Some" }; Some(Fix::new(name, source_change, tail_expr_range)) }