Skip to content

Commit b927a7c

Browse files
authored
Merge pull request #19563 from Veykril/push-xwlnkpmkqnwp
fix: Fix invalid signature bitflags
2 parents 9e0af2b + 8df812f commit b927a7c

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-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

crates/ide-diagnostics/src/handlers/missing_unsafe.rs

+13
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,19 @@ fn baz() {
874874
fn f(it: unsafe fn()){
875875
it();
876876
// ^^^^ 💡 error: call to unsafe function is unsafe and requires an unsafe function or block
877+
}
878+
"#,
879+
);
880+
}
881+
882+
#[test]
883+
fn unsafe_call_in_const_expr() {
884+
check_diagnostics(
885+
r#"
886+
unsafe fn f() {}
887+
fn main() {
888+
const { f(); };
889+
// ^^^ 💡 error: call to unsafe function is unsafe and requires an unsafe function or block
877890
}
878891
"#,
879892
);

0 commit comments

Comments
 (0)