Skip to content

Commit 95c4cb9

Browse files
committed
Handle new hir block kinds in scope calculations
1 parent b827648 commit 95c4cb9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

crates/hir-def/src/body/scope.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,16 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope
194194
scopes.set_scope(expr, scope);
195195
compute_block_scopes(statements, *tail, body, scopes, &mut scope);
196196
}
197+
Expr::Unsafe { id, statements, tail }
198+
| Expr::Async { id, statements, tail }
199+
| Expr::Const { id, statements, tail }
200+
| Expr::TryBlock { id, statements, tail } => {
201+
let mut scope = scopes.new_block_scope(*scope, *id, None);
202+
// Overwrite the old scope for the block expr, so that every block scope can be found
203+
// via the block itself (important for blocks that only contain items, no expressions).
204+
scopes.set_scope(expr, scope);
205+
compute_block_scopes(statements, *tail, body, scopes, &mut scope);
206+
}
197207
Expr::For { iterable, pat, body: body_expr, label } => {
198208
compute_expr_scopes(*iterable, body, scopes, scope);
199209
let mut scope = scopes.new_labeled_scope(*scope, make_label(label));

crates/hir-ty/src/diagnostics/unsafe_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn walk_unsafe(
9595
}
9696
}
9797
Expr::Unsafe { .. } => {
98-
expr.walk_child_exprs(|child| {
98+
return expr.walk_child_exprs(|child| {
9999
walk_unsafe(db, infer, def, body, child, true, unsafe_expr_cb);
100100
});
101101
}

0 commit comments

Comments
 (0)