use naked_asm! in naked-function tests

This commit is contained in:
Folkert 2024-08-04 16:45:48 +02:00 committed by Folkert de Vries
parent 0aec55504c
commit 47b42bef32
9 changed files with 63 additions and 43 deletions

View File

@ -4,7 +4,7 @@
#![crate_type = "lib"]
#![feature(naked_functions)]
use std::arch::asm;
use std::arch::naked_asm;
// CHECK: Function Attrs: naked
// CHECK-NEXT: define{{.*}}void @naked_empty()
@ -14,7 +14,7 @@
// CHECK-NEXT: {{.+}}:
// CHECK-NEXT: call void asm
// CHECK-NEXT: unreachable
asm!("ret", options(noreturn));
naked_asm!("ret", options(noreturn));
}
// CHECK: Function Attrs: naked
@ -25,5 +25,5 @@
// CHECK-NEXT: {{.+}}:
// CHECK-NEXT: call void asm
// CHECK-NEXT: unreachable
asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
naked_asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
}

View File

@ -3,13 +3,13 @@
#![feature(naked_functions)]
#![crate_type = "lib"]
use std::arch::asm;
use std::arch::naked_asm;
#[naked]
pub extern "C" fn naked(p: char) -> u128 {
//~^ WARN uses type `char`
//~| WARN uses type `u128`
unsafe {
asm!("", options(noreturn));
naked_asm!("", options(noreturn));
}
}

View File

@ -19,7 +19,7 @@
#[naked]
#[inline(always)]
//~^ ERROR [E0736]
pub unsafe extern "C" fn inline_always() {
<<<<<<< HEAD
naked_asm!("");
}

View File

