Skip to content

Commit 116de04

Browse files
committed
use naked_asm! in naked-function tests
1 parent 4323a16 commit 116de04

9 files changed

+68
-48
lines changed

Diff for: tests/codegen/naked-fn/naked-functions.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#![crate_type = "lib"]
66
#![feature(naked_functions)]
7-
use std::arch::asm;
7+
use std::arch::naked_asm;
88

99
// CHECK: Function Attrs: naked
1010
// CHECK-NEXT: define{{.*}}void @naked_empty()
@@ -14,7 +14,7 @@ pub unsafe extern "C" fn naked_empty() {
1414
// CHECK-NEXT: {{.+}}:
1515
// CHECK-NEXT: call void asm
1616
// CHECK-NEXT: unreachable
17-
asm!("ret", options(noreturn));
17+
naked_asm!("ret", options(noreturn));
1818
}
1919

2020
// CHECK: Function Attrs: naked
@@ -25,5 +25,5 @@ pub unsafe extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize
2525
// CHECK-NEXT: {{.+}}:
2626
// CHECK-NEXT: call void asm
2727
// CHECK-NEXT: unreachable
28-
asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
28+
naked_asm!("lea rax, [rdi + rsi]", "ret", options(noreturn));
2929
}

Diff for: tests/ui/asm/naked-functions-ffi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
#![feature(naked_functions)]
44
#![crate_type = "lib"]
55

6-
use std::arch::asm;
6+
use std::arch::naked_asm;
77

88
#[naked]
99
pub extern "C" fn naked(p: char) -> u128 {
1010
//~^ WARN uses type `char`
1111
//~| WARN uses type `u128`
1212
unsafe {
13-
asm!("", options(noreturn));
13+
naked_asm!("", options(noreturn));
1414
}
1515
}

Diff for: tests/ui/asm/naked-functions-inline.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,37 @@
22
#![feature(naked_functions)]
33
#![crate_type = "lib"]
44

5-
use std::arch::asm;
5+
use std::arch::naked_asm;
66

77
#[naked]
88
pub unsafe extern "C" fn inline_none() {
9-
asm!("", options(noreturn));
9+
naked_asm!("", options(noreturn));
1010
}
1111

1212
#[naked]
1313
#[inline]
1414
//~^ ERROR [E0736]
1515
pub unsafe extern "C" fn inline_hint() {
16-
asm!("", options(noreturn));
16+
naked_asm!("", options(noreturn));
1717
}
1818

1919
#[naked]
2020
#[inline(always)]
2121
//~^ ERROR [E0736]
2222
pub unsafe extern "C" fn inline_always() {
23-
asm!("", options(noreturn));
23+
naked_asm!("", options(noreturn));
2424
}
2525

2626
#[naked]
2727
#[inline(never)]
2828
//~^ ERROR [E0736]
2929
pub unsafe extern "C" fn inline_never() {
30-
asm!("", options(noreturn));
30+
naked_asm!("", options(noreturn));
3131
}
3232

3333
#[naked]
3434
#[cfg_attr(all(), inline(never))]
3535
//~^ ERROR [E0736]
3636
pub unsafe extern "C" fn conditional_inline_never() {
37-
asm!("", options(noreturn));
37+
naked_asm!("", options(noreturn));
3838
}

Diff for: tests/ui/asm/naked-functions-instruction-set.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#![no_core]
99

