aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r--crates/ra_hir_def/src/body/lower.rs16
-rw-r--r--crates/ra_hir_def/src/expr.rs6
2 files changed, 15 insertions, 7 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index fe0973fc7..1fc892362 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -8,7 +8,7 @@ use ra_arena::Arena;
8use ra_syntax::{ 8use ra_syntax::{
9 ast::{ 9 ast::{
10 self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, ModuleItemOwner, NameOwner, 10 self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, ModuleItemOwner, NameOwner,
11 TypeAscriptionOwner, 11 SlicePatComponents, TypeAscriptionOwner,
12 }, 12 },
13 AstNode, AstPtr, 13 AstNode, AstPtr,
14}; 14};
@@ -596,7 +596,7 @@ where
596 let args = p.args().map(|p| self.collect_pat(p)).collect(); 596 let args = p.args().map(|p| self.collect_pat(p)).collect();
597 Pat::Tuple(args) 597 Pat::Tuple(args)
598 } 598 }
599 ast::Pat::PlaceholderPat(_) => Pat::Wild, 599 ast::Pat::PlaceholderPat(_) | ast::Pat::DotDotPat(_) => Pat::Wild,
600 ast::Pat::RecordPat(p) => { 600 ast::Pat::RecordPat(p) => {
601 let path = p.path().and_then(|path| self.expander.parse_path(path)); 601 let path = p.path().and_then(|path| self.expander.parse_path(path));
602 let record_field_pat_list = 602 let record_field_pat_list =
@@ -621,12 +621,20 @@ where
621 621
622 Pat::Record { path, args: fields } 622 Pat::Record { path, args: fields }
623 } 623 }
624 ast::Pat::SlicePat(p) => {
625 let SlicePatComponents { prefix, slice, suffix } = p.components();
626
627 Pat::Slice {
628 prefix: prefix.into_iter().map(|p| self.collect_pat(p)).collect(),
629 slice: slice.map(|p| self.collect_pat(p)),
630 suffix: suffix.into_iter().map(|p| self.collect_pat(p)).collect(),
631 }
632 }
624 633
625 // FIXME: implement 634 // FIXME: implement
626 ast::Pat::DotDotPat(_) => Pat::Missing,
627 ast::Pat::BoxPat(_) => Pat::Missing, 635 ast::Pat::BoxPat(_) => Pat::Missing,
628 ast::Pat::LiteralPat(_) => Pat::Missing, 636 ast::Pat::LiteralPat(_) => Pat::Missing,
629 ast::Pat::SlicePat(_) | ast::Pat::RangePat(_) => Pat::Missing, 637 ast::Pat::RangePat(_) => Pat::Missing,
630 }; 638 };
631 let ptr = AstPtr::new(&pat); 639 let ptr = AstPtr::new(&pat);
632 self.alloc_pat(pattern, Either::Left(ptr)) 640 self.alloc_pat(pattern, Either::Left(ptr))
diff --git a/crates/ra_hir_def/src/expr.rs b/crates/ra_hir_def/src/expr.rs
index 5a84e08ed..9707c5527 100644
--- a/crates/ra_hir_def/src/expr.rs
+++ b/crates/ra_hir_def/src/expr.rs
@@ -394,7 +394,7 @@ pub enum Pat {
394 }, 394 },
395 Slice { 395 Slice {
396 prefix: Vec<PatId>, 396 prefix: Vec<PatId>,
397 rest: Option<PatId>, 397 slice: Option<PatId>,
398 suffix: Vec<PatId>, 398 suffix: Vec<PatId>,
399 }, 399 },
400 Path(Path), 400 Path(Path),
@@ -425,8 +425,8 @@ impl Pat {
425 args.iter().copied().for_each(f); 425 args.iter().copied().for_each(f);
426 } 426 }
427 Pat::Ref { pat, .. } => f(*pat), 427 Pat::Ref { pat, .. } => f(*pat),
428 Pat::Slice { prefix, rest, suffix } => { 428 Pat::Slice { prefix, slice, suffix } => {
429 let total_iter = prefix.iter().chain(rest.iter()).chain(suffix.iter()); 429 let total_iter = prefix.iter().chain(slice.iter()).chain(suffix.iter());
430 total_iter.copied().for_each(f); 430 total_iter.copied().for_each(f);
431 } 431 }
432 Pat::Record { args, .. } => { 432 Pat::Record { args, .. } => {