From 8d80cc56794e43f5c6e89550dc6ac64101e278fa Mon Sep 17 00:00:00 2001 From: Camelid Date: Fri, 19 Jun 2020 20:18:32 -0700 Subject: [PATCH] Fix duplicate options error The UI isn't glitching anymore. --- src/librustc_builtin_macros/asm.rs | 21 ++++++++++++--------- src/test/ui/asm/duplicate-options.stderr | 18 +++++++++--------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/librustc_builtin_macros/asm.rs b/src/librustc_builtin_macros/asm.rs index 119536da0502..6fa04c279d26 100644 --- a/src/librustc_builtin_macros/asm.rs +++ b/src/librustc_builtin_macros/asm.rs @@ -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(); } diff --git a/src/test/ui/asm/duplicate-options.stderr b/src/test/ui/asm/duplicate-options.stderr index 46a966ddc860..cd8d743e031a 100644 --- a/src/test/ui/asm/duplicate-options.stderr +++ b/src/test/ui/asm/duplicate-options.stderr @@ -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