aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/expr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r--crates/ra_hir/src/expr.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index b52f7591d..51dae8e25 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -854,25 +854,25 @@ impl ExprCollector {
854 ast::PatKind::PlaceholderPat(_) => Pat::Wild, 854 ast::PatKind::PlaceholderPat(_) => Pat::Wild,
855 ast::PatKind::StructPat(p) => { 855 ast::PatKind::StructPat(p) => {
856 let path = p.path().and_then(Path::from_ast); 856 let path = p.path().and_then(Path::from_ast);
857 let fields = p 857 let field_pat_list = 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 .pats() 860 let mut fields: Vec<_> = field_pat_list
861 .map(|f| { 861 .bind_pats()
862 let ast_pat = f.pat().expect("field pat always contains a pattern"); 862 .map(|bind_pat| {
863 let ast_pat = ast::Pat::cast(bind_pat.syntax()).expect("bind pat is a pat");
863 let pat = self.collect_pat(ast_pat); 864 let pat = self.collect_pat(ast_pat);
864 let name = f 865 let name = bind_pat.name().expect("bind pat has a name").as_name();
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();
873 FieldPat { name, pat } 866 FieldPat { name, pat }
874 }) 867 })
875 .collect(); 868 .collect();
869 let iter = field_pat_list.field_pats().map(|f| {
870 let ast_pat = f.pat().expect("field pat always contains a pattern");
871 let pat = self.collect_pat(ast_pat);
872 let name = f.name().expect("field pats always have a name").as_name();
873 FieldPat { name, pat }
874 });
875 fields.extend(iter);
876 876
877 Pat::Struct { 877 Pat::Struct {
878 path: path, 878 path: path,