diff options
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index c6d442ec4..893bad9cd 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -331,8 +331,8 @@ impl_arena_id!(PatId); | |||
331 | 331 | ||
332 | #[derive(Debug, Clone, Eq, PartialEq)] | 332 | #[derive(Debug, Clone, Eq, PartialEq)] |
333 | pub struct FieldPat { | 333 | pub struct FieldPat { |
334 | name: Name, | 334 | pub(crate) name: Name, |
335 | pat: Option<PatId>, | 335 | pub(crate) pat: Option<PatId>, |
336 | } | 336 | } |
337 | 337 | ||
338 | /// Close relative to rustc's hir::PatKind | 338 | /// Close relative to rustc's hir::PatKind |
@@ -392,7 +392,9 @@ impl Pat { | |||
392 | let total_iter = prefix.iter().chain(rest.iter()).chain(suffix.iter()); | 392 | let total_iter = prefix.iter().chain(rest.iter()).chain(suffix.iter()); |
393 | total_iter.map(|pat| *pat).for_each(f); | 393 | total_iter.map(|pat| *pat).for_each(f); |
394 | } | 394 | } |
395 | Pat::Struct { .. } => {} // TODO | 395 | Pat::Struct { args, .. } => { |
396 | args.iter().filter_map(|a| a.pat).for_each(f); | ||
397 | } | ||
396 | } | 398 | } |
397 | } | 399 | } |
398 | } | 400 | } |
@@ -814,23 +816,20 @@ impl ExprCollector { | |||
814 | ast::PatKind::PlaceholderPat(_) => Pat::Wild, | 816 | ast::PatKind::PlaceholderPat(_) => Pat::Wild, |
815 | ast::PatKind::StructPat(p) => { | 817 | ast::PatKind::StructPat(p) => { |
816 | let path = p.path().and_then(Path::from_ast); | 818 | let path = p.path().and_then(Path::from_ast); |
817 | 819 | let fields = p | |
818 | if let Some(field_list) = p.field_pat_list() { | 820 | .field_pat_list() |
819 | let fields = field_list | 821 | .expect("every struct should have a field list") |
820 | .field_pats() | 822 | .field_pats() |
821 | .into_iter() | 823 | .into_iter() |
822 | .map(|f| FieldPat { | 824 | .map(|f| FieldPat { |
823 | name: Name::new(f.ident), | 825 | name: Name::new(f.ident), |
824 | pat: f.pat.as_ref().map(|p| self.collect_pat(p)), | 826 | pat: f.pat.as_ref().map(|p| self.collect_pat(p)), |
825 | }) | 827 | }) |
826 | .collect(); | 828 | .collect(); |
827 | 829 | ||
828 | Pat::Struct { | 830 | Pat::Struct { |
829 | path: path, | 831 | path: path, |
830 | args: fields, | 832 | args: fields, |
831 | } | ||
832 | } else { | ||
833 | Pat::Missing | ||
834 | } | 833 | } |
835 | } | 834 | } |
836 | 835 | ||