diff options
Diffstat (limited to 'crates/ra_hir/src/expr/validation.rs')
-rw-r--r-- | crates/ra_hir/src/expr/validation.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs index c8ae19869..6fdaf1fce 100644 --- a/crates/ra_hir/src/expr/validation.rs +++ b/crates/ra_hir/src/expr/validation.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use rustc_hash::FxHashSet; | ||
2 | use std::sync::Arc; | 1 | use std::sync::Arc; |
3 | 2 | ||
4 | use ra_syntax::ast::{AstNode, RecordLit}; | 3 | use ra_syntax::ast::{self, AstNode}; |
4 | use rustc_hash::FxHashSet; | ||
5 | 5 | ||
6 | use super::{Expr, ExprId, RecordLitField}; | 6 | use super::{Expr, ExprId, RecordLitField}; |
7 | use crate::{ | 7 | use crate::{ |
@@ -13,7 +13,6 @@ use crate::{ | |||
13 | ty::{ApplicationTy, InferenceResult, Ty, TypeCtor}, | 13 | ty::{ApplicationTy, InferenceResult, Ty, TypeCtor}, |
14 | Function, HasSource, HirDatabase, ModuleDef, Name, Path, PerNs, Resolution, | 14 | Function, HasSource, HirDatabase, ModuleDef, Name, Path, PerNs, Resolution, |
15 | }; | 15 | }; |
16 | use ra_syntax::ast; | ||
17 | 16 | ||
18 | pub(crate) struct ExprValidator<'a, 'b: 'a> { | 17 | pub(crate) struct ExprValidator<'a, 'b: 'a> { |
19 | func: Function, | 18 | func: Function, |
@@ -84,8 +83,12 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
84 | let source_file = parse.tree(); | 83 | let source_file = parse.tree(); |
85 | if let Some(field_list_node) = source_map | 84 | if let Some(field_list_node) = source_map |
86 | .expr_syntax(id) | 85 | .expr_syntax(id) |
86 | .and_then(|ptr| ptr.a()) | ||
87 | .map(|ptr| ptr.to_node(source_file.syntax())) | 87 | .map(|ptr| ptr.to_node(source_file.syntax())) |
88 | .and_then(RecordLit::cast) | 88 | .and_then(|expr| match expr { |
89 | ast::Expr::RecordLit(it) => Some(it), | ||
90 | _ => None, | ||
91 | }) | ||
89 | .and_then(|lit| lit.record_field_list()) | 92 | .and_then(|lit| lit.record_field_list()) |
90 | { | 93 | { |
91 | let field_list_ptr = AstPtr::new(&field_list_node); | 94 | let field_list_ptr = AstPtr::new(&field_list_node); |
@@ -135,7 +138,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
135 | let source_map = self.func.body_source_map(db); | 138 | let source_map = self.func.body_source_map(db); |
136 | let file_id = self.func.source(db).file_id; | 139 | let file_id = self.func.source(db).file_id; |
137 | 140 | ||
138 | if let Some(expr) = source_map.expr_syntax(id).and_then(|n| n.cast::<ast::Expr>()) { | 141 | if let Some(expr) = source_map.expr_syntax(id).and_then(|n| n.a()) { |
139 | self.sink.push(MissingOkInTailExpr { file: file_id, expr }); | 142 | self.sink.push(MissingOkInTailExpr { file: file_id, expr }); |
140 | } | 143 | } |
141 | } | 144 | } |