diff options
Diffstat (limited to 'crates/ra_hir_ty/src/expr.rs')
-rw-r--r-- | crates/ra_hir_ty/src/expr.rs | 14 |
1 files changed, 11 insertions, 3 deletions
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; | |||
4 | 4 | ||
5 | use hir_def::{path::path, resolver::HasResolver, AdtId, FunctionId}; | 5 | use hir_def::{path::path, resolver::HasResolver, AdtId, FunctionId}; |
6 | use hir_expand::diagnostics::DiagnosticSink; | 6 | use hir_expand::diagnostics::DiagnosticSink; |
7 | use ra_syntax::{ast, AstPtr}; | 7 | use ra_syntax::{ast, AstNode, AstPtr}; |
8 | use rustc_hash::FxHashSet; | 8 | use rustc_hash::FxHashSet; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
@@ -100,6 +100,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
100 | self.sink.push(MissingFields { | 100 | self.sink.push(MissingFields { |
101 | file: source_ptr.file_id, | 101 | file: source_ptr.file_id, |
102 | field_list: AstPtr::new(&field_list), | 102 | field_list: AstPtr::new(&field_list), |
103 | highlight_range: field_list.syntax().text_range(), | ||
103 | missed_fields, | 104 | missed_fields, |
104 | }) | 105 | }) |
105 | } | 106 | } |
@@ -130,6 +131,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
130 | self.sink.push(MissingPatFields { | 131 | self.sink.push(MissingPatFields { |
131 | file: source_ptr.file_id, | 132 | file: source_ptr.file_id, |
132 | field_list: AstPtr::new(&field_list), | 133 | field_list: AstPtr::new(&field_list), |
134 | highlight_range: field_list.syntax().text_range(), | ||
133 | missed_fields, | 135 | missed_fields, |
134 | }) | 136 | }) |
135 | } | 137 | } |
@@ -213,6 +215,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
213 | file: source_ptr.file_id, | 215 | file: source_ptr.file_id, |
214 | match_expr: AstPtr::new(&match_expr), | 216 | match_expr: AstPtr::new(&match_expr), |
215 | arms: AstPtr::new(&arms), | 217 | arms: AstPtr::new(&arms), |
218 | highlight_range: match_expr.syntax().text_range(), | ||
216 | }) | 219 | }) |
217 | } | 220 | } |
218 | } | 221 | } |
@@ -244,8 +247,13 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
244 | let (_, source_map) = db.body_with_source_map(self.func.into()); | 247 | let (_, source_map) = db.body_with_source_map(self.func.into()); |
245 | 248 | ||
246 | if let Ok(source_ptr) = source_map.expr_syntax(id) { | 249 | if let Ok(source_ptr) = source_map.expr_syntax(id) { |
247 | self.sink | 250 | let root = source_ptr.file_syntax(db.upcast()); |
248 | .push(MissingOkInTailExpr { file: source_ptr.file_id, expr: source_ptr.value }); | 251 | let highlight_range = source_ptr.value.to_node(&root).syntax().text_range(); |
252 | self.sink.push(MissingOkInTailExpr { | ||
253 | file: source_ptr.file_id, | ||
254 | expr: source_ptr.value, | ||
255 | highlight_range, | ||
256 | }); | ||
249 | } | 257 | } |
250 | } | 258 | } |
251 | } | 259 | } |