diff options
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r-- | crates/ra_hir_def/src/body/lower.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir_def/src/expr.rs | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index a7e2e0982..c6bc85e2f 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs | |||
@@ -176,6 +176,7 @@ impl ExprCollector<'_> { | |||
176 | if !self.expander.is_cfg_enabled(&expr) { | 176 | if !self.expander.is_cfg_enabled(&expr) { |
177 | return self.missing_expr(); | 177 | return self.missing_expr(); |
178 | } | 178 | } |
179 | |||
179 | match expr { | 180 | match expr { |
180 | ast::Expr::IfExpr(e) => { | 181 | ast::Expr::IfExpr(e) => { |
181 | let then_branch = self.collect_block_opt(e.then_branch()); | 182 | let then_branch = self.collect_block_opt(e.then_branch()); |
@@ -218,8 +219,12 @@ impl ExprCollector<'_> { | |||
218 | let body = self.collect_block_opt(e.block_expr()); | 219 | let body = self.collect_block_opt(e.block_expr()); |
219 | self.alloc_expr(Expr::TryBlock { body }, syntax_ptr) | 220 | self.alloc_expr(Expr::TryBlock { body }, syntax_ptr) |
220 | } | 221 | } |
222 | ast::Effect::Unsafe(_) => { | ||
223 | let body = self.collect_block_opt(e.block_expr()); | ||
224 | self.alloc_expr(Expr::Unsafe { body }, syntax_ptr) | ||
225 | } | ||
221 | // FIXME: we need to record these effects somewhere... | 226 | // FIXME: we need to record these effects somewhere... |
222 | ast::Effect::Async(_) | ast::Effect::Label(_) | ast::Effect::Unsafe(_) => { | 227 | ast::Effect::Async(_) | ast::Effect::Label(_) => { |
223 | self.collect_block_opt(e.block_expr()) | 228 | self.collect_block_opt(e.block_expr()) |
224 | } | 229 | } |
225 | }, | 230 | }, |
@@ -445,7 +450,6 @@ impl ExprCollector<'_> { | |||
445 | Mutability::from_mutable(e.mut_token().is_some()) | 450 | Mutability::from_mutable(e.mut_token().is_some()) |
446 | }; | 451 | }; |
447 | let rawness = Rawness::from_raw(raw_tok); | 452 | let rawness = Rawness::from_raw(raw_tok); |
448 | |||
449 | self.alloc_expr(Expr::Ref { expr, rawness, mutability }, syntax_ptr) | 453 | self.alloc_expr(Expr::Ref { expr, rawness, mutability }, syntax_ptr) |
450 | } | 454 | } |
451 | ast::Expr::PrefixExpr(e) => { | 455 | ast::Expr::PrefixExpr(e) => { |
diff --git a/crates/ra_hir_def/src/expr.rs b/crates/ra_hir_def/src/expr.rs index ca49b26d1..e41cfc16b 100644 --- a/crates/ra_hir_def/src/expr.rs +++ b/crates/ra_hir_def/src/expr.rs | |||
@@ -150,6 +150,9 @@ pub enum Expr { | |||
150 | Tuple { | 150 | Tuple { |
151 | exprs: Vec<ExprId>, | 151 | exprs: Vec<ExprId>, |
152 | }, | 152 | }, |
153 | Unsafe { | ||
154 | body: ExprId, | ||
155 | }, | ||
153 | Array(Array), | 156 | Array(Array), |
154 | Literal(Literal), | 157 | Literal(Literal), |
155 | } | 158 | } |
@@ -247,7 +250,7 @@ impl Expr { | |||
247 | f(*expr); | 250 | f(*expr); |
248 | } | 251 | } |
249 | } | 252 | } |
250 | Expr::TryBlock { body } => f(*body), | 253 | Expr::TryBlock { body } | Expr::Unsafe { body } => f(*body), |
251 | Expr::Loop { body, .. } => f(*body), | 254 | Expr::Loop { body, .. } => f(*body), |
252 | Expr::While { condition, body, .. } => { | 255 | Expr::While { condition, body, .. } => { |
253 | f(*condition); | 256 | f(*condition); |