diff options
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r-- | crates/hir_def/src/body/lower.rs | 16 | ||||
-rw-r--r-- | crates/hir_def/src/expr.rs | 16 |
2 files changed, 27 insertions, 5 deletions
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs index e1de39d0c..17c72779b 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs | |||
@@ -263,6 +263,10 @@ impl ExprCollector<'_> { | |||
263 | let body = self.collect_block_opt(e.block_expr()); | 263 | let body = self.collect_block_opt(e.block_expr()); |
264 | self.alloc_expr(Expr::Async { body }, syntax_ptr) | 264 | self.alloc_expr(Expr::Async { body }, syntax_ptr) |
265 | } | 265 | } |
266 | ast::Effect::Const(_) => { | ||
267 | let body = self.collect_block_opt(e.block_expr()); | ||
268 | self.alloc_expr(Expr::Const { body }, syntax_ptr) | ||
269 | } | ||
266 | }, | 270 | }, |
267 | ast::Expr::BlockExpr(e) => self.collect_block(e), | 271 | ast::Expr::BlockExpr(e) => self.collect_block(e), |
268 | ast::Expr::LoopExpr(e) => { | 272 | ast::Expr::LoopExpr(e) => { |
@@ -930,10 +934,16 @@ impl ExprCollector<'_> { | |||
930 | let inner = self.collect_pat_opt(boxpat.pat()); | 934 | let inner = self.collect_pat_opt(boxpat.pat()); |
931 | Pat::Box { inner } | 935 | Pat::Box { inner } |
932 | } | 936 | } |
933 | // FIXME: implement | 937 | ast::Pat::ConstBlockPat(const_block_pat) => { |
934 | ast::Pat::RangePat(_) | ast::Pat::MacroPat(_) | ast::Pat::ConstBlockPat(_) => { | 938 | if let Some(expr) = const_block_pat.block_expr() { |
935 | Pat::Missing | 939 | let expr_id = self.collect_block(expr); |
940 | Pat::ConstBlock(expr_id) | ||
941 | } else { | ||
942 | Pat::Missing | ||
943 | } | ||
936 | } | 944 | } |
945 | // FIXME: implement | ||
946 | ast::Pat::RangePat(_) | ast::Pat::MacroPat(_) => Pat::Missing, | ||
937 | }; | 947 | }; |
938 | let ptr = AstPtr::new(&pat); | 948 | let ptr = AstPtr::new(&pat); |
939 | self.alloc_pat(pattern, Either::Left(ptr)) | 949 | self.alloc_pat(pattern, Either::Left(ptr)) |
diff --git a/crates/hir_def/src/expr.rs b/crates/hir_def/src/expr.rs index b080f1553..6a481769d 100644 --- a/crates/hir_def/src/expr.rs +++ b/crates/hir_def/src/expr.rs | |||
@@ -120,6 +120,9 @@ pub enum Expr { | |||
120 | Async { | 120 | Async { |
121 | body: ExprId, | 121 | body: ExprId, |
122 | }, | 122 | }, |
123 | Const { | ||
124 | body: ExprId, | ||
125 | }, | ||
123 | Cast { | 126 | Cast { |
124 | expr: ExprId, | 127 | expr: ExprId, |
125 | type_ref: TypeRef, | 128 | type_ref: TypeRef, |
@@ -259,7 +262,10 @@ impl Expr { | |||
259 | f(*expr); | 262 | f(*expr); |
260 | } | 263 | } |
261 | } | 264 | } |
262 | Expr::TryBlock { body } | Expr::Unsafe { body } | Expr::Async { body } => f(*body), | 265 | Expr::TryBlock { body } |
266 | | Expr::Unsafe { body } | ||
267 | | Expr::Async { body } | ||
268 | | Expr::Const { body } => f(*body), | ||
263 | Expr::Loop { body, .. } => f(*body), | 269 | Expr::Loop { body, .. } => f(*body), |
264 | Expr::While { condition, body, .. } => { | 270 | Expr::While { condition, body, .. } => { |
265 | f(*condition); | 271 | f(*condition); |
@@ -405,12 +411,18 @@ pub enum Pat { | |||
405 | TupleStruct { path: Option<Path>, args: Vec<PatId>, ellipsis: Option<usize> }, | 411 | TupleStruct { path: Option<Path>, args: Vec<PatId>, ellipsis: Option<usize> }, |
406 | Ref { pat: PatId, mutability: Mutability }, | 412 | Ref { pat: PatId, mutability: Mutability }, |
407 | Box { inner: PatId }, | 413 | Box { inner: PatId }, |
414 | ConstBlock(ExprId), | ||
408 | } | 415 | } |
409 | 416 | ||
410 | impl Pat { | 417 | impl Pat { |
411 | pub fn walk_child_pats(&self, mut f: impl FnMut(PatId)) { | 418 | pub fn walk_child_pats(&self, mut f: impl FnMut(PatId)) { |
412 | match self { | 419 | match self { |
413 | Pat::Range { .. } | Pat::Lit(..) | Pat::Path(..) | Pat::Wild | Pat::Missing => {} | 420 | Pat::Range { .. } |
421 | | Pat::Lit(..) | ||
422 | | Pat::Path(..) | ||
423 | | Pat::ConstBlock(..) | ||
424 | | Pat::Wild | ||
425 | | Pat::Missing => {} | ||
414 | Pat::Bind { subpat, .. } => { | 426 | Pat::Bind { subpat, .. } => { |
415 | subpat.iter().copied().for_each(f); | 427 | subpat.iter().copied().for_each(f); |
416 | } | 428 | } |