From f9a6050034b2ab4358d8a46dd8432de41cebdf0c Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Fri, 18 Jan 2019 14:52:31 +0100 Subject: Move parsing of field pattern lists to the parser (where it belongs) --- crates/ra_hir/src/expr.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir') 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 { let fields = p .field_pat_list() .expect("every struct should have a field list") - .field_pats() - .into_iter() + .pats() .map(|f| { - let name = Name::new(f.ident); - let pat = self.collect_pat(&*f.pat); + let ast_pat = f.pat().expect("field pat always contains a pattern"); + let pat = self.collect_pat(ast_pat); + let name = f + .name() + .unwrap_or_else(|| { + ast::BindPat::cast(ast_pat.syntax()) + .expect("field pat without label is a bind pat") + .name() + .expect("bind pat has a name") + }) + .as_name(); FieldPat { name, pat } }) .collect(); -- cgit v1.2.3