Skip to content

Commit 8d80cc5

Browse files
committed
Fix duplicate options error
The UI isn't glitching anymore.
1 parent 58f812b commit 8d80cc5

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

src/librustc_builtin_macros/asm.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,20 +292,23 @@ fn err_duplicate_option<'a>(p: &mut Parser<'a>, symbol: Symbol, span: Span) {
292292
.sess
293293
.span_diagnostic
294294
.struct_span_err(span, &format!("the `{}` option was already provided", symbol));
295-
err.span_suggestion(
295+
err.span_label(
296296
span,
297+
"this option was already provided",
298+
);
299+
300+
// Tool-only output
301+
let mut full_span = span;
302+
if p.token.kind == token::Comma {
303+
full_span = full_span.to(p.token.span);
304+
}
305+
err.tool_only_span_suggestion(
306+
full_span,
297307
"remove this option",
298308
String::new(),
299309
Applicability::MachineApplicable,
300310
);
301-
if p.token.kind == token::Comma {
302-
err.tool_only_span_suggestion(
303-
p.token.span,
304-
"remove this comma",
305-
String::new(),
306-
Applicability::MachineApplicable,
307-
);
308-
}
311+
309312
err.emit();
310313
}
311314

src/test/ui/asm/duplicate-options.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,55 @@ error: the `nomem` option was already provided
22
--> $DIR/duplicate-options.rs:8:33
33
|
44
LL | asm!("", options(nomem, nomem));
5-
| ^^^^^ help: remove this option
5+
| ^^^^^ this option was already provided
66

77
error: the `att_syntax` option was already provided
88
--> $DIR/duplicate-options.rs:10:38
99
|
1010
LL | asm!("", options(att_syntax, att_syntax));
11-
| ^^^^^^^^^^ help: remove this option
11+
| ^^^^^^^^^^ this option was already provided
1212

1313
error: the `nostack` option was already provided
1414
--> $DIR/duplicate-options.rs:12:56
1515
|
1616
LL | asm!("", options(nostack, att_syntax), options(nostack));
17-
| ^^^^^^^ help: remove this option
17+
| ^^^^^^^ this option was already provided
1818

1919
error: the `nostack` option was already provided
2020
--> $DIR/duplicate-options.rs:14:35
2121
|
2222
LL | asm!("", options(nostack, nostack), options(nostack), options(nostack));
23-
| ^^^^^^^ help: remove this option
23+
| ^^^^^^^ this option was already provided
2424

2525
error: the `nostack` option was already provided
2626
--> $DIR/duplicate-options.rs:14:53
2727
|
2828
LL | asm!("", options(nostack, nostack), options(nostack), options(nostack));
29-
| ^^^^^^^ help: remove this option
29+
| ^^^^^^^ this option was already provided
3030

3131
error: the `nostack` option was already provided
3232
--> $DIR/duplicate-options.rs:14:71
3333
|
3434
LL | asm!("", options(nostack, nostack), options(nostack), options(nostack));
35-
| ^^^^^^^ help: remove this option
35+
| ^^^^^^^ this option was already provided
3636

3737
error: the `noreturn` option was already provided
3838
--> $DIR/duplicate-options.rs:21:33
3939
|
4040
LL | options(att_syntax, noreturn),
41-
| ^^^^^^^^ help: remove this option
41+
| ^^^^^^^^ this option was already provided
4242

4343
error: the `nomem` option was already provided
4444
--> $DIR/duplicate-options.rs:22:21
4545
|
4646
LL | options(nomem, nostack),
47-
| ^^^^^^ help: remove this option
47+
| ^^^^^ this option was already provided
4848

4949
error: the `noreturn` option was already provided
5050
--> $DIR/duplicate-options.rs:23:21
5151
|
5252
LL | options(noreturn),
53-
| ^^^^^^^^ help: remove this option
53+
| ^^^^^^^^ this option was already provided
5454

5555
error: aborting due to 9 previous errors
5656

0 commit comments

Comments
 (0)