Move parsing of field pattern lists to the parser (where it belongs)

This commit is contained in:
Marcus Klaas de Vries 2019-01-18 14:52:31 +01:00 committed by Aleksey Kladov
parent d2769837f1
commit f9a6050034
6 changed files with 71 additions and 64 deletions

View file

@ -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();