rust/tests/ui/asm/naked-asm-outside-naked-fn.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
682 B
Rust
Raw Normal View History

//@ edition: 2021
//@ needs-asm-support
//@ ignore-nvptx64
//@ ignore-spirv
#![crate_type = "lib"]
use std::arch::naked_asm;
fn main() {
test1();
}
2025-03-29 17:30:11 +01:00
#[unsafe(naked)]
extern "C" fn test1() {
2025-03-29 17:30:11 +01:00
naked_asm!("")
}
extern "C" fn test2() {
2025-03-29 17:30:11 +01:00
naked_asm!("")
//~^ ERROR the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]`
}
extern "C" fn test3() {
2025-03-29 17:30:11 +01:00
(|| naked_asm!(""))()
//~^ ERROR the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]`
}
fn test4() {
async move {
2025-03-29 17:30:11 +01:00
naked_asm!("");
//~^ ERROR the `naked_asm!` macro can only be used in functions marked with `#[unsafe(naked)]`
};
}