use naked_asm!
in naked-function tests
This commit is contained in:
parent
0aec55504c
commit
47b42bef32
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
#![feature(naked_functions)]
|
#![feature(naked_functions)]
|
||||||
use std::arch::asm;
|
use std::arch::naked_asm;
|
||||||
|
|
||||||
// CHECK: Function Attrs: naked
|
// CHECK: Function Attrs: naked
|
||||||
// CHECK-NEXT: define{{.*}}void @naked_empty()
|
// CHECK-NEXT: define{{.*}}void @naked_empty()
|
||||||
@ -14,7 +14,7 @@
|
|||||||
// CHECK-NEXT: {{.+}}:
|
// CHECK-NEXT: {{.+}}:
|
||||||
// CHECK-NEXT: call void asm
|
// CHECK-NEXT: call void asm
|
||||||
// CHECK-NEXT: unreachable
|
// CHECK-NEXT: unreachable
|
||||||
asm!("ret", options(noreturn));
|
naked_asm!("ret", options(noreturn));
|
||||||
}
|
}
|
||||||
|
|
||||||
// CHECK: Function Attrs: naked
|
// CHECK: Function Attrs: naked
|
||||||
@ -25,5 +25,5 @@
|
|||||||
// CHECK-NEXT: {{.+}}:
|
// CHECK-NEXT: {{.+}}:
|
||||||
// CHECK-NEXT: call void asm
|
// CHECK-NEXT: call void asm
|
||||||
// CHECK-NEXT: unreachable
|
// CHECK-NEXT: unreachable
|
||||||
asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
|
naked_asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
#![feature(naked_functions)]
|
#![feature(naked_functions)]
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
use std::arch::asm;
|
use std::arch::naked_asm;
|
||||||
|
|
||||||
#[naked]
|
#[naked]
|
||||||
pub extern "C" fn naked(p: char) -> u128 {
|
pub extern "C" fn naked(p: char) -> u128 {
|
||||||
//~^ WARN uses type `char`
|
//~^ WARN uses type `char`
|
||||||
//~| WARN uses type `u128`
|
//~| WARN uses type `u128`
|
||||||
unsafe {
|
unsafe {
|
||||||
asm!("", options(noreturn));
|
naked_asm!("", options(noreturn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#[naked]
|
#[naked]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
//~^ ERROR [E0736]
|
//~^ ERROR [E0736]
|
||||||
pub unsafe extern "C" fn inline_always() {
|
<<<<<<< HEAD
|
||||||
naked_asm!("");
|
naked_asm!("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#![no_core]
|
#![no_core]
|
||||||
|
|
||||||
#[rustc_builtin_macro]
|
#[rustc_builtin_macro]
|
||||||
macro_rules! asm {
|
macro_rules! naked_asm {
|
||||||
() => {};
|
() => {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,12 +19,12 @@ trait Sized {}
|
|||||||
#[naked]
|
#[naked]
|
||||||
#[instruction_set(arm::t32)]
|
#[instruction_set(arm::t32)]
|
||||||
unsafe extern "C" fn test_thumb() {
|
unsafe extern "C" fn test_thumb() {
|
||||||
asm!("bx lr", options(noreturn));
|
naked_asm!("bx lr", options(noreturn));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[naked]
|
#[naked]
|
||||||
#[instruction_set(arm::t32)]
|
#[instruction_set(arm::t32)]
|
||||||
unsafe extern "C" fn test_arm() {
|
unsafe extern "C" fn test_arm() {
|
||||||
asm!("bx lr", options(noreturn));
|
naked_asm!("bx lr", options(noreturn));
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
use std::arch::asm;
|
use std::arch::naked_asm;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[naked]
|
#[naked]
|
||||||
//~^ ERROR [E0736]
|
//~^ ERROR [E0736]
|
||||||
fn test_naked() {
|
fn test_naked() {
|
||||||
unsafe { asm!("", options(noreturn)) };
|
unsafe { naked_asm!("", options(noreturn)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
@ -20,7 +20,7 @@ fn test_naked() {
|
|||||||
#[naked]
|
#[naked]
|
||||||
//~^ ERROR [E0736]
|
//~^ ERROR [E0736]
|
||||||
fn test_naked_should_panic() {
|
fn test_naked_should_panic() {
|
||||||
unsafe { asm!("", options(noreturn)) };
|
unsafe { naked_asm!("", options(noreturn)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ignore]
|
#[ignore]
|
||||||
@ -28,12 +28,12 @@ fn test_naked_should_panic() {
|
|||||||
#[naked]
|
#[naked]
|
||||||
//~^ ERROR [E0736]
|
//~^ ERROR [E0736]
|
||||||
fn test_naked_ignore() {
|
fn test_naked_ignore() {
|
||||||
unsafe { asm!("", options(noreturn)) };
|
unsafe { naked_asm!("", options(noreturn)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
#[bench]
|
||||||
#[naked]
|
#[naked]
|
||||||
//~^ ERROR [E0736]
|
//~^ ERROR [E0736]
|
||||||
fn bench_naked() {
|
fn bench_naked() {
|
||||||
unsafe { asm!("", options(noreturn)) };
|
unsafe { naked_asm!("", options(noreturn)) };
|
||||||
}
|
}
|
||||||
|
@ -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`
|
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||||
|
|
||||||
error: unused variable: `a`
|
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 {
|
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||||
|
|
||||||
error: unused variable: `b`
|
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 {
|
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||||
|
|
||||||
error: unused variable: `a`
|
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 {
|
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||||
|
|
||||||
error: unused variable: `b`
|
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 {
|
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||||
|
|
||||||
error: unused variable: `a`
|
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 {
|
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||||
|
|
||||||
error: unused variable: `b`
|
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 {
|
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||||
|
|
||||||
error: unused variable: `a`
|
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 {
|
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||||
|
|
||||||
error: unused variable: `b`
|
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 {
|
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||||
|
@ -17,7 +17,9 @@ pub mod normal {
|
|||||||
pub extern "C" fn function(a: usize, b: usize) -> usize {
|
pub extern "C" fn function(a: usize, b: usize) -> usize {
|
||||||
//~^ ERROR unused variable: `a`
|
//~^ ERROR unused variable: `a`
|
||||||
//~| ERROR unused variable: `b`
|
//~| ERROR unused variable: `b`
|
||||||
unsafe { asm!("", options(noreturn)); }
|
unsafe {
|
||||||
|
asm!("", options(noreturn));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Normal;
|
pub struct Normal;
|
||||||
@ -26,13 +28,17 @@ impl Normal {
|
|||||||
pub extern "C" fn associated(a: usize, b: usize) -> usize {
|
pub extern "C" fn associated(a: usize, b: usize) -> usize {
|
||||||
//~^ ERROR unused variable: `a`
|
//~^ ERROR unused variable: `a`
|
||||||
//~| ERROR unused variable: `b`
|
//~| ERROR unused variable: `b`
|
||||||
unsafe { asm!("", options(noreturn)); }
|
unsafe {
|
||||||
|
asm!("", options(noreturn));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
|
pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
|
||||||
//~^ ERROR unused variable: `a`
|
//~^ ERROR unused variable: `a`
|
||||||
//~| ERROR unused variable: `b`
|
//~| 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 {
|
extern "C" fn trait_associated(a: usize, b: usize) -> usize {
|
||||||
//~^ ERROR unused variable: `a`
|
//~^ ERROR unused variable: `a`
|
||||||
//~| ERROR unused variable: `b`
|
//~| ERROR unused variable: `b`
|
||||||
unsafe { asm!("", options(noreturn)); }
|
unsafe {
|
||||||
|
asm!("", options(noreturn));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
|
extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
|
||||||
//~^ ERROR unused variable: `a`
|
//~^ ERROR unused variable: `a`
|
||||||
//~| ERROR unused variable: `b`
|
//~| ERROR unused variable: `b`
|
||||||
unsafe { asm!("", options(noreturn)); }
|
unsafe {
|
||||||
|
asm!("", options(noreturn));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod naked {
|
pub mod naked {
|
||||||
use std::arch::asm;
|
use std::arch::naked_asm;
|
||||||
|
|
||||||
#[naked]
|
#[naked]
|
||||||
pub extern "C" fn function(a: usize, b: usize) -> usize {
|
pub extern "C" fn function(a: usize, b: usize) -> usize {
|
||||||
unsafe { asm!("", options(noreturn)); }
|
unsafe {
|
||||||
|
naked_asm!("", options(noreturn));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Naked;
|
pub struct Naked;
|
||||||
@ -64,24 +76,32 @@ pub extern "C" fn function(a: usize, b: usize) -> usize {
|
|||||||
impl Naked {
|
impl Naked {
|
||||||
#[naked]
|
#[naked]
|
||||||
pub extern "C" fn associated(a: usize, b: usize) -> usize {
|
pub extern "C" fn associated(a: usize, b: usize) -> usize {
|
||||||
unsafe { asm!("", options(noreturn)); }
|
unsafe {
|
||||||
|
naked_asm!("", options(noreturn));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[naked]
|
#[naked]
|
||||||
pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
|
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 {
|
impl super::Trait for Naked {
|
||||||
#[naked]
|
#[naked]
|
||||||
extern "C" fn trait_associated(a: usize, b: usize) -> usize {
|
extern "C" fn trait_associated(a: usize, b: usize) -> usize {
|
||||||
unsafe { asm!("", options(noreturn)); }
|
unsafe {
|
||||||
|
naked_asm!("", options(noreturn));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[naked]
|
#[naked]
|
||||||
extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
|
extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
|
||||||
unsafe { asm!("", options(noreturn)); }
|
unsafe {
|
||||||
|
naked_asm!("", options(noreturn));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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`
|
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||||
|
|
||||||
error: unused variable: `a`
|
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 {
|
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||||
|
|
||||||
error: unused variable: `b`
|
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 {
|
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||||
|
|
||||||
error: unused variable: `a`
|
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 {
|
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||||
|
|
||||||
error: unused variable: `b`
|
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 {
|
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||||
|
|
||||||
error: unused variable: `a`
|
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 {
|
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||||
|
|
||||||
error: unused variable: `b`
|
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 {
|
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||||
|
|
||||||
error: unused variable: `a`
|
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 {
|
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
| ^ help: if this is intentional, prefix it with an underscore: `_a`
|
||||||
|
|
||||||
error: unused variable: `b`
|
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 {
|
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
|
||||||
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
| ^ help: if this is intentional, prefix it with an underscore: `_b`
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
#[naked]
|
#[naked]
|
||||||
//~^ the `#[naked]` attribute is an experimental feature
|
//~^ the `#[naked]` attribute is an experimental feature
|
||||||
extern "C" fn naked() {
|
extern "C" fn naked() {
|
||||||
asm!("", options(noreturn))
|
naked_asm!("", options(noreturn))
|
||||||
//~^ ERROR: requires unsafe
|
//~^ ERROR: requires unsafe
|
||||||
}
|
}
|
||||||
|
|
||||||
#[naked]
|
#[naked]
|
||||||
//~^ the `#[naked]` attribute is an experimental feature
|
//~^ the `#[naked]` attribute is an experimental feature
|
||||||
extern "C" fn naked_2() -> isize {
|
extern "C" fn naked_2() -> isize {
|
||||||
asm!("", options(noreturn))
|
naked_asm!("", options(noreturn))
|
||||||
//~^ ERROR: requires unsafe
|
//~^ ERROR: requires unsafe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user