diff options
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 328d635d4..9e8584908 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -60,7 +60,7 @@ pub struct BodySourceMap { | |||
60 | expr_map_back: ArenaMap<ExprId, SyntaxNodePtr>, | 60 | expr_map_back: ArenaMap<ExprId, SyntaxNodePtr>, |
61 | pat_map: FxHashMap<PatPtr, PatId>, | 61 | pat_map: FxHashMap<PatPtr, PatId>, |
62 | pat_map_back: ArenaMap<PatId, PatPtr>, | 62 | pat_map_back: ArenaMap<PatId, PatPtr>, |
63 | field_map: FxHashMap<(ExprId, usize), AstPtr<ast::NamedField>>, | 63 | field_map: FxHashMap<(ExprId, usize), AstPtr<ast::RecordField>>, |
64 | } | 64 | } |
65 | 65 | ||
66 | type PatPtr = Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>; | 66 | type PatPtr = Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>; |
@@ -148,7 +148,7 @@ impl BodySourceMap { | |||
148 | self.pat_map.get(&Either::A(AstPtr::new(node))).cloned() | 148 | self.pat_map.get(&Either::A(AstPtr::new(node))).cloned() |
149 | } | 149 | } |
150 | 150 | ||
151 | pub(crate) fn field_syntax(&self, expr: ExprId, field: usize) -> AstPtr<ast::NamedField> { | 151 | pub(crate) fn field_syntax(&self, expr: ExprId, field: usize) -> AstPtr<ast::RecordField> { |
152 | self.field_map[&(expr, field)] | 152 | self.field_map[&(expr, field)] |
153 | } | 153 | } |
154 | } | 154 | } |
@@ -210,9 +210,9 @@ pub enum Expr { | |||
210 | Return { | 210 | Return { |
211 | expr: Option<ExprId>, | 211 | expr: Option<ExprId>, |
212 | }, | 212 | }, |
213 | StructLit { | 213 | RecordLit { |
214 | path: Option<Path>, | 214 | path: Option<Path>, |
215 | fields: Vec<StructLitField>, | 215 | fields: Vec<RecordLitField>, |
216 | spread: Option<ExprId>, | 216 | spread: Option<ExprId>, |
217 | }, | 217 | }, |
218 | Field { | 218 | Field { |
@@ -316,7 +316,7 @@ pub struct MatchArm { | |||
316 | } | 316 | } |
317 | 317 | ||
318 | #[derive(Debug, Clone, Eq, PartialEq)] | 318 | #[derive(Debug, Clone, Eq, PartialEq)] |
319 | pub struct StructLitField { | 319 | pub struct RecordLitField { |
320 | pub name: Name, | 320 | pub name: Name, |
321 | pub expr: ExprId, | 321 | pub expr: ExprId, |
322 | } | 322 | } |
@@ -388,7 +388,7 @@ impl Expr { | |||
388 | f(*expr); | 388 | f(*expr); |
389 | } | 389 | } |
390 | } | 390 | } |
391 | Expr::StructLit { fields, spread, .. } => { | 391 | Expr::RecordLit { fields, spread, .. } => { |
392 | for field in fields { | 392 | for field in fields { |
393 | f(field.expr); | 393 | f(field.expr); |
394 | } | 394 | } |
@@ -474,7 +474,7 @@ impl BindingAnnotation { | |||
474 | } | 474 | } |
475 | 475 | ||
476 | #[derive(Debug, Clone, Eq, PartialEq)] | 476 | #[derive(Debug, Clone, Eq, PartialEq)] |
477 | pub struct FieldPat { | 477 | pub struct RecordFieldPat { |
478 | pub(crate) name: Name, | 478 | pub(crate) name: Name, |
479 | pub(crate) pat: PatId, | 479 | pub(crate) pat: PatId, |
480 | } | 480 | } |
@@ -487,7 +487,7 @@ pub enum Pat { | |||
487 | Tuple(Vec<PatId>), | 487 | Tuple(Vec<PatId>), |
488 | Struct { | 488 | Struct { |
489 | path: Option<Path>, | 489 | path: Option<Path>, |
490 | args: Vec<FieldPat>, | 490 | args: Vec<RecordFieldPat>, |
491 | // FIXME: 'ellipsis' option | 491 | // FIXME: 'ellipsis' option |
492 | }, | 492 | }, |
493 | Range { | 493 | Range { |
@@ -746,14 +746,14 @@ where | |||
746 | let expr = e.expr().map(|e| self.collect_expr(e)); | 746 | let expr = e.expr().map(|e| self.collect_expr(e)); |
747 | self.alloc_expr(Expr::Return { expr }, syntax_ptr) | 747 | self.alloc_expr(Expr::Return { expr }, syntax_ptr) |
748 | } | 748 | } |
749 | ast::Expr::StructLit(e) => { | 749 | ast::Expr::RecordLit(e) => { |
750 | let path = e.path().and_then(Path::from_ast); | 750 | let path = e.path().and_then(Path::from_ast); |
751 | let mut field_ptrs = Vec::new(); | 751 | let mut field_ptrs = Vec::new(); |
752 | let struct_lit = if let Some(nfl) = e.named_field_list() { | 752 | let record_lit = if let Some(nfl) = e.record_field_list() { |
753 | let fields = nfl | 753 | let fields = nfl |
754 | .fields() | 754 | .fields() |
755 | .inspect(|field| field_ptrs.push(AstPtr::new(field))) | 755 | .inspect(|field| field_ptrs.push(AstPtr::new(field))) |
756 | .map(|field| StructLitField { | 756 | .map(|field| RecordLitField { |
757 | name: field | 757 | name: field |
758 | .name_ref() | 758 | .name_ref() |
759 | .map(|nr| nr.as_name()) | 759 | .map(|nr| nr.as_name()) |
@@ -776,12 +776,12 @@ where | |||
776 | }) | 776 | }) |
777 | .collect(); | 777 | .collect(); |
778 | let spread = nfl.spread().map(|s| self.collect_expr(s)); | 778 | let spread = nfl.spread().map(|s| self.collect_expr(s)); |
779 | Expr::StructLit { path, fields, spread } | 779 | Expr::RecordLit { path, fields, spread } |
780 | } else { | 780 | } else { |
781 | Expr::StructLit { path, fields: Vec::new(), spread: None } | 781 | Expr::RecordLit { path, fields: Vec::new(), spread: None } |
782 | }; | 782 | }; |
783 | 783 | ||
784 | let res = self.alloc_expr(struct_lit, syntax_ptr); | 784 | let res = self.alloc_expr(record_lit, syntax_ptr); |
785 | for (i, ptr) in field_ptrs.into_iter().enumerate() { | 785 | for (i, ptr) in field_ptrs.into_iter().enumerate() { |
786 | self.source_map.field_map.insert((res, i), ptr); | 786 | self.source_map.field_map.insert((res, i), ptr); |
787 | } | 787 | } |
@@ -994,25 +994,25 @@ where | |||
994 | Pat::Tuple(args) | 994 | Pat::Tuple(args) |
995 | } | 995 | } |
996 | ast::Pat::PlaceholderPat(_) => Pat::Wild, | 996 | ast::Pat::PlaceholderPat(_) => Pat::Wild, |
997 | ast::Pat::StructPat(p) => { | 997 | ast::Pat::RecordPat(p) => { |
998 | let path = p.path().and_then(Path::from_ast); | 998 | let path = p.path().and_then(Path::from_ast); |
999 | let field_pat_list = | 999 | let record_field_pat_list = |
1000 | p.field_pat_list().expect("every struct should have a field list"); | 1000 | p.record_field_pat_list().expect("every struct should have a field list"); |
1001 | let mut fields: Vec<_> = field_pat_list | 1001 | let mut fields: Vec<_> = record_field_pat_list |
1002 | .bind_pats() | 1002 | .bind_pats() |
1003 | .filter_map(|bind_pat| { | 1003 | .filter_map(|bind_pat| { |
1004 | let ast_pat = | 1004 | let ast_pat = |
1005 | ast::Pat::cast(bind_pat.syntax().clone()).expect("bind pat is a pat"); | 1005 | ast::Pat::cast(bind_pat.syntax().clone()).expect("bind pat is a pat"); |
1006 | let pat = self.collect_pat(ast_pat); | 1006 | let pat = self.collect_pat(ast_pat); |
1007 | let name = bind_pat.name()?.as_name(); | 1007 | let name = bind_pat.name()?.as_name(); |
1008 | Some(FieldPat { name, pat }) | 1008 | Some(RecordFieldPat { name, pat }) |
1009 | }) | 1009 | }) |
1010 | .collect(); | 1010 | .collect(); |
1011 | let iter = field_pat_list.field_pats().filter_map(|f| { | 1011 | let iter = record_field_pat_list.record_field_pats().filter_map(|f| { |
1012 | let ast_pat = f.pat()?; | 1012 | let ast_pat = f.pat()?; |
1013 | let pat = self.collect_pat(ast_pat); | 1013 | let pat = self.collect_pat(ast_pat); |
1014 | let name = f.name()?.as_name(); | 1014 | let name = f.name()?.as_name(); |
1015 | Some(FieldPat { name, pat }) | 1015 | Some(RecordFieldPat { name, pat }) |
1016 | }); | 1016 | }); |
1017 | fields.extend(iter); | 1017 | fields.extend(iter); |
1018 | 1018 | ||