rust/tests/codegen/cffi/ffi-const.rs
Folkert de Vries f472cc8cd4
error on unsafe attributes in pre-2024 editions
the `no_mangle`, `link_section` and `export_name` attributes are exceptions, and can still be used without an unsafe in earlier editions
2025-04-13 01:22:59 +02:00

15 lines
340 B
Rust

//@ compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]
#![feature(ffi_const)]
pub fn bar() {
unsafe { foo() }
}
extern "C" {
// CHECK-LABEL: declare{{.*}}void @foo()
// CHECK-SAME: [[ATTRS:#[0-9]+]]
// CHECK-DAG: attributes [[ATTRS]] = { {{.*}}memory(none){{.*}} }
#[unsafe(ffi_const)]
pub fn foo();
}