Skip to content

Commit 381b6b5

Browse files
committed
fix: Walk const block expressions for unsafety checking
1 parent 4fdc250 commit 381b6b5

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

crates/hir-def/src/expr_store.rs

+7
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ impl ExpressionStore {
282282
}
283283
}
284284

285+
/// Walks the immediate children expressions and calls `f` for each child expression.
286+
///
287+
/// Note that this does not walk const blocks.
285288
pub fn walk_child_exprs(&self, expr_id: ExprId, mut f: impl FnMut(ExprId)) {
286289
let expr = &self[expr_id];
287290
match expr {
@@ -415,6 +418,10 @@ impl ExpressionStore {
415418
}
416419
}
417420

421+
/// Walks the immediate children expressions and calls `f` for each child expression but does
422+
/// not walk expressions within patterns.
423+
///
424+
/// Note that this does not walk const blocks.
418425
pub fn walk_child_exprs_without_pats(&self, expr_id: ExprId, mut f: impl FnMut(ExprId)) {
419426
let expr = &self[expr_id];
420427
match expr {

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

+1
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ impl<'a> UnsafeVisitor<'a> {
348348
Expr::Closure { args, .. } => {
349349
self.walk_pats_top(args.iter().copied(), current);
350350
}
351+
Expr::Const(e) => self.walk_expr(*e),
351352
_ => {}
352353
}
353354

0 commit comments

Comments
 (0)