1010
#[rustc_builtin_macro]
11-
macro_rules! asm {
11+
macro_rules! naked_asm {
1212
() => {};
1313
}
1414

@@ -19,12 +19,12 @@ trait Sized {}
1919
#[naked]
2020
#[instruction_set(arm::t32)]
2121
unsafe extern "C" fn test_thumb() {
22-
asm!("bx lr", options(noreturn));
22+
naked_asm!("bx lr", options(noreturn));
2323
}
2424

2525
#[no_mangle]
2626
#[naked]
2727
#[instruction_set(arm::t32)]
2828
unsafe extern "C" fn test_arm() {
29-
asm!("bx lr", options(noreturn));
29+
naked_asm!("bx lr", options(noreturn));
3030
}

Diff for: tests/ui/asm/naked-functions-testattrs.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@
66
#![feature(test)]
77
#![crate_type = "lib"]
88

9-
use std::arch::asm;
9+
use std::arch::naked_asm;
1010

1111
#[test]
1212
#[naked]
1313
//~^ ERROR [E0736]
1414
fn test_naked() {
15-
unsafe { asm!("", options(noreturn)) };
15+
unsafe { naked_asm!("", options(noreturn)) };
1616
}
1717

1818
#[should_panic]
1919
#[test]
2020
#[naked]
2121
//~^ ERROR [E0736]
2222
fn test_naked_should_panic() {
23-
unsafe { asm!("", options(noreturn)) };
23+
unsafe { naked_asm!("", options(noreturn)) };
2424
}
2525

2626
#[ignore]
2727
#[test]
2828
#[naked]
2929
//~^ ERROR [E0736]
3030
fn test_naked_ignore() {
31-
unsafe { asm!("", options(noreturn)) };
31+
unsafe { naked_asm!("", options(noreturn)) };
3232
}
3333

3434
#[bench]
3535
#[naked]
3636
//~^ ERROR [E0736]
3737
fn bench_naked() {
38-
unsafe { asm!("", options(noreturn)) };
38+
unsafe { naked_asm!("", options(noreturn)) };
3939
}

Diff for: tests/ui/asm/naked-functions-unused.aarch64.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -18,49 +18,49 @@ LL | pub extern "C" fn function(a: usize, b: usize) -> usize {
1818
| ^ help: if this is intentional, prefix it with an underscore: `_b`
1919

2020
error: unused variable: `a`
21-
--> $DIR/naked-functions-unused.rs:26:38
21+
--> $DIR/naked-functions-unused.rs:28:38
2222
|
2323
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
2424
| ^ help: if this is intentional, prefix it with an underscore: `_a`
2525

2626
error: unused variable: `b`
27-
--> $DIR/naked-functions-unused.rs:26:48
27+
--> $DIR/naked-functions-unused.rs:28:48
2828
|
2929
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
3030
| ^ help: if this is intentional, prefix it with an underscore: `_b`
3131

3232
error: unused variable: `a`
33-
--> $DIR/naked-functions-unused.rs:32:41
33+
--> $DIR/naked-functions-unused.rs:36:41
3434
|
3535
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
3636
| ^ help: if this is intentional, prefix it with an underscore: `_a`
3737

3838
error: unused variable: `b`
39-
--> $DIR/naked-functions-unused.rs:32:51
39+
--> $DIR/naked-functions-unused.rs:36:51
4040
|
4141
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
4242
| ^ help: if this is intentional, prefix it with an underscore: `_b`
4343

4444
error: unused variable: `a`
45-
--> $DIR/naked-functions-unused.rs:40:40
45+
--> $DIR/naked-functions-unused.rs:46:40
4646
|
4747
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
4848
| ^ help: if this is intentional, prefix it with an underscore: `_a`
4949

5050
error: unused variable: `b`
51-
--> $DIR/naked-functions-unused.rs:40:50
51+
--> $DIR/naked-functions-unused.rs:46:50
5252
|
5353
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
5454
| ^ help: if this is intentional, prefix it with an underscore: `_b`
5555

5656
error: unused variable: `a`
57-
--> $DIR/naked-functions-unused.rs:46:43
57+
--> $DIR/naked-functions-unused.rs:54:43
5858
|
5959
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
6060
| ^ help: if this is intentional, prefix it with an underscore: `_a`
6161

6262
error: unused variable: `b`
63-
--> $DIR/naked-functions-unused.rs:46:53
63+
--> $DIR/naked-functions-unused.rs:54:53
6464
|
6565
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
6666
| ^ help: if this is intentional, prefix it with an underscore: `_b`

Diff for: tests/ui/asm/naked-functions-unused.rs

+31-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ pub mod normal {
1717
pub extern "C" fn function(a: usize, b: usize) -> usize {
1818
//~^ ERROR unused variable: `a`
1919
//~| ERROR unused variable: `b`
20-
unsafe { asm!("", options(noreturn)); }
20+
unsafe {
21+
asm!("", options(noreturn));
22+
}
2123
}
2224

2325
pub struct Normal;
@@ -26,62 +28,80 @@ pub mod normal {
2628
pub extern "C" fn associated(a: usize, b: usize) -> usize {
2729
//~^ ERROR unused variable: `a`
2830
//~| ERROR unused variable: `b`
29-
unsafe { asm!("", options(noreturn)); }
31+
unsafe {
32+
asm!("", options(noreturn));
33+
}
3034
}
3135

3236
pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
3337
//~^ ERROR unused variable: `a`
3438
//~| ERROR unused variable: `b`
35-
unsafe { asm!("", options(noreturn)); }
39+
unsafe {
40+
asm!("", options(noreturn));
41+
}
3642
}
3743
}
3844

3945
impl super::Trait for Normal {
4046
extern "C" fn trait_associated(a: usize, b: usize) -> usize {
4147
//~^ ERROR unused variable: `a`
4248
//~| ERROR unused variable: `b`
43-
unsafe { asm!("", options(noreturn)); }
49+
unsafe {
50+
asm!("", options(noreturn));
51+
}
4452
}
4553

4654
extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
4755
//~^ ERROR unused variable: `a`
4856
//~| ERROR unused variable: `b`
49-
unsafe { asm!("", options(noreturn)); }
57+
unsafe {
58+
asm!("", options(noreturn));
59+
}
5060
}
5161
}
5262
}
5363

