1
Fork 0

Fix duplicate options error

The UI isn't glitching anymore.
This commit is contained in:
Camelid 2020-06-19 20:18:32 -07:00
parent 58f812bd61
commit 8d80cc5679
2 changed files with 21 additions and 18 deletions

View file

@ -292,20 +292,23 @@ fn err_duplicate_option<'a>(p: &mut Parser<'a>, symbol: Symbol, span: Span) {
.sess
.span_diagnostic
.struct_span_err(span, &format!("the `{}` option was already provided", symbol));
err.span_suggestion(
err.span_label(
span,
"this option was already provided",
);
// Tool-only output
let mut full_span = span;
if p.token.kind == token::Comma {
full_span = full_span.to(p.token.span);
}
err.tool_only_span_suggestion(
full_span,
"remove this option",
String::new(),
Applicability::MachineApplicable,
);
if p.token.kind == token::Comma {
err.tool_only_span_suggestion(
p.token.span,
"remove this comma",
String::new(),
Applicability::MachineApplicable,
);
}
err.emit();
}

View file

@ -2,55 +2,55 @@ error: the `nomem` option was already provided
--> $DIR/duplicate-options.rs:8:33
|
LL | asm!("", options(nomem, nomem));
| ^^^^^ help: remove this option
| ^^^^^ this option was already provided
error: the `att_syntax` option was already provided
--> $DIR/duplicate-options.rs:10:38
|
LL | asm!("", options(att_syntax, att_syntax));
| ^^^^^^^^^^ help: remove this option
| ^^^^^^^^^^ this option was already provided
error: the `nostack` option was already provided
--> $DIR/duplicate-options.rs:12:56
|
LL | asm!("", options(nostack, att_syntax), options(nostack));
| ^^^^^^^ help: remove this option
| ^^^^^^^ this option was already provided
error: the `nostack` option was already provided
--> $DIR/duplicate-options.rs:14:35
|
LL | asm!("", options(nostack, nostack), options(nostack), options(nostack));
| ^^^^^^^ help: remove this option
| ^^^^^^^ this option was already provided
error: the `nostack` option was already provided
--> $DIR/duplicate-options.rs:14:53
|
LL | asm!("", options(nostack, nostack), options(nostack), options(nostack));
| ^^^^^^^ help: remove this option
| ^^^^^^^ this option was already provided
error: the `nostack` option was already provided
--> $DIR/duplicate-options.rs:14:71
|
LL | asm!("", options(nostack, nostack), options(nostack), options(nostack));
| ^^^^^^^ help: remove this option
| ^^^^^^^ this option was already provided
error: the `noreturn` option was already provided
--> $DIR/duplicate-options.rs:21:33
|
LL | options(att_syntax, noreturn),
| ^^^^^^^^ help: remove this option
| ^^^^^^^^ this option was already provided
error: the `nomem` option was already provided
--> $DIR/duplicate-options.rs:22:21
|
LL | options(nomem, nostack),
| ^^^^^^ help: remove this option
| ^^^^^ this option was already provided
error: the `noreturn` option was already provided
--> $DIR/duplicate-options.rs:23:21
|
LL | options(noreturn),
| ^^^^^^^^ help: remove this option
| ^^^^^^^^ this option was already provided
error: aborting due to 9 previous errors