]> git.lizzy.rs Git - rust.git/commitdiff
Create a separate, tool-only suggestion for the comma
authorCamelid <camelidcamel@gmail.com>
Tue, 16 Jun 2020 19:43:03 +0000 (12:43 -0700)
committerCamelid <camelidcamel@gmail.com>
Sat, 20 Jun 2020 18:12:43 +0000 (11:12 -0700)
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.

src/librustc_builtin_macros/asm.rs

index 7e5eca29aeada0352be0555bb12bcbe05113400a..1d59029333db0034544049e74345f82e37bd0999 100644 (file)
@@ -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);
     }
 }