aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-05-24 21:24:36 +0100
committerPaul Daniel Faria <[email protected]>2020-06-27 15:10:26 +0100
commit278cbf12cd0f76fc191d5ce7f130e6245596a578 (patch)
tree7c00307fbef82b45cbd0072a45819ea962bf8900 /crates/ra_hir_def/src
parent3df0f9ce7e6eea48b67dae8b26e83aa7bd36ff24 (diff)
Track unsafe blocks, don't trigger missing unsafe diagnostic when unsafe exprs within unsafe block
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r--crates/ra_hir_def/src/body/lower.rs6
-rw-r--r--crates/ra_hir_def/src/expr.rs5
2 files changed, 9 insertions, 2 deletions
diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs
index a7e2e0982..174bbf9f4 100644
--- a/crates/ra_hir_def/src/body/lower.rs
+++ b/crates/ra_hir_def/src/body/lower.rs
@@ -218,8 +218,12 @@ impl ExprCollector<'_> {
218 let body = self.collect_block_opt(e.block_expr()); 218 let body = self.collect_block_opt(e.block_expr());
219 self.alloc_expr(Expr::TryBlock { body }, syntax_ptr) 219 self.alloc_expr(Expr::TryBlock { body }, syntax_ptr)
220 } 220 }
221 ast::Effect::Unsafe(_) => {
222 let body = self.collect_block_opt(e.block_expr());
223 self.alloc_expr(Expr::UnsafeBlock { body }, syntax_ptr)
224 }
221 // FIXME: we need to record these effects somewhere... 225 // FIXME: we need to record these effects somewhere...
222 ast::Effect::Async(_) | ast::Effect::Label(_) | ast::Effect::Unsafe(_) => { 226 ast::Effect::Async(_) | ast::Effect::Label(_) => {
223 self.collect_block_opt(e.block_expr()) 227 self.collect_block_opt(e.block_expr())
224 } 228 }
225 }, 229 },
diff --git a/crates/ra_hir_def/src/expr.rs b/crates/ra_hir_def/src/expr.rs
index ca49b26d1..f5e3e74fb 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 UnsafeBlock {
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::UnsafeBlock { 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);