Skip to content

Commit

Permalink
more asm! -> naked_asm! in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Oct 6, 2024
1 parent 562ec5a commit bc0a954
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 23 deletions.
4 changes: 2 additions & 2 deletions tests/assembly/aarch64-naked-fn-no-bti-prolog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#![crate_type = "lib"]
#![feature(naked_functions)]
use std::arch::asm;
use std::arch::naked_asm;

// The problem at hand: Rust has adopted a fairly strict meaning for "naked functions",
// meaning "no prologue whatsoever, no, really, not one instruction."
Expand All @@ -17,5 +17,5 @@ use std::arch::asm;
pub unsafe extern "C" fn _hlt() -> ! {
// CHECK-NOT: hint #34
// CHECK: hlt #0x1
asm!("hlt #1", options(noreturn))
naked_asm!("hlt #1")
}
4 changes: 2 additions & 2 deletions tests/assembly/x86_64-naked-fn-no-cet-prolog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#![crate_type = "lib"]
#![feature(naked_functions)]
use std::arch::asm;
use std::arch::naked_asm;

// The problem at hand: Rust has adopted a fairly strict meaning for "naked functions",
// meaning "no prologue whatsoever, no, really, not one instruction."
Expand All @@ -17,7 +17,7 @@ use std::arch::asm;
pub unsafe extern "sysv64" fn will_halt() -> ! {
// CHECK-NOT: endbr{{32|64}}
// CHECK: hlt
asm!("hlt", options(noreturn))
naked_asm!("hlt")
}

// what about aarch64?
Expand Down
3 changes: 1 addition & 2 deletions tests/codegen/cffi/c-variadic-naked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
pub unsafe extern "C" fn c_variadic(_: usize, _: ...) {
// CHECK-NOT: va_start
// CHECK-NOT: alloca
core::arch::asm! {
core::arch::naked_asm! {
"ret",
options(noreturn),
}
}
4 changes: 2 additions & 2 deletions tests/crashes/124375.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
//@ only-x86_64
#![crate_type = "lib"]
#![feature(naked_functions)]
use std::arch::asm;
use std::arch::naked_asm;

#[naked]
pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
naked_asm!("lea rax, [rdi + rsi]", "ret");
}
12 changes: 6 additions & 6 deletions tests/run-make/naked-symbol-visibility/a_rust_dylib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![feature(naked_functions, asm_const, linkage)]
#![crate_type = "dylib"]

use std::arch::asm;
use std::arch::naked_asm;

pub trait TraitWithConst {
const COUNT: u32;
Expand All @@ -28,7 +28,7 @@ extern "C" fn private_vanilla() -> u32 {

#[naked]
extern "C" fn private_naked() -> u32 {
unsafe { asm!("mov rax, 42", "ret", options(noreturn)) }
unsafe { naked_asm!("mov rax, 42", "ret") }
}

#[no_mangle]
Expand All @@ -39,7 +39,7 @@ pub extern "C" fn public_vanilla() -> u32 {
#[naked]
#[no_mangle]
pub extern "C" fn public_naked() -> u32 {
unsafe { asm!("mov rax, 42", "ret", options(noreturn)) }
unsafe { naked_asm!("mov rax, 42", "ret") }
}

pub extern "C" fn public_vanilla_generic<T: TraitWithConst>() -> u32 {
Expand All @@ -48,7 +48,7 @@ pub extern "C" fn public_vanilla_generic<T: TraitWithConst>() -> u32 {

#[naked]
pub extern "C" fn public_naked_generic<T: TraitWithConst>() -> u32 {
unsafe { asm!("mov rax, {}", "ret", const T::COUNT, options(noreturn)) }
unsafe { naked_asm!("mov rax, {}", "ret", const T::COUNT) }
}

#[linkage = "external"]
Expand All @@ -59,7 +59,7 @@ extern "C" fn vanilla_external_linkage() -> u32 {
#[naked]
#[linkage = "external"]
extern "C" fn naked_external_linkage() -> u32 {
unsafe { asm!("mov rax, 42", "ret", options(noreturn)) }
unsafe { naked_asm!("mov rax, 42", "ret") }
}

#[cfg(not(windows))]
Expand All @@ -72,7 +72,7 @@ extern "C" fn vanilla_weak_linkage() -> u32 {
#[cfg(not(windows))]
#[linkage = "weak"]
extern "C" fn naked_weak_linkage() -> u32 {
unsafe { asm!("mov rax, 42", "ret", options(noreturn)) }
unsafe { naked_asm!("mov rax, 42", "ret", options(noreturn)) }
}

// functions that are declared in an `extern "C"` block are currently not exported
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/feature-gates/feature-gate-naked_functions.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error[E0658]: use of unstable library feature 'naked_functions'
--> $DIR/feature-gate-naked_functions.rs:9:5
|
LL | naked_asm!("", options(noreturn))
LL | naked_asm!("")
| ^^^^^^^^^
|
= note: see issue #90957 <https://github.com/rust-lang/rust/issues/90957> for more information
Expand All @@ -11,7 +11,7 @@ LL | naked_asm!("", options(noreturn))
error[E0658]: use of unstable library feature 'naked_functions'
--> $DIR/feature-gate-naked_functions.rs:17:5
|
LL | naked_asm!("", options(noreturn))
LL | naked_asm!("")
| ^^^^^^^^^
|
= note: see issue #90957 <https://github.com/rust-lang/rust/issues/90957> for more information
Expand Down Expand Up @@ -51,16 +51,16 @@ LL | use std::arch::naked_asm;
error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/feature-gate-naked_functions.rs:9:5
|
LL | naked_asm!("", options(noreturn))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of inline assembly
LL | naked_asm!("")
| ^^^^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior

error[E0133]: use of inline assembly is unsafe and requires unsafe function or block
--> $DIR/feature-gate-naked_functions.rs:17:5
|
LL | naked_asm!("", options(noreturn))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of inline assembly
LL | naked_asm!("")
| ^^^^^^^^^^^^^^ use of inline assembly
|
= note: inline assembly is entirely unchecked and can cause undefined behavior

Expand Down
6 changes: 3 additions & 3 deletions tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//@ needs-asm-support
#![feature(naked_functions)]

use std::arch::asm;
use std::arch::naked_asm;

#[track_caller] //~ ERROR [E0736]
//~^ ERROR `#[track_caller]` requires Rust ABI
#[naked]
extern "C" fn f() {
unsafe {
asm!("", options(noreturn));
naked_asm!("");
}
}

Expand All @@ -20,7 +20,7 @@ impl S {
#[naked]
extern "C" fn g() {
unsafe {
asm!("", options(noreturn));
naked_asm!("");
}
}
}
Expand Down

0 comments on commit bc0a954

Please sign in to comment.