Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e12d675

Browse files
committed
delay error for unsupported options
1 parent 7ec06fc commit e12d675

File tree

5 files changed

+39
-79
lines changed

5 files changed

+39
-79
lines changed

compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,13 @@ fn validate_raw_asm_args<'a>(
347347

348348
for (symbol, option, span, full_span) in new_options {
349349
if !asm_macro.is_supported_option(option) {
350-
/*
351-
// Tool-only output
352-
p.dcx().emit_err(errors::AsmUnsupportedOption {
350+
// Tool-only output.
351+
dcx.emit_err(errors::AsmUnsupportedOption {
353352
span,
354353
symbol,
355354
full_span,
356355
macro_name: asm_macro.macro_name(),
357356
});
358-
*/
359357
} else if args.options.contains(option) {
360358
// Tool-only output.
361359
dcx.emit_err(errors::AsmOptAlreadyprovided { span, symbol, full_span });
@@ -500,16 +498,6 @@ fn parse_options<'a>(
500498
let full_span =
501499
if p.token == token::Comma { span.to(p.token.span) } else { span };
502500

503-
if !asm_macro.is_supported_option(option) {
504-
// Tool-only output.
505-
p.dcx().emit_err(errors::AsmUnsupportedOption {
506-
span,
507-
symbol: exp.kw,
508-
full_span,
509-
macro_name: asm_macro.macro_name(),
510-
});
511-
}
512-
513501
options.push((exp.kw, option, span, full_span));
514502
break 'blk;
515503
}

tests/ui/asm/aarch64/parse-error.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,8 @@ global_asm!("", options(FOO));
9696
//~^ ERROR expected one of
9797
global_asm!("", options(nomem FOO));
9898
//~^ ERROR expected one of
99-
//~| ERROR the `nomem` option cannot be used with `global_asm!`
10099
global_asm!("", options(nomem, FOO));
101100
//~^ ERROR expected one of
102-
//~| ERROR the `nomem` option cannot be used with `global_asm!`
103101
global_asm!("{}", options(), const FOO);
104102
global_asm!("", clobber_abi(FOO));
105103
//~^ ERROR expected string literal

tests/ui/asm/aarch64/parse-error.stderr

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -218,104 +218,92 @@ error: expected one of `)`, `att_syntax`, or `raw`, found `FOO`
218218
LL | global_asm!("", options(FOO));
219219
| ^^^ expected one of `)`, `att_syntax`, or `raw`
220220

221-
error: the `nomem` option cannot be used with `global_asm!`
222-
--> $DIR/parse-error.rs:97:25
223-
|
224-
LL | global_asm!("", options(nomem FOO));
225-
| ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly
226-
227221
error: expected one of `)` or `,`, found `FOO`
228222
--> $DIR/parse-error.rs:97:31
229223
|
230224
LL | global_asm!("", options(nomem FOO));
231225
| ^^^ expected one of `)` or `,`
232226

233-
error: the `nomem` option cannot be used with `global_asm!`
234-
--> $DIR/parse-error.rs:100:25
235-
|
236-
LL | global_asm!("", options(nomem, FOO));
237-
| ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly
238-
239227
error: expected one of `)`, `att_syntax`, or `raw`, found `FOO`
240-
--> $DIR/parse-error.rs:100:32
228+
--> $DIR/parse-error.rs:99:32
241229
|
242230
LL | global_asm!("", options(nomem, FOO));
243231
| ^^^ expected one of `)`, `att_syntax`, or `raw`
244232

245233
error: expected string literal
246-
--> $DIR/parse-error.rs:104:29
234+
--> $DIR/parse-error.rs:102:29
247235
|
248236
LL | global_asm!("", clobber_abi(FOO));
249237
| ^^^ not a string literal
250238

251239
error: expected one of `)` or `,`, found `FOO`
252-
--> $DIR/parse-error.rs:106:33
240+
--> $DIR/parse-error.rs:104:33
253241
|
254242
LL | global_asm!("", clobber_abi("C" FOO));
255243
| ^^^ expected one of `)` or `,`
256244

257245
error: expected string literal
258-
--> $DIR/parse-error.rs:108:34
246+
--> $DIR/parse-error.rs:106:34
259247
|
260248
LL | global_asm!("", clobber_abi("C", FOO));
261249
| ^^^ not a string literal
262250

263251
error: `clobber_abi` cannot be used with `global_asm!`
264-
--> $DIR/parse-error.rs:110:19
252+
--> $DIR/parse-error.rs:108:19
265253
|
266254
LL | global_asm!("{}", clobber_abi("C"), const FOO);
267255
| ^^^^^^^^^^^^^^^^
268256

269257
error: `clobber_abi` cannot be used with `global_asm!`
270-
--> $DIR/parse-error.rs:112:28
258+
--> $DIR/parse-error.rs:110:28
271259
|
272260
LL | global_asm!("", options(), clobber_abi("C"));
273261
| ^^^^^^^^^^^^^^^^
274262

275263
error: `clobber_abi` cannot be used with `global_asm!`
276-
--> $DIR/parse-error.rs:114:30
264+
--> $DIR/parse-error.rs:112:30
277265
|
278266
LL | global_asm!("{}", options(), clobber_abi("C"), const FOO);
279267
| ^^^^^^^^^^^^^^^^
280268

281269
error: duplicate argument named `a`
282-
--> $DIR/parse-error.rs:116:35
270+
--> $DIR/parse-error.rs:114:35
283271
|
284272
LL | global_asm!("{a}", a = const FOO, a = const BAR);
285273
| ------------- ^^^^^^^^^^^^^ duplicate argument
286274
| |
287275
| previously here
288276

289277
error: argument never used
290-
--> $DIR/parse-error.rs:116:35
278+
--> $DIR/parse-error.rs:114:35
291279
|
292280
LL | global_asm!("{a}", a = const FOO, a = const BAR);
293281
| ^^^^^^^^^^^^^ argument never used
294282
|
295283
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"`
296284

297285
error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""`
298-
--> $DIR/parse-error.rs:119:28
286+
--> $DIR/parse-error.rs:117:28
299287
|
300288
LL | global_asm!("", options(), "");
301289
| ^^ expected one of `clobber_abi`, `const`, `options`, or `sym`
302290

303291
error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"`
304-
--> $DIR/parse-error.rs:121:30
292+
--> $DIR/parse-error.rs:119:30
305293
|
306294
LL | global_asm!("{}", const FOO, "{}", const FOO);
307295
| ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym`
308296

309297
error: asm template must be a string literal
310-
--> $DIR/parse-error.rs:123:13
298+
--> $DIR/parse-error.rs:121:13
311299
|
312300
LL | global_asm!(format!("{{{}}}", 0), const FOO);
313301
| ^^^^^^^^^^^^^^^^^^^^
314302
|
315303
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
316304

317305
error: asm template must be a string literal
318-
--> $DIR/parse-error.rs:125:20
306+
--> $DIR/parse-error.rs:123:20
319307
|
320308
LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
321309
| ^^^^^^^^^^^^^^^^^^^^
@@ -418,6 +406,6 @@ LL - let mut bar = 0;
418406
LL + const bar: /* Type */ = 0;
419407
|
420408

421-
error: aborting due to 59 previous errors
409+
error: aborting due to 57 previous errors
422410

423411
For more information about this error, try `rustc --explain E0435`.

tests/ui/asm/parse-error.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,9 @@ global_asm!("", options(FOO));
113113
global_asm!("", options(FOO,));
114114
//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO`
115115
global_asm!("", options(nomem FOO));
116-
//~^ ERROR the `nomem` option cannot be used with `global_asm!`
117-
//~| ERROR expected one of `)` or `,`, found `FOO`
116+
//~^ ERROR expected one of `)` or `,`, found `FOO`
118117
global_asm!("", options(nomem, FOO));
119-
//~^ ERROR the `nomem` option cannot be used with `global_asm!`
120-
//~| ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO`
118+
//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO`
121119
global_asm!("{}", options(), const FOO);
122120
global_asm!("", clobber_abi(FOO));
123121
//~^ ERROR expected string literal

tests/ui/asm/parse-error.stderr

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -270,148 +270,136 @@ error: expected one of `)`, `att_syntax`, or `raw`, found `FOO`
270270
LL | global_asm!("", options(FOO,));
271271
| ^^^ expected one of `)`, `att_syntax`, or `raw`
272272

273-
error: the `nomem` option cannot be used with `global_asm!`
274-
--> $DIR/parse-error.rs:115:25
275-
|
276-
LL | global_asm!("", options(nomem FOO));
277-
| ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly
278-
279273
error: expected one of `)` or `,`, found `FOO`
280274
--> $DIR/parse-error.rs:115:31
281275
|
282276
LL | global_asm!("", options(nomem FOO));
283277
| ^^^ expected one of `)` or `,`
284278

285-
error: the `nomem` option cannot be used with `global_asm!`
286-
--> $DIR/parse-error.rs:118:25
287-
|
288-
LL | global_asm!("", options(nomem, FOO));
289-
| ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly
290-
291279
error: expected one of `)`, `att_syntax`, or `raw`, found `FOO`
292-
--> $DIR/parse-error.rs:118:32
280+
--> $DIR/parse-error.rs:117:32
293281
|
294282
LL | global_asm!("", options(nomem, FOO));
295283
| ^^^ expected one of `)`, `att_syntax`, or `raw`
296284

297285
error: expected string literal
298-
--> $DIR/parse-error.rs:122:29
286+
--> $DIR/parse-error.rs:120:29
299287
|
300288
LL | global_asm!("", clobber_abi(FOO));
301289
| ^^^ not a string literal
302290

303291
error: expected one of `)` or `,`, found `FOO`
304-
--> $DIR/parse-error.rs:124:33
292+
--> $DIR/parse-error.rs:122:33
305293
|
306294
LL | global_asm!("", clobber_abi("C" FOO));
307295
| ^^^ expected one of `)` or `,`
308296

309297
error: expected string literal
310-
--> $DIR/parse-error.rs:126:34
298+
--> $DIR/parse-error.rs:124:34
311299
|
312300
LL | global_asm!("", clobber_abi("C", FOO));
313301
| ^^^ not a string literal
314302

315303
error: `clobber_abi` cannot be used with `global_asm!`
316-
--> $DIR/parse-error.rs:128:19
304+
--> $DIR/parse-error.rs:126:19
317305
|
318306
LL | global_asm!("{}", clobber_abi("C"), const FOO);
319307
| ^^^^^^^^^^^^^^^^
320308

321309
error: `clobber_abi` cannot be used with `global_asm!`
322-
--> $DIR/parse-error.rs:130:28
310+
--> $DIR/parse-error.rs:128:28
323311
|
324312
LL | global_asm!("", options(), clobber_abi("C"));
325313
| ^^^^^^^^^^^^^^^^
326314

327315
error: `clobber_abi` cannot be used with `global_asm!`
328-
--> $DIR/parse-error.rs:132:30
316+
--> $DIR/parse-error.rs:130:30
329317
|
330318
LL | global_asm!("{}", options(), clobber_abi("C"), const FOO);
331319
| ^^^^^^^^^^^^^^^^
332320

333321
error: `clobber_abi` cannot be used with `global_asm!`
334-
--> $DIR/parse-error.rs:134:17
322+
--> $DIR/parse-error.rs:132:17
335323
|
336324
LL | global_asm!("", clobber_abi("C"), clobber_abi("C"));
337325
| ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
338326

339327
error: duplicate argument named `a`
340-
--> $DIR/parse-error.rs:136:35
328+
--> $DIR/parse-error.rs:134:35
341329
|
342330
LL | global_asm!("{a}", a = const FOO, a = const BAR);
343331
| ------------- ^^^^^^^^^^^^^ duplicate argument
344332
| |
345333
| previously here
346334

347335
error: argument never used
348-
--> $DIR/parse-error.rs:136:35
336+
--> $DIR/parse-error.rs:134:35
349337
|
350338
LL | global_asm!("{a}", a = const FOO, a = const BAR);
351339
| ^^^^^^^^^^^^^ argument never used
352340
|
353341
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"`
354342

355343
error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""`
356-
--> $DIR/parse-error.rs:139:28
344+
--> $DIR/parse-error.rs:137:28
357345
|
358346
LL | global_asm!("", options(), "");
359347
| ^^ expected one of `clobber_abi`, `const`, `options`, or `sym`
360348

361349
error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"`
362-
--> $DIR/parse-error.rs:141:30
350+
--> $DIR/parse-error.rs:139:30
363351
|
364352
LL | global_asm!("{}", const FOO, "{}", const FOO);
365353
| ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym`
366354

367355
error: asm template must be a string literal
368-
--> $DIR/parse-error.rs:143:13
356+
--> $DIR/parse-error.rs:141:13
369357
|
370358
LL | global_asm!(format!("{{{}}}", 0), const FOO);
371359
| ^^^^^^^^^^^^^^^^^^^^
372360
|
373361
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
374362

375363
error: asm template must be a string literal
376-
--> $DIR/parse-error.rs:145:20
364+
--> $DIR/parse-error.rs:143:20
377365
|
378366
LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
379367
| ^^^^^^^^^^^^^^^^^^^^
380368
|
381369
= note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
382370

383371
error: the `in` operand cannot be used with `global_asm!`
384-
--> $DIR/parse-error.rs:148:19
372+
--> $DIR/parse-error.rs:146:19
385373
|
386374
LL | global_asm!("{}", in(reg));
387375
| ^^ the `in` operand is not meaningful for global-scoped inline assembly, remove it
388376

389377
error: the `out` operand cannot be used with `global_asm!`
390-
--> $DIR/parse-error.rs:150:19
378+
--> $DIR/parse-error.rs:148:19
391379
|
392380
LL | global_asm!("{}", out(reg));
393381
| ^^^ the `out` operand is not meaningful for global-scoped inline assembly, remove it
394382

395383
error: the `lateout` operand cannot be used with `global_asm!`
396-
--> $DIR/parse-error.rs:152:19
384+
--> $DIR/parse-error.rs:150:19
397385
|
398386
LL | global_asm!("{}", lateout(reg));
399387
| ^^^^^^^ the `lateout` operand is not meaningful for global-scoped inline assembly, remove it
400388

401389
error: the `inout` operand cannot be used with `global_asm!`
402-
--> $DIR/parse-error.rs:154:19
390+
--> $DIR/parse-error.rs:152:19
403391
|
404392
LL | global_asm!("{}", inout(reg));
405393
| ^^^^^ the `inout` operand is not meaningful for global-scoped inline assembly, remove it
406394

407395
error: the `inlateout` operand cannot be used with `global_asm!`
408-
--> $DIR/parse-error.rs:156:19
396+
--> $DIR/parse-error.rs:154:19
409397
|
410398
LL | global_asm!("{}", inlateout(reg));
411399
| ^^^^^^^^^ the `inlateout` operand is not meaningful for global-scoped inline assembly, remove it
412400

413401
error: the `label` operand cannot be used with `global_asm!`
414-
--> $DIR/parse-error.rs:158:19
402+
--> $DIR/parse-error.rs:156:19
415403
|
416404
LL | global_asm!("{}", label(reg));
417405
| ^^^^^ the `label` operand is not meaningful for global-scoped inline assembly, remove it
@@ -476,6 +464,6 @@ LL - let mut bar = 0;
476464
LL + const bar: /* Type */ = 0;
477465
|
478466

479-
error: aborting due to 72 previous errors
467+
error: aborting due to 70 previous errors
480468

481469
For more information about this error, try `rustc --explain E0435`.

0 commit comments

Comments
 (0)