aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/hir/src/diagnostics.rs2
-rw-r--r--crates/hir_ty/src/diagnostics/expr.rs17
-rw-r--r--crates/ide/src/diagnostics/fixes.rs13
3 files changed, 24 insertions, 8 deletions
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::{
5}; 5};
6pub use hir_ty::diagnostics::{ 6pub use hir_ty::diagnostics::{
7 IncorrectCase, MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, 7 IncorrectCase, MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr,
8 NoSuchField, RemoveThisSemicolon 8 NoSuchField, RemoveThisSemicolon,
9}; 9};
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 @@
2 2
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use hir_def::{AdtId, DefWithBodyId, expr::Statement, path::path, resolver::HasResolver}; 5use hir_def::{expr::Statement, path::path, resolver::HasResolver, AdtId, DefWithBodyId};
6use hir_expand::diagnostics::DiagnosticSink; 6use hir_expand::diagnostics::DiagnosticSink;
7use rustc_hash::FxHashSet; 7use rustc_hash::FxHashSet;
8use syntax::{ast, AstPtr}; 8use syntax::{ast, AstPtr};
@@ -11,7 +11,8 @@ use crate::{
11 db::HirDatabase, 11 db::HirDatabase,
12 diagnostics::{ 12 diagnostics::{
13 match_check::{is_useful, MatchCheckCtx, Matrix, PatStack, Usefulness}, 13 match_check::{is_useful, MatchCheckCtx, Matrix, PatStack, Usefulness},
14 MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, MissingPatFields, RemoveThisSemicolon 14 MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkInTailExpr, MissingPatFields,
15 RemoveThisSemicolon,
15 }, 16 },
16 utils::variant_data, 17 utils::variant_data,
17 ApplicationTy, InferenceResult, Ty, TypeCtor, 18 ApplicationTy, InferenceResult, Ty, TypeCtor,
@@ -324,7 +325,12 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
324 } 325 }
325 } 326 }
326 327
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 ) {
328 let mismatch = match self.infer.type_mismatch_for_expr(body_id) { 334 let mismatch = match self.infer.type_mismatch_for_expr(body_id) {
329 Some(m) => m, 335 Some(m) => m,
330 None => return, 336 None => return,
@@ -335,7 +341,10 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
335 let (_, source_map) = db.body_with_source_map(self.owner.into()); 341 let (_, source_map) = db.body_with_source_map(self.owner.into());
336 342
337 if let Ok(source_ptr) = source_map.expr_syntax(possible_tail_id) { 343 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 });
339 } 348 }
340 } 349 }
341 } 350 }
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::{
13 source_change::{FileSystemEdit, SourceFileEdit}, 13 source_change::{FileSystemEdit, SourceFileEdit},
14 RootDatabase, 14 RootDatabase,
15}; 15};
16use syntax::{AstNode, Direction, T, algo, ast::{self, edit::IndentLevel, make}}; 16use syntax::{
17 algo,
18 ast::{self, edit::IndentLevel, make},
19 AstNode, Direction, T,
20};
17use text_edit::TextEdit; 21use text_edit::TextEdit;
18 22
19use crate::{diagnostics::Fix, references::rename::rename_with_semantics, FilePosition}; 23use crate::{diagnostics::Fix, references::rename::rename_with_semantics, FilePosition};
@@ -102,7 +106,9 @@ impl DiagnosticWithFix for RemoveThisSemicolon {
102 fn fix(&self, sema: &Semantics<RootDatabase>) -> Option<Fix> { 106 fn fix(&self, sema: &Semantics<RootDatabase>) -> Option<Fix> {
103 let root = sema.db.parse_or_expand(self.file)?; 107 let root = sema.db.parse_or_expand(self.file)?;
104 108
105 let semicolon = self.expr.to_node(&root) 109 let semicolon = self
110 .expr
111 .to_node(&root)
106 .syntax() 112 .syntax()
107 .siblings_with_tokens(Direction::Next) 113 .siblings_with_tokens(Direction::Next)
108 .filter_map(|it| it.into_token()) 114 .filter_map(|it| it.into_token())
@@ -110,7 +116,8 @@ impl DiagnosticWithFix for RemoveThisSemicolon {
110 .text_range(); 116 .text_range();
111 117
112 let edit = TextEdit::delete(semicolon); 118 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();
114 121
115 Some(Fix::new("Remove this semicolon", source_change, semicolon)) 122 Some(Fix::new("Remove this semicolon", source_change, semicolon))
116 } 123 }