aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-09-12 20:29:51 +0100
committerGitHub <[email protected]>2020-09-12 20:29:51 +0100
commitab432b36de5d6a370dbaad923f9a475a00fbf220 (patch)
treead9f3491f4a80bfff853b4ce89023cd40f62bbf7 /crates/hir_def
parentc8623461a57e7882ac47b5da13a1a03efa58f603 (diff)
parent07a704e31cf74deb28a15859b5adfe65ed709bf4 (diff)
Merge #5990
5990: Implement box patterns r=jonas-schievink a=jonas-schievink Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def')
-rw-r--r--crates/hir_def/src/body/lower.rs6
-rw-r--r--crates/hir_def/src/expr.rs2
2 files changed, 7 insertions, 1 deletions
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs
index 30ac12a12..9ea3d5291 100644
--- a/crates/hir_def/src/body/lower.rs
+++ b/crates/hir_def/src/body/lower.rs
@@ -835,8 +835,12 @@ impl ExprCollector<'_> {
835 835
836 Pat::Missing 836 Pat::Missing
837 } 837 }
838 ast::Pat::BoxPat(boxpat) => {
839 let inner = self.collect_pat_opt(boxpat.pat());
840 Pat::Box { inner }
841 }
838 // FIXME: implement 842 // FIXME: implement
839 ast::Pat::BoxPat(_) | ast::Pat::RangePat(_) | ast::Pat::MacroPat(_) => Pat::Missing, 843 ast::Pat::RangePat(_) | ast::Pat::MacroPat(_) => Pat::Missing,
840 }; 844 };
841 let ptr = AstPtr::new(&pat); 845 let ptr = AstPtr::new(&pat);
842 self.alloc_pat(pattern, Either::Left(ptr)) 846 self.alloc_pat(pattern, Either::Left(ptr))
diff --git a/crates/hir_def/src/expr.rs b/crates/hir_def/src/expr.rs
index c94b3a36f..dc975d42f 100644
--- a/crates/hir_def/src/expr.rs
+++ b/crates/hir_def/src/expr.rs
@@ -395,6 +395,7 @@ pub enum Pat {
395 Bind { mode: BindingAnnotation, name: Name, subpat: Option<PatId> }, 395 Bind { mode: BindingAnnotation, name: Name, subpat: Option<PatId> },
396 TupleStruct { path: Option<Path>, args: Vec<PatId>, ellipsis: Option<usize> }, 396 TupleStruct { path: Option<Path>, args: Vec<PatId>, ellipsis: Option<usize> },
397 Ref { pat: PatId, mutability: Mutability }, 397 Ref { pat: PatId, mutability: Mutability },
398 Box { inner: PatId },
398} 399}
399 400
400impl Pat { 401impl Pat {
@@ -415,6 +416,7 @@ impl Pat {
415 Pat::Record { args, .. } => { 416 Pat::Record { args, .. } => {
416 args.iter().map(|f| f.pat).for_each(f); 417 args.iter().map(|f| f.pat).for_each(f);
417 } 418 }
419 Pat::Box { inner } => f(*inner),
418 } 420 }
419 } 421 }
420} 422}