diff options
Diffstat (limited to 'crates/ra_hir_ty/src/expr.rs')
-rw-r--r-- | crates/ra_hir_ty/src/expr.rs | 55 |
1 files changed, 25 insertions, 30 deletions
diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index 03ef488b9..21abbcf1e 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs | |||
@@ -89,21 +89,19 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
89 | let (_, source_map) = db.body_with_source_map(self.func.into()); | 89 | let (_, source_map) = db.body_with_source_map(self.func.into()); |
90 | 90 | ||
91 | if let Ok(source_ptr) = source_map.expr_syntax(id) { | 91 | if let Ok(source_ptr) = source_map.expr_syntax(id) { |
92 | if let Some(expr) = source_ptr.value.as_ref().left() { | 92 | let root = source_ptr.file_syntax(db.upcast()); |
93 | let root = source_ptr.file_syntax(db.upcast()); | 93 | if let ast::Expr::RecordLit(record_lit) = &source_ptr.value.to_node(&root) { |
94 | if let ast::Expr::RecordLit(record_lit) = expr.to_node(&root) { | 94 | if let Some(field_list) = record_lit.record_field_list() { |
95 | if let Some(field_list) = record_lit.record_field_list() { | 95 | let variant_data = variant_data(db.upcast(), variant_def); |
96 | let variant_data = variant_data(db.upcast(), variant_def); | 96 | let missed_fields = missed_fields |
97 | let missed_fields = missed_fields | 97 | .into_iter() |
98 | .into_iter() | 98 | .map(|idx| variant_data.fields()[idx].name.clone()) |
99 | .map(|idx| variant_data.fields()[idx].name.clone()) | 99 | .collect(); |
100 | .collect(); | 100 | self.sink.push(MissingFields { |
101 | self.sink.push(MissingFields { | 101 | file: source_ptr.file_id, |
102 | file: source_ptr.file_id, | 102 | field_list: AstPtr::new(&field_list), |
103 | field_list: AstPtr::new(&field_list), | 103 | missed_fields, |
104 | missed_fields, | 104 | }) |
105 | }) | ||
106 | } | ||
107 | } | 105 | } |
108 | } | 106 | } |
109 | } | 107 | } |
@@ -206,18 +204,16 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
206 | } | 204 | } |
207 | 205 | ||
208 | if let Ok(source_ptr) = source_map.expr_syntax(id) { | 206 | if let Ok(source_ptr) = source_map.expr_syntax(id) { |
209 | if let Some(expr) = source_ptr.value.as_ref().left() { | 207 | let root = source_ptr.file_syntax(db.upcast()); |
210 | let root = source_ptr.file_syntax(db.upcast()); | 208 | if let ast::Expr::MatchExpr(match_expr) = &source_ptr.value.to_node(&root) { |
211 | if let ast::Expr::MatchExpr(match_expr) = expr.to_node(&root) { | 209 | if let (Some(match_expr), Some(arms)) = |
212 | if let (Some(match_expr), Some(arms)) = | 210 | (match_expr.expr(), match_expr.match_arm_list()) |
213 | (match_expr.expr(), match_expr.match_arm_list()) | 211 | { |
214 | { | 212 | self.sink.push(MissingMatchArms { |
215 | self.sink.push(MissingMatchArms { | 213 | file: source_ptr.file_id, |
216 | file: source_ptr.file_id, | 214 | match_expr: AstPtr::new(&match_expr), |
217 | match_expr: AstPtr::new(&match_expr), | 215 | arms: AstPtr::new(&arms), |
218 | arms: AstPtr::new(&arms), | 216 | }) |
219 | }) | ||
220 | } | ||
221 | } | 217 | } |
222 | } | 218 | } |
223 | } | 219 | } |
@@ -248,9 +244,8 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
248 | let (_, source_map) = db.body_with_source_map(self.func.into()); | 244 | let (_, source_map) = db.body_with_source_map(self.func.into()); |
249 | 245 | ||
250 | if let Ok(source_ptr) = source_map.expr_syntax(id) { | 246 | if let Ok(source_ptr) = source_map.expr_syntax(id) { |
251 | if let Some(expr) = source_ptr.value.left() { | 247 | self.sink |
252 | self.sink.push(MissingOkInTailExpr { file: source_ptr.file_id, expr }); | 248 | .push(MissingOkInTailExpr { file: source_ptr.file_id, expr: source_ptr.value }); |
253 | } | ||
254 | } | 249 | } |
255 | } | 250 | } |
256 | } | 251 | } |