diff options
author | Marcus Klaas de Vries <[email protected]> | 2019-01-18 13:52:31 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-19 12:37:26 +0000 |
commit | f9a6050034b2ab4358d8a46dd8432de41cebdf0c (patch) | |
tree | 9de2701b95000fc0a089213bebf8b88924ff61c4 /crates/ra_hir | |
parent | d2769837f1f9c94b977bd6022090f8e5cd02410c (diff) |
Move parsing of field pattern lists to the parser (where it belongs)
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 1d0beb148..b52f7591d 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -857,11 +857,19 @@ impl ExprCollector { | |||
857 | let fields = p | 857 | let fields = p |
858 | .field_pat_list() | 858 | .field_pat_list() |
859 | .expect("every struct should have a field list") | 859 | .expect("every struct should have a field list") |
860 | .field_pats() | 860 | .pats() |
861 | .into_iter() | ||
862 | .map(|f| { | 861 | .map(|f| { |
863 | let name = Name::new(f.ident); | 862 | let ast_pat = f.pat().expect("field pat always contains a pattern"); |
864 | let pat = self.collect_pat(&*f.pat); | 863 | let pat = self.collect_pat(ast_pat); |
864 | let name = f | ||
865 | .name() | ||
866 | .unwrap_or_else(|| { | ||
867 | ast::BindPat::cast(ast_pat.syntax()) | ||
868 | .expect("field pat without label is a bind pat") | ||
869 | .name() | ||
870 | .expect("bind pat has a name") | ||
871 | }) | ||
872 | .as_name(); | ||
865 | FieldPat { name, pat } | 873 | FieldPat { name, pat } |
866 | }) | 874 | }) |
867 | .collect(); | 875 | .collect(); |