diff options
Diffstat (limited to 'crates/hir_def/src/body/lower.rs')
-rw-r--r-- | crates/hir_def/src/body/lower.rs | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs index 8c8eb8007..8934ae6c9 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs | |||
@@ -379,23 +379,22 @@ impl ExprCollector<'_> { | |||
379 | } | 379 | } |
380 | ast::Expr::RecordExpr(e) => { | 380 | ast::Expr::RecordExpr(e) => { |
381 | let path = e.path().and_then(|path| self.expander.parse_path(path)); | 381 | let path = e.path().and_then(|path| self.expander.parse_path(path)); |
382 | let mut field_ptrs = Vec::new(); | ||
383 | let record_lit = if let Some(nfl) = e.record_expr_field_list() { | 382 | let record_lit = if let Some(nfl) = e.record_expr_field_list() { |
384 | let fields = nfl | 383 | let fields = nfl |
385 | .fields() | 384 | .fields() |
386 | .inspect(|field| field_ptrs.push(AstPtr::new(field))) | ||
387 | .filter_map(|field| { | 385 | .filter_map(|field| { |
388 | self.check_cfg(&field)?; | 386 | self.check_cfg(&field)?; |
389 | 387 | ||
390 | let name = field.field_name()?.as_name(); | 388 | let name = field.field_name()?.as_name(); |
391 | 389 | ||
392 | Some(RecordLitField { | 390 | let expr = match field.expr() { |
393 | name, | 391 | Some(e) => self.collect_expr(e), |
394 | expr: match field.expr() { | 392 | None => self.missing_expr(), |
395 | Some(e) => self.collect_expr(e), | 393 | }; |
396 | None => self.missing_expr(), | 394 | let src = self.expander.to_source(AstPtr::new(&field)); |
397 | }, | 395 | self.source_map.field_map.insert(src.clone(), expr); |
398 | }) | 396 | self.source_map.field_map_back.insert(expr, src); |
397 | Some(RecordLitField { name, expr }) | ||
399 | }) | 398 | }) |
400 | .collect(); | 399 | .collect(); |
401 | let spread = nfl.spread().map(|s| self.collect_expr(s)); | 400 | let spread = nfl.spread().map(|s| self.collect_expr(s)); |
@@ -404,12 +403,7 @@ impl ExprCollector<'_> { | |||
404 | Expr::RecordLit { path, fields: Vec::new(), spread: None } | 403 | Expr::RecordLit { path, fields: Vec::new(), spread: None } |
405 | }; | 404 | }; |
406 | 405 | ||
407 | let res = self.alloc_expr(record_lit, syntax_ptr); | 406 | self.alloc_expr(record_lit, syntax_ptr) |
408 | for (i, ptr) in field_ptrs.into_iter().enumerate() { | ||
409 | let src = self.expander.to_source(ptr); | ||
410 | self.source_map.field_map.insert((res, i), src); | ||
411 | } | ||
412 | res | ||
413 | } | 407 | } |
414 | ast::Expr::FieldExpr(e) => { | 408 | ast::Expr::FieldExpr(e) => { |
415 | let expr = self.collect_expr_opt(e.expr()); | 409 | let expr = self.collect_expr_opt(e.expr()); |