From cc09cb0dfa4f04eb569f55df047b0f2e3febe50a Mon Sep 17 00:00:00 2001 From: Folkert Date: Sun, 4 Aug 2024 16:42:37 +0200 Subject: [PATCH 1/2] implement `naked_asm` macro --- core/src/arch.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/src/arch.rs b/core/src/arch.rs index 4945c045bc635..f1a0739128cdb 100644 --- a/core/src/arch.rs +++ b/core/src/arch.rs @@ -77,3 +77,17 @@ pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))?) { /* compiler built-in */ } + +/// Inline assembly used in combination with `#[naked]` functions. +/// +/// Refer to [Rust By Example] for a usage guide and the [reference] for +/// detailed information about the syntax and available options. +/// +/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html +/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html +#[unstable(feature = "naked_functions", issue = "90957")] +#[rustc_builtin_macro] +#[cfg(not(bootstrap))] +pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) { + /* compiler built-in */ +} From 4ca50c3c94aa28ddeb31de14007c418b506127ba Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Thu, 5 Sep 2024 13:45:26 +0200 Subject: [PATCH 2/2] disallow `asm!` in `#[naked]` functions also disallow the `noreturn` option, and infer `naked_asm!` as `!` --- core/src/arch.rs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/core/src/arch.rs b/core/src/arch.rs index f1a0739128cdb..4945c045bc635 100644 --- a/core/src/arch.rs +++ b/core/src/arch.rs @@ -77,17 +77,3 @@ pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))?) { /* compiler built-in */ } - -/// Inline assembly used in combination with `#[naked]` functions. -/// -/// Refer to [Rust By Example] for a usage guide and the [reference] for -/// detailed information about the syntax and available options. -/// -/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html -/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html -#[unstable(feature = "naked_functions", issue = "90957")] -#[rustc_builtin_macro] -#[cfg(not(bootstrap))] -pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) { - /* compiler built-in */ -}