rust/tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs
2024-09-14 18:07:06 +02:00

19 lines
557 B
Rust

const unsafe extern "C" fn foo() -> usize {
5
}
const unsafe extern "C-unwind" fn bar() -> usize {
5
}
fn main() {
let a: [u8; foo()];
//~^ call to unsafe function `foo` is unsafe and requires unsafe function or block
foo();
//~^ ERROR call to unsafe function `foo` is unsafe and requires unsafe function or block
let b: [u8; bar()];
//~^ call to unsafe function `bar` is unsafe and requires unsafe function or block
bar();
//~^ ERROR call to unsafe function `bar` is unsafe and requires unsafe function or block
}