diff options
Diffstat (limited to 'crates/ra_ide_api/src/diagnostics.rs')
-rw-r--r-- | crates/ra_ide_api/src/diagnostics.rs | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs index f662f7e2f..943fd2f53 100644 --- a/crates/ra_ide_api/src/diagnostics.rs +++ b/crates/ra_ide_api/src/diagnostics.rs | |||
@@ -3,7 +3,7 @@ use hir::{Problem, source_binder}; | |||
3 | use ra_db::SourceDatabase; | 3 | use ra_db::SourceDatabase; |
4 | use ra_syntax::{ | 4 | use ra_syntax::{ |
5 | Location, SourceFile, SyntaxKind, TextRange, SyntaxNode, | 5 | Location, SourceFile, SyntaxKind, TextRange, SyntaxNode, |
6 | ast::{self, AstNode, NameOwner}, | 6 | ast::{self, AstNode}, |
7 | 7 | ||
8 | }; | 8 | }; |
9 | use ra_text_edit::{TextEdit, TextEditBuilder}; | 9 | use ra_text_edit::{TextEdit, TextEditBuilder}; |
@@ -161,23 +161,13 @@ fn check_module( | |||
161 | } | 161 | } |
162 | 162 | ||
163 | fn check_function(acc: &mut Vec<Diagnostic>, db: &RootDatabase, function: hir::Function) { | 163 | fn check_function(acc: &mut Vec<Diagnostic>, db: &RootDatabase, function: hir::Function) { |
164 | let (_file_id, fn_def) = function.source(db); | 164 | for d in function.diagnostics(db).iter() { |
165 | let source_file = fn_def.syntax().ancestors().find_map(ast::SourceFile::cast).unwrap(); | 165 | acc.push(Diagnostic { |
166 | let source_map = function.body_source_map(db); | 166 | message: d.message(), |
167 | for d in function.diagnostics(db) { | 167 | range: d.syntax_node().range(), |
168 | match d { | 168 | severity: Severity::Error, |
169 | hir::diagnostics::FunctionDiagnostic::NoSuchField { expr, field } => { | 169 | fix: None, |
170 | if let Some(field) = source_map.field_syntax(expr, field) { | 170 | }) |
171 | let field = field.to_node(&source_file); | ||
172 | acc.push(Diagnostic { | ||
173 | message: "no such field".into(), | ||
174 | range: field.syntax().range(), | ||
175 | severity: Severity::Error, | ||
176 | fix: None, | ||
177 | }) | ||
178 | } | ||
179 | } | ||
180 | } | ||
181 | } | 171 | } |
182 | } | 172 | } |
183 | 173 | ||