about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamelid <camelidcamel@gmail.com>2020-06-16 12:43:03 -0700
committerCamelid <camelidcamel@gmail.com>2020-06-20 11:12:43 -0700
commit8fe6710b4db48e60f49c0d237d324d5490dc4f8e (patch)
treee08b7bd02c3469762e73a18e15b97f07c71ef49d
parent4ba66970d87684fa412a6475bf68ed6042c9e1e9 (diff)
downloadrust-8fe6710b4db48e60f49c0d237d324d5490dc4f8e.tar.gz
rust-8fe6710b4db48e60f49c0d237d324d5490dc4f8e.zip
Create a separate, tool-only suggestion for the comma
That way the comma isn't highlighted as part of the option in the UI.

Weirdly, the comma removal suggestion shows up in the UI.
-rw-r--r--src/librustc_builtin_macros/asm.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/librustc_builtin_macros/asm.rs b/src/librustc_builtin_macros/asm.rs
index 7e5eca29aea..1d59029333d 100644
--- a/src/librustc_builtin_macros/asm.rs
+++ b/src/librustc_builtin_macros/asm.rs
@@ -294,6 +294,14 @@ fn err_duplicate_option<'a>(p: &mut Parser<'a>, symbol: Symbol, span: Span) {
         String::new(),
         Applicability::MachineApplicable,
     );
+    if p.look_ahead(0, |t| t == &token::Comma) {
+        err.tool_only_span_suggestion(
+            p.token.span,
+            "remove this comma",
+            String::new(),
+            Applicability::MachineApplicable,
+        );
+    }
     err.emit();
 }
 
@@ -306,11 +314,7 @@ fn try_set_option<'a>(
     if !args.options.contains(option) {
         args.options |= option;
     } else {
-        let mut span = p.prev_token.span;
-        if p.look_ahead(0, |t| t == &token::Comma) {
-            span = span.to(p.token.span);
-        }
-        err_duplicate_option(p, symbol, span);
+        err_duplicate_option(p, symbol, p.prev_token.span);
     }
 }