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.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index 67e123e4d..593fe1598 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -315,15 +315,20 @@ pub enum Pat {
315 path: Option<Path>, 315 path: Option<Path>,
316 args: Vec<PatId>, 316 args: Vec<PatId>,
317 }, 317 },
318 Ref {
319 pat: PatId,
320 mutability: Mutability,
321 },
318} 322}
319 323
320impl Pat { 324impl Pat {
321 pub fn walk_child_pats(&self, f: impl FnMut(PatId)) { 325 pub fn walk_child_pats(&self, mut f: impl FnMut(PatId)) {
322 match self { 326 match self {
323 Pat::Missing | Pat::Bind { .. } => {} 327 Pat::Missing | Pat::Bind { .. } => {}
324 Pat::TupleStruct { args, .. } => { 328 Pat::TupleStruct { args, .. } => {
325 args.iter().map(|pat| *pat).for_each(f); 329 args.iter().map(|pat| *pat).for_each(f);
326 } 330 }
331 Pat::Ref { pat, .. } => f(*pat),
327 } 332 }
328 } 333 }
329} 334}
@@ -684,6 +689,11 @@ impl ExprCollector {
684 let args = p.args().map(|p| self.collect_pat(p)).collect(); 689 let args = p.args().map(|p| self.collect_pat(p)).collect();
685 self.alloc_pat(Pat::TupleStruct { path, args }, syntax_ptr) 690 self.alloc_pat(Pat::TupleStruct { path, args }, syntax_ptr)
686 } 691 }
692 ast::PatKind::RefPat(p) => {
693 let pat = self.collect_pat_opt(p.pat());
694 let mutability = Mutability::from_mutable(p.is_mut());
695 self.alloc_pat(Pat::Ref { pat, mutability }, syntax_ptr)
696 }
687 _ => { 697 _ => {
688 // TODO 698 // TODO
689 self.alloc_pat(Pat::Missing, syntax_ptr) 699 self.alloc_pat(Pat::Missing, syntax_ptr)