@ -8,7 +8,7 @@
#![no_core]
#[rustc_builtin_macro]
macro_rules! asm {
macro_rules! naked_asm {
() => {};
}
@ -19,12 +19,12 @@ trait Sized {}
#[naked]
#[instruction_set(arm::t32)]
unsafe extern "C" fn test_thumb() {
asm!("bx lr", options(noreturn));
naked_asm!("bx lr", options(noreturn));
}
#[no_mangle]
#[naked]
#[instruction_set(arm::t32)]
unsafe extern "C" fn test_arm() {
asm!("bx lr", options(noreturn));
naked_asm!("bx lr", options(noreturn));
}

View File

@ -6,13 +6,13 @@
#![feature(test)]
#![crate_type = "lib"]
use std::arch::asm;
use std::arch::naked_asm;
#[test]
#[naked]
//~^ ERROR [E0736]
fn test_naked() {
unsafe { asm!("", options(noreturn)) };
unsafe { naked_asm!("", options(noreturn)) };
}
#[should_panic]
@ -20,7 +20,7 @@ fn test_naked() {
#[naked]
//~^ ERROR [E0736]
fn test_naked_should_panic() {
unsafe { asm!("", options(noreturn)) };
unsafe { naked_asm!("", options(noreturn)) };
}
#[ignore]
@ -28,12 +28,12 @@ fn test_naked_should_panic() {
#[naked]
//~^ ERROR [E0736]
fn test_naked_ignore() {
unsafe { asm!("", options(noreturn)) };
unsafe { naked_asm!("", options(noreturn)) };
}
#[bench]
#[naked]
//~^ ERROR [E0736]
fn bench_naked() {
unsafe { asm!("", options(noreturn)) };
unsafe { naked_asm!("", options(noreturn)) };
}

View File

@ -18,49 +18,49 @@ LL | pub extern "C" fn function(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`
error: unused variable: `a`
--> $DIR/naked-functions-unused.rs:26:38
--> $DIR/naked-functions-unused.rs:28:38
|
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_a`
error: unused variable: `b`
--> $DIR/naked-functions-unused.rs:26:48
--> $DIR/naked-functions-unused.rs:28:48
|
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`
error: unused variable: `a`
--> $DIR/naked-functions-unused.rs:32:41
--> $DIR/naked-functions-unused.rs:36:41
|
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_a`
error: unused variable: `b`
--> $DIR/naked-functions-unused.rs:32:51
--> $DIR/naked-functions-unused.rs:36:51
|
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`
error: unused variable: `a`
--> $DIR/naked-functions-unused.rs:40:40
--> $DIR/naked-functions-unused.rs:46:40
|
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_a`
error: unused variable: `b`
--> $DIR/naked-functions-unused.rs:40:50
--> $DIR/naked-functions-unused.rs:46:50
|
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`
error: unused variable: `a`
--> $DIR/naked-functions-unused.rs:46:43
--> $DIR/naked-functions-unused.rs:54:43
|
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_a`
error: unused variable: `b`
--> $DIR/naked-functions-unused.rs:46:53
--> $DIR/naked-functions-unused.rs:54:53
|
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`

View File

@ -17,7 +17,9 @@ pub mod normal {
pub extern "C" fn function(a: usize, b: usize) -> usize {
//~^ ERROR unused variable: `a`
//~| ERROR unused variable: `b`
unsafe { asm!("", options(noreturn)); }
unsafe {
asm!("", options(noreturn));
}
}
pub struct Normal;
@ -26,13 +28,17 @@ impl Normal {
pub extern "C" fn associated(a: usize, b: usize) -> usize {
//~^ ERROR unused variable: `a`
//~| ERROR unused variable: `b`
unsafe { asm!("", options(noreturn)); }
unsafe {
asm!("", options(noreturn));
}
}
pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
//~^ ERROR unused variable: `a`
//~| ERROR unused variable: `b`
unsafe { asm!("", options(noreturn)); }
unsafe {
asm!("", options(noreturn));
}
}
}
@ -40,23 +46,29 @@ impl super::Trait for Normal {
extern "C" fn trait_associated(a: usize, b: usize) -> usize {
//~^ ERROR unused variable: `a`
//~| ERROR unused variable: `b`
unsafe { asm!("", options(noreturn)); }
unsafe {
asm!("", options(noreturn));
}
}
extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
//~^ ERROR unused variable: `a`
//~| ERROR unused variable: `b`
unsafe { asm!("", options(noreturn)); }
unsafe {
asm!("", options(noreturn));
}
}
}
}
pub mod naked {
use std::arch::asm;
use std::arch::naked_asm;
#[naked]
pub extern "C" fn function(a: usize, b: usize) -> usize {
unsafe { asm!("", options(noreturn)); }
unsafe {
naked_asm!("", options(noreturn));
}
}
pub struct Naked;
@ -64,24 +76,32 @@ pub extern "C" fn function(a: usize, b: usize) -> usize {
impl Naked {
#[naked]
pub extern "C" fn associated(a: usize, b: usize) -> usize {
unsafe { asm!("", options(noreturn)); }
unsafe {
naked_asm!("", options(noreturn));
}
}
#[naked]
pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
unsafe { asm!("", options(noreturn)); }
unsafe {
naked_asm!("", options(noreturn));
}
}
}
impl super::Trait for Naked {
#[naked]
extern "C" fn trait_associated(a: usize, b: usize) -> usize {
unsafe { asm!("", options(noreturn)); }
unsafe {
naked_asm!("", options(noreturn));
}
}
#[naked]
extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
unsafe { asm!("", options(noreturn)); }
unsafe {
naked_asm!("", options(noreturn));
}
}
}
}

View File

@ -18,49 +18,49 @@ LL | pub extern "C" fn function(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`
error: unused variable: `a`
--> $DIR/naked-functions-unused.rs:26:38
--> $DIR/naked-functions-unused.rs:28:38
|
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_a`
error: unused variable: `b`
--> $DIR/naked-functions-unused.rs:26:48
--> $DIR/naked-functions-unused.rs:28:48
|
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`
error: unused variable: `a`
--> $DIR/naked-functions-unused.rs:32:41
--> $DIR/naked-functions-unused.rs:36:41
|
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_a`
error: unused variable: `b`
--> $DIR/naked-functions-unused.rs:32:51
--> $DIR/naked-functions-unused.rs:36:51
|
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`
error: unused variable: `a`
--> $DIR/naked-functions-unused.rs:40:40
--> $DIR/naked-functions-unused.rs:46:40
|
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_a`
error: unused variable: `b`
--> $DIR/naked-functions-unused.rs:40:50
--> $DIR/naked-functions-unused.rs:46:50
|
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`
error: unused variable: `a`
--> $DIR/naked-functions-unused.rs:46:43
--> $DIR/naked-functions-unused.rs:54:43
|
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_a`
error: unused variable: `b`
--> $DIR/naked-functions-unused.rs:46:53
--> $DIR/naked-functions-unused.rs:54:53
|
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
| ^ help: if this is intentional, prefix it with an underscore: `_b`

View File

@ -5,14 +5,14 @@
#[naked]
//~^ the `#[naked]` attribute is an experimental feature
extern "C" fn naked() {
asm!("", options(noreturn))
naked_asm!("", options(noreturn))
//~^ ERROR: requires unsafe
}
#[naked]
//~^ the `#[naked]` attribute is an experimental feature
extern "C" fn naked_2() -> isize {
asm!("", options(noreturn))
naked_asm!("", options(noreturn))
//~^ ERROR: requires unsafe
}