Skip to content

Commit 4323a16

Browse files
committed
use naked_asm! in tests/ui/asm/naked-functions.rs
1 parent dd0edd7 commit 4323a16

File tree

2 files changed

+117
-139
lines changed

2 files changed

+117
-139
lines changed

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

+36-36
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![feature(asm_unwind, linkage)]
77
#![crate_type = "lib"]
88

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

1111
#[repr(C)]
1212
pub struct P {
@@ -25,7 +25,7 @@ pub unsafe extern "C" fn patterns(
2525
P { x, y }: P,
2626
//~^ ERROR patterns not allowed in naked function parameters
2727
) {
28-
asm!("", options(noreturn))
28+
naked_asm!("", options(noreturn))
2929
}
3030

3131
#[naked]
@@ -38,9 +38,8 @@ pub unsafe extern "C" fn inc(a: u32) -> u32 {
3838
#[naked]
3939
#[allow(asm_sub_register)]
4040
pub unsafe extern "C" fn inc_asm(a: u32) -> u32 {
41-
asm!("/* {0} */", in(reg) a, options(noreturn));
42-
//~^ ERROR referencing function parameters is not allowed in naked functions
43-
//~| ERROR only `const` and `sym` operands are supported in naked functions
41+
naked_asm!("/* {0} */", in(reg) a, options(noreturn))
42+
//~^ ERROR the `in` operand cannot be used with `naked_asm!`
4443
}
4544

4645
#[naked]
@@ -59,10 +58,9 @@ pub unsafe extern "C" fn unsupported_operands() {
5958
let mut e = 0usize;
6059
const F: usize = 0usize;
6160
static G: usize = 0usize;
62-
asm!("/* {0} {1} {2} {3} {4} {5} {6} */",
63-
//~^ ERROR asm in naked functions must use `noreturn` option
61+
naked_asm!("/* {0} {1} {2} {3} {4} {5} {6} */",
6462
in(reg) a,
65-
//~^ ERROR only `const` and `sym` operands are supported in naked functions
63+
//~^ ERROR the `in` operand cannot be used with `naked_asm!`
6664
inlateout(reg) b,
6765
inout(reg) c,
6866
lateout(reg) d,
@@ -81,13 +79,13 @@ pub extern "C" fn missing_assembly() {
8179
pub extern "C" fn too_many_asm_blocks() {
8280
//~^ ERROR naked functions must contain a single asm block
8381
unsafe {
84-
asm!("");
82+
naked_asm!("");
8583
//~^ ERROR asm in naked functions must use `noreturn` option
86-
asm!("");
84+
naked_asm!("");
8785
//~^ ERROR asm in naked functions must use `noreturn` option
88-
asm!("");
86+
naked_asm!("");
8987
//~^ ERROR asm in naked functions must use `noreturn` option
90-
asm!("", options(noreturn));
88+
naked_asm!("", options(noreturn));
9189
}
9290
}
9391

@@ -103,40 +101,42 @@ pub fn outer(x: u32) -> extern "C" fn(usize) -> usize {
103101

104102
#[naked]
105103
unsafe extern "C" fn invalid_options() {
106-
asm!("", options(nomem, preserves_flags, noreturn));
107-
//~^ ERROR asm options unsupported in naked functions: `nomem`, `preserves_flags`
104+
naked_asm!("", options(nomem, preserves_flags, noreturn));
105+
//~^ ERROR the `nomem` option cannot be used with `naked_asm!`
106+
//~| ERROR the `preserves_flags` option cannot be used with `naked_asm!`
108107
}
109108

110109
#[naked]
111110
unsafe extern "C" fn invalid_options_continued() {
112-
asm!("", options(readonly, nostack), options(pure));
113-
//~^ ERROR asm with the `pure` option must have at least one output
114-
//~| ERROR asm options unsupported in naked functions: `pure`, `readonly`, `nostack`
111+
naked_asm!("", options(readonly, nostack), options(pure));
112+
//~^ ERROR the `readonly` option cannot be used with `naked_asm!`
113+
//~| ERROR the `nostack` option cannot be used with `naked_asm!`
114+
//~| ERROR the `pure` option cannot be used with `naked_asm!`
115115
//~| ERROR asm in naked functions must use `noreturn` option
116116
}
117117

118118
#[naked]
119119
unsafe extern "C" fn invalid_may_unwind() {
120-
asm!("", options(noreturn, may_unwind));
121-
//~^ ERROR asm options unsupported in naked functions: `may_unwind`
120+
naked_asm!("", options(noreturn, may_unwind));
121+
//~^ ERROR the `may_unwind` option cannot be used with `naked_asm!`
122122
}
123123

124124
#[naked]
125125
pub unsafe fn default_abi() {
126126
//~^ WARN Rust ABI is unsupported in naked functions
127-
asm!("", options(noreturn));
127+
naked_asm!("", options(noreturn));
128128
}
129129

130130
#[naked]
131131
pub unsafe fn rust_abi() {
132132
//~^ WARN Rust ABI is unsupported in naked functions
133-
asm!("", options(noreturn));
133+
naked_asm!("", options(noreturn));
134134
}
135135

136136
#[naked]
137137
pub extern "C" fn valid_a<T>() -> T {
138138
unsafe {
139-
asm!("", options(noreturn));
139+
naked_asm!("", options(noreturn));
140140
}
141141
}
142142

@@ -145,21 +145,21 @@ pub extern "C" fn valid_b() {
145145
unsafe {
146146
{
147147
{
148-
asm!("", options(noreturn));
148+
naked_asm!("", options(noreturn));
149149
};
150150
};
151151
}
152152
}
153153

154154
#[naked]
155155
pub unsafe extern "C" fn valid_c() {
156-
asm!("", options(noreturn));
156+
naked_asm!("", options(noreturn));
157157
}
158158

159159
#[cfg(target_arch = "x86_64")]
160160
#[naked]
161161
pub unsafe extern "C" fn valid_att_syntax() {
162-
asm!("", options(noreturn, att_syntax));
162+
naked_asm!("", options(noreturn, att_syntax));
163163
}
164164

165165
#[naked]
@@ -173,20 +173,20 @@ pub unsafe extern "C" fn allow_compile_error(a: u32) -> u32 {
173173
pub unsafe extern "C" fn allow_compile_error_and_asm(a: u32) -> u32 {
174174
compile_error!("this is a user specified error");
175175
//~^ ERROR this is a user specified error
176-
asm!("", options(noreturn))
176+
naked_asm!("", options(noreturn))
177177
}
178178

179179
#[naked]
180180
pub unsafe extern "C" fn invalid_asm_syntax(a: u32) -> u32 {
181-
asm!(invalid_syntax)
181+
naked_asm!(invalid_syntax)
182182
//~^ ERROR asm template must be a string literal
183183
}
184184

185185
#[cfg(target_arch = "x86_64")]
186186
#[cfg_attr(target_pointer_width = "64", no_mangle)]
187187
#[naked]
188188
pub unsafe extern "C" fn compatible_cfg_attributes() {
189-
asm!("", options(noreturn, att_syntax));
189+
naked_asm!("", options(noreturn, att_syntax));
190190
}
191191

192192
#[allow(dead_code)]
@@ -195,20 +195,20 @@ pub unsafe extern "C" fn compatible_cfg_attributes() {
195195
#[forbid(dead_code)]
196196
#[naked]
197197
pub unsafe extern "C" fn compatible_diagnostic_attributes() {
198-
asm!("", options(noreturn, raw));
198+
naked_asm!("", options(noreturn, raw));
199199
}
200200

201201
#[deprecated = "test"]
202202
#[naked]
203203
pub unsafe extern "C" fn compatible_deprecated_attributes() {
204-
asm!("", options(noreturn, raw));
204+
naked_asm!("", options(noreturn, raw));
205205
}
206206

207207
#[cfg(target_arch = "x86_64")]
208208
#[must_use]
209209
#[naked]
210210
pub unsafe extern "C" fn compatible_must_use_attributes() -> u64 {
211-
asm!(
211+
naked_asm!(
212212
"
213213
mov rax, 42
214214
ret
@@ -222,20 +222,20 @@ pub unsafe extern "C" fn compatible_must_use_attributes() -> u64 {
222222
#[no_mangle]
223223
#[naked]
224224
pub unsafe extern "C" fn compatible_ffi_attributes_1() {
225-
asm!("", options(noreturn, raw));
225+
naked_asm!("", options(noreturn, raw));
226226
}
227227

228228
#[cold]
229229
#[naked]
230230
pub unsafe extern "C" fn compatible_codegen_attributes() {
231-
asm!("", options(noreturn, raw));
231+
naked_asm!("", options(noreturn, raw));
232232
}
233233

234234
#[cfg(target_arch = "x86_64")]
235235
#[target_feature(enable = "sse2")]
236236
#[naked]
237237
pub unsafe extern "C" fn compatible_target_feature() {
238-
asm!("", options(noreturn));
238+
naked_asm!("", options(noreturn));
239239
}
240240

241241
#[doc = "foo bar baz"]
@@ -244,11 +244,11 @@ pub unsafe extern "C" fn compatible_target_feature() {
244244
#[doc(alias = "ADocAlias")]
245245
#[naked]
246246
pub unsafe extern "C" fn compatible_doc_attributes() {
247-
asm!("", options(noreturn, raw));
247+
naked_asm!("", options(noreturn, raw));
248248
}
249249

250250
#[linkage = "external"]
251251
#[naked]
252252
pub unsafe extern "C" fn compatible_linkage() {
253-
asm!("", options(noreturn, raw));
253+
naked_asm!("", options(noreturn, raw));
254254
}

0 commit comments

Comments
 (0)