5464
pub mod naked {
55-
use std::arch::asm;
65+
use std::arch::naked_asm;
5666

5767
#[naked]
5868
pub extern "C" fn function(a: usize, b: usize) -> usize {
59-
unsafe { asm!("", options(noreturn)); }
69+
unsafe {
70+
naked_asm!("", options(noreturn));
71+
}
6072
}
6173

6274
pub struct Naked;
6375

6476
impl Naked {
6577
#[naked]
6678
pub extern "C" fn associated(a: usize, b: usize) -> usize {
67-
unsafe { asm!("", options(noreturn)); }
79+
unsafe {
80+
naked_asm!("", options(noreturn));
81+
}
6882
}
6983

7084
#[naked]
7185
pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
72-
unsafe { asm!("", options(noreturn)); }
86+
unsafe {
87+
naked_asm!("", options(noreturn));
88+
}
7389
}
7490
}
7591

7692
impl super::Trait for Naked {
7793
#[naked]
7894
extern "C" fn trait_associated(a: usize, b: usize) -> usize {
79-
unsafe { asm!("", options(noreturn)); }
95+
unsafe {
96+
naked_asm!("", options(noreturn));
97+
}
8098
}
8199

82100
#[naked]
83101
extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
84-
unsafe { asm!("", options(noreturn)); }
102+
unsafe {
103+
naked_asm!("", options(noreturn));
104+
}
85105
}
86106
}
87107
}

Diff for: tests/ui/asm/naked-functions-unused.x86_64.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -18,49 +18,49 @@ LL | pub extern "C" fn function(a: usize, b: usize) -> usize {
1818
| ^ help: if this is intentional, prefix it with an underscore: `_b`
1919

2020
error: unused variable: `a`
21-
--> $DIR/naked-functions-unused.rs:26:38
21+
--> $DIR/naked-functions-unused.rs:28:38
2222
|
2323
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
2424
| ^ help: if this is intentional, prefix it with an underscore: `_a`
2525

2626
error: unused variable: `b`
27-
--> $DIR/naked-functions-unused.rs:26:48
27+
--> $DIR/naked-functions-unused.rs:28:48
2828
|
2929
LL | pub extern "C" fn associated(a: usize, b: usize) -> usize {
3030
| ^ help: if this is intentional, prefix it with an underscore: `_b`
3131

3232
error: unused variable: `a`
33-
--> $DIR/naked-functions-unused.rs:32:41
33+
--> $DIR/naked-functions-unused.rs:36:41
3434
|
3535
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
3636
| ^ help: if this is intentional, prefix it with an underscore: `_a`
3737

3838
error: unused variable: `b`
39-
--> $DIR/naked-functions-unused.rs:32:51
39+
--> $DIR/naked-functions-unused.rs:36:51
4040
|
4141
LL | pub extern "C" fn method(&self, a: usize, b: usize) -> usize {
4242
| ^ help: if this is intentional, prefix it with an underscore: `_b`
4343

4444
error: unused variable: `a`
45-
--> $DIR/naked-functions-unused.rs:40:40
45+
--> $DIR/naked-functions-unused.rs:46:40
4646
|
4747
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
4848
| ^ help: if this is intentional, prefix it with an underscore: `_a`
4949

5050
error: unused variable: `b`
51-
--> $DIR/naked-functions-unused.rs:40:50
51+
--> $DIR/naked-functions-unused.rs:46:50
5252
|
5353
LL | extern "C" fn trait_associated(a: usize, b: usize) -> usize {
5454
| ^ help: if this is intentional, prefix it with an underscore: `_b`
5555

5656
error: unused variable: `a`
57-
--> $DIR/naked-functions-unused.rs:46:43
57+
--> $DIR/naked-functions-unused.rs:54:43
5858
|
5959
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
6060
| ^ help: if this is intentional, prefix it with an underscore: `_a`
6161

6262
error: unused variable: `b`
63-
--> $DIR/naked-functions-unused.rs:46:53
63+
--> $DIR/naked-functions-unused.rs:54:53
6464
|
6565
LL | extern "C" fn trait_method(&self, a: usize, b: usize) -> usize {
6666
| ^ help: if this is intentional, prefix it with an underscore: `_b`

Diff for: tests/ui/feature-gates/feature-gate-naked_functions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ use std::arch::asm;
55
#[naked]
66
//~^ the `#[naked]` attribute is an experimental feature
77
extern "C" fn naked() {
8-
asm!("", options(noreturn))
8+
naked_asm!("", options(noreturn))
99
//~^ ERROR: requires unsafe
1010
}
1111

1212
#[naked]
1313
//~^ the `#[naked]` attribute is an experimental feature
1414
extern "C" fn naked_2() -> isize {
15-
asm!("", options(noreturn))
15+
naked_asm!("", options(noreturn))
1616
//~^ ERROR: requires unsafe
1717
}
1818

0 commit comments

Comments
 (0)