aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/expr.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-06 15:27:34 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-06 15:27:34 +0100
commitef782adc293deb287128f005dbab2038ba3ccdc1 (patch)
tree6e451b71b482e75a5a30548ab8f769c5ec17864c /crates/ra_hir/src/expr.rs
parent32db5884ada59c72aa7ab9f88910ef7c8f882e7d (diff)
parent12f8472d2800b2d7c05cb1fc466c80072ed8e283 (diff)
Merge #1163
1163: fill struct fields diagnostic r=matklad a=pasa implementation of #1095 Co-authored-by: Sergey Parilin <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r--crates/ra_hir/src/expr.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index 692da2895..480eaf171 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -19,6 +19,7 @@ use crate::{path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, U
19pub use self::scope::ExprScopes; 19pub use self::scope::ExprScopes;
20 20
21pub(crate) mod scope; 21pub(crate) mod scope;
22pub(crate) mod validation;
22 23
23#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] 24#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
24pub struct ExprId(RawId); 25pub struct ExprId(RawId);
@@ -670,8 +671,9 @@ where
670 ast::ExprKind::StructLit(e) => { 671 ast::ExprKind::StructLit(e) => {
671 let path = e.path().and_then(Path::from_ast); 672 let path = e.path().and_then(Path::from_ast);
672 let mut field_ptrs = Vec::new(); 673 let mut field_ptrs = Vec::new();
673 let fields = if let Some(nfl) = e.named_field_list() { 674 let struct_lit = if let Some(nfl) = e.named_field_list() {
674 nfl.fields() 675 let fields = nfl
676 .fields()
675 .inspect(|field| field_ptrs.push(AstPtr::new(*field))) 677 .inspect(|field| field_ptrs.push(AstPtr::new(*field)))
676 .map(|field| StructLitField { 678 .map(|field| StructLitField {
677 name: field 679 name: field
@@ -694,12 +696,14 @@ where
694 self.exprs.alloc(Expr::Missing) 696 self.exprs.alloc(Expr::Missing)
695 }, 697 },
696 }) 698 })
697 .collect() 699 .collect();
700 let spread = nfl.spread().map(|s| self.collect_expr(s));
701 Expr::StructLit { path, fields, spread }
698 } else { 702 } else {
699 Vec::new() 703 Expr::StructLit { path, fields: Vec::new(), spread: None }
700 }; 704 };
701 let spread = e.spread().map(|s| self.collect_expr(s)); 705
702 let res = self.alloc_expr(Expr::StructLit { path, fields, spread }, syntax_ptr); 706 let res = self.alloc_expr(struct_lit, syntax_ptr);
703 for (i, ptr) in field_ptrs.into_iter().enumerate() { 707 for (i, ptr) in field_ptrs.into_iter().enumerate() {
704 self.source_map.field_map.insert((res, i), ptr); 708 self.source_map.field_map.insert((res, i), ptr);
705 } 709 }