Skip to content

Commit 8fe6710

Browse files
committed
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.
1 parent 4ba6697 commit 8fe6710

File tree

1 file changed

+9
-5
lines changed
  • src/librustc_builtin_macros

1 file changed

+9
-5
lines changed

src/librustc_builtin_macros/asm.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,14 @@ fn err_duplicate_option<'a>(p: &mut Parser<'a>, symbol: Symbol, span: Span) {
294294
String::new(),
295295
Applicability::MachineApplicable,
296296
);
297+
if p.look_ahead(0, |t| t == &token::Comma) {
298+
err.tool_only_span_suggestion(
299+
p.token.span,
300+
"remove this comma",
301+
String::new(),
302+
Applicability::MachineApplicable,
303+
);
304+
}
297305
err.emit();
298306
}
299307

@@ -306,11 +314,7 @@ fn try_set_option<'a>(
306314
if !args.options.contains(option) {
307315
args.options |= option;
308316
} else {
309-
let mut span = p.prev_token.span;
310-
if p.look_ahead(0, |t| t == &token::Comma) {
311-
span = span.to(p.token.span);
312-
}
313-
err_duplicate_option(p, symbol, span);
317+
err_duplicate_option(p, symbol, p.prev_token.span);
314318
}
315319
}
316320

0 commit comments

Comments
 (0)