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 .sess
.span_diagnostic .span_diagnostic
.struct_span_err(span, &format!("the `{}` option was already provided", symbol)); .struct_span_err(span, &format!("the `{}` option was already provided", symbol));
err.span_suggestion( err.span_label(
span, 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", "remove this option",
String::new(), String::new(),
Applicability::MachineApplicable, 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(); err.emit();
} }

View file

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