From 07a704e31cf74deb28a15859b5adfe65ed709bf4 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sat, 12 Sep 2020 21:18:57 +0200 Subject: Implement box pattern inference --- crates/hir_def/src/body/lower.rs | 6 +++++- crates/hir_def/src/expr.rs | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/hir_def/src') 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<'_> { Pat::Missing } + ast::Pat::BoxPat(boxpat) => { + let inner = self.collect_pat_opt(boxpat.pat()); + Pat::Box { inner } + } // FIXME: implement - ast::Pat::BoxPat(_) | ast::Pat::RangePat(_) | ast::Pat::MacroPat(_) => Pat::Missing, + ast::Pat::RangePat(_) | ast::Pat::MacroPat(_) => Pat::Missing, }; let ptr = AstPtr::new(&pat); 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 { Bind { mode: BindingAnnotation, name: Name, subpat: Option }, TupleStruct { path: Option, args: Vec, ellipsis: Option }, Ref { pat: PatId, mutability: Mutability }, + Box { inner: PatId }, } impl Pat { @@ -415,6 +416,7 @@ impl Pat { Pat::Record { args, .. } => { args.iter().map(|f| f.pat).for_each(f); } + Pat::Box { inner } => f(*inner), } } } -- cgit v1.2.3