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 978c3a324..1b98504bb 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs | |||
@@ -246,6 +246,10 @@ impl ExprCollector<'_> { | |||
246 | let body = self.collect_block_opt(e.block_expr()); | 246 | let body = self.collect_block_opt(e.block_expr()); |
247 | self.alloc_expr(Expr::Async { body }, syntax_ptr) | 247 | self.alloc_expr(Expr::Async { body }, syntax_ptr) |
248 | } | 248 | } |
249 | ast::Effect::Const(_) => { | ||
250 | let body = self.collect_block_opt(e.block_expr()); | ||
251 | self.alloc_expr(Expr::Const { body }, syntax_ptr) | ||
252 | } | ||
249 | }, | 253 | }, |
250 | ast::Expr::BlockExpr(e) => self.collect_block(e), | 254 | ast::Expr::BlockExpr(e) => self.collect_block(e), |
251 | ast::Expr::LoopExpr(e) => { | 255 | ast::Expr::LoopExpr(e) => { |
@@ -932,10 +936,16 @@ impl ExprCollector<'_> { | |||
932 | let inner = self.collect_pat_opt(boxpat.pat()); | 936 | let inner = self.collect_pat_opt(boxpat.pat()); |
933 | Pat::Box { inner } | 937 | Pat::Box { inner } |
934 | } | 938 | } |
935 | // FIXME: implement | 939 | ast::Pat::ConstBlockPat(const_block_pat) => { |
936 | ast::Pat::RangePat(_) | ast::Pat::MacroPat(_) | ast::Pat::ConstBlockPat(_) => { | 940 | if let Some(expr) = const_block_pat.block_expr() { |
937 | Pat::Missing | 941 | let expr_id = self.collect_block(expr); |
942 | Pat::ConstBlock(expr_id) | ||
943 | } else { | ||
944 | Pat::Missing | ||
945 | } | ||
938 | } | 946 | } |
947 | // FIXME: implement | ||
948 | ast::Pat::RangePat(_) | ast::Pat::MacroPat(_) => Pat::Missing, | ||
939 | }; | 949 | }; |
940 | let ptr = AstPtr::new(&pat); | 950 | let ptr = AstPtr::new(&pat); |
941 | self.alloc_pat(pattern, Either::Left(ptr)) | 951 | self.alloc_pat(pattern, Either::Left(ptr)) |
diff --git a/crates/hir_def/src/expr.rs b/crates/hir_def/src/expr.rs index e5d740a36..3bba30397 100644 --- a/crates/hir_def/src/expr.rs +++ b/crates/hir_def/src/expr.rs | |||
@@ -114,6 +114,9 @@ pub enum Expr { | |||
114 | Async { | 114 | Async { |
115 | body: ExprId, | 115 | body: ExprId, |
116 | }, | 116 | }, |
117 | Const { | ||
118 | body: ExprId, | ||
119 | }, | ||
117 | Cast { | 120 | Cast { |
118 | expr: ExprId, | 121 | expr: ExprId, |
119 | type_ref: TypeRef, | 122 | type_ref: TypeRef, |
@@ -253,7 +256,10 @@ impl Expr { | |||
253 | f(*expr); | 256 | f(*expr); |
254 | } | 257 | } |
255 | } | 258 | } |
256 | Expr::TryBlock { body } | Expr::Unsafe { body } | Expr::Async { body } => f(*body), | 259 | Expr::TryBlock { body } |
260 | | Expr::Unsafe { body } | ||
261 | | Expr::Async { body } | ||
262 | | Expr::Const { body } => f(*body), | ||
257 | Expr::Loop { body, .. } => f(*body), | 263 | Expr::Loop { body, .. } => f(*body), |
258 | Expr::While { condition, body, .. } => { | 264 | Expr::While { condition, body, .. } => { |
259 | f(*condition); | 265 | f(*condition); |
@@ -399,12 +405,18 @@ pub enum Pat { | |||
399 | TupleStruct { path: Option<Path>, args: Vec<PatId>, ellipsis: Option<usize> }, | 405 | TupleStruct { path: Option<Path>, args: Vec<PatId>, ellipsis: Option<usize> }, |
400 | Ref { pat: PatId, mutability: Mutability }, | 406 | Ref { pat: PatId, mutability: Mutability }, |
401 | Box { inner: PatId }, | 407 | Box { inner: PatId }, |
408 | ConstBlock(ExprId), | ||
402 | } | 409 | } |
403 | 410 | ||
404 | impl Pat { | 411 | impl Pat { |
405 | pub fn walk_child_pats(&self, mut f: impl FnMut(PatId)) { | 412 | pub fn walk_child_pats(&self, mut f: impl FnMut(PatId)) { |
406 | match self { | 413 | match self { |
407 | Pat::Range { .. } | Pat::Lit(..) | Pat::Path(..) | Pat::Wild | Pat::Missing => {} | 414 | Pat::Range { .. } |
415 | | Pat::Lit(..) | ||
416 | | Pat::Path(..) | ||
417 | | Pat::ConstBlock(..) | ||
418 | | Pat::Wild | ||
419 | | Pat::Missing => {} | ||
408 | Pat::Bind { subpat, .. } => { | 420 | Pat::Bind { subpat, .. } => { |
409 | subpat.iter().copied().for_each(f); | 421 | subpat.iter().copied().for_each(f); |
410 | } | 422 | } |