From 302bf97bbf1855e3c7def9ab4f9f3d338be5e3b7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 17 Apr 2020 11:38:51 +0200 Subject: Don't expose impl details of SyntaxPtr --- crates/ra_hir_ty/src/infer.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir_ty/src/infer.rs') diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index 246b0e9be..7e6cdefe4 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs @@ -665,6 +665,7 @@ impl Expectation { mod diagnostics { use hir_def::{expr::ExprId, src::HasSource, FunctionId, Lookup}; use hir_expand::diagnostics::DiagnosticSink; + use ra_syntax::AstNode; use crate::{db::HirDatabase, diagnostics::NoSuchField}; @@ -682,10 +683,16 @@ mod diagnostics { ) { match self { InferenceDiagnostic::NoSuchField { expr, field } => { - let file = owner.lookup(db.upcast()).source(db.upcast()).file_id; + let source = owner.lookup(db.upcast()).source(db.upcast()); let (_, source_map) = db.body_with_source_map(owner.into()); let field = source_map.field_syntax(*expr, *field); - sink.push(NoSuchField { file, field }) + let root = field.file_syntax(db.upcast()); + let highlight_range = field.value.to_node(&root).syntax().text_range(); + sink.push(NoSuchField { + file: source.file_id, + field: field.value, + highlight_range, + }) } } } -- cgit v1.2.3 From 146f6f5a45a4bfd98ab0eb54bb30610d784433c9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 17 Apr 2020 13:55:05 +0200 Subject: Simplify Diagnostic structure It's not entirely clear what subnode ranges should mean in the presence of macros, so let's leave them out for now. We are not using them heavily anyway. --- crates/ra_hir_ty/src/infer.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'crates/ra_hir_ty/src/infer.rs') diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index 7e6cdefe4..b6d9b3438 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs @@ -665,7 +665,6 @@ impl Expectation { mod diagnostics { use hir_def::{expr::ExprId, src::HasSource, FunctionId, Lookup}; use hir_expand::diagnostics::DiagnosticSink; - use ra_syntax::AstNode; use crate::{db::HirDatabase, diagnostics::NoSuchField}; @@ -686,13 +685,7 @@ mod diagnostics { let source = owner.lookup(db.upcast()).source(db.upcast()); let (_, source_map) = db.body_with_source_map(owner.into()); let field = source_map.field_syntax(*expr, *field); - let root = field.file_syntax(db.upcast()); - let highlight_range = field.value.to_node(&root).syntax().text_range(); - sink.push(NoSuchField { - file: source.file_id, - field: field.value, - highlight_range, - }) + sink.push(NoSuchField { file: source.file_id, field: field.value }) } } } -- cgit v1.2.3