fix: Walk const block expressions for unsafety checking

This commit is contained in:
Lukas Wirth 2025-04-10 15:56:31 +02:00
parent 4fdc2507c6
commit 8df812f14d
3 changed files with 21 additions and 0 deletions

View file

@ -874,6 +874,19 @@ fn baz() {
fn f(it: unsafe fn()){
it();
// ^^^^ 💡 error: call to unsafe function is unsafe and requires an unsafe function or block
}
"#,
);
}
#[test]
fn unsafe_call_in_const_expr() {
check_diagnostics(
r#"
unsafe fn f() {}
fn main() {
const { f(); };
// ^^^ 💡 error: call to unsafe function is unsafe and requires an unsafe function or block
}
"#,
);