1
Fork 0
rust/tests/ui/ffi-attrs/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

18 lines
471 B
Rust

#![feature(ffi_const)]
#![crate_type = "lib"]
#[unsafe(ffi_const)] //~ ERROR `#[ffi_const]` may only be used on foreign functions
pub fn foo() {}
#[unsafe(ffi_const)] //~ ERROR `#[ffi_const]` may only be used on foreign functions
macro_rules! bar {
() => {};
}
extern "C" {
#[unsafe(ffi_const)] //~ ERROR `#[ffi_const]` may only be used on foreign functions
static INT: i32;
#[ffi_const] //~ ERROR unsafe attribute used without unsafe
fn bar();
}