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/expr.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir_ty/src/expr.rs') diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index fd59f4320..1d3950b70 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use hir_def::{path::path, resolver::HasResolver, AdtId, FunctionId}; use hir_expand::diagnostics::DiagnosticSink; -use ra_syntax::{ast, AstPtr}; +use ra_syntax::{ast, AstNode, AstPtr}; use rustc_hash::FxHashSet; use crate::{ @@ -100,6 +100,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { self.sink.push(MissingFields { file: source_ptr.file_id, field_list: AstPtr::new(&field_list), + highlight_range: field_list.syntax().text_range(), missed_fields, }) } @@ -130,6 +131,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { self.sink.push(MissingPatFields { file: source_ptr.file_id, field_list: AstPtr::new(&field_list), + highlight_range: field_list.syntax().text_range(), missed_fields, }) } @@ -213,6 +215,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { file: source_ptr.file_id, match_expr: AstPtr::new(&match_expr), arms: AstPtr::new(&arms), + highlight_range: match_expr.syntax().text_range(), }) } } @@ -244,8 +247,13 @@ impl<'a, 'b> ExprValidator<'a, 'b> { let (_, source_map) = db.body_with_source_map(self.func.into()); if let Ok(source_ptr) = source_map.expr_syntax(id) { - self.sink - .push(MissingOkInTailExpr { file: source_ptr.file_id, expr: source_ptr.value }); + let root = source_ptr.file_syntax(db.upcast()); + let highlight_range = source_ptr.value.to_node(&root).syntax().text_range(); + self.sink.push(MissingOkInTailExpr { + file: source_ptr.file_id, + expr: source_ptr.value, + highlight_range, + }); } } } -- cgit v1.2.3