How do I emit multiple suggestions for a diagnostic?
Right now, my code looks like:
fn err_duplicate_option<'a>(p: &mut Parser<'a>, symbol: Symbol, span: Span) {
let mut err = p
.sess
.span_diagnostic
.struct_span_err(span, &format!("the `{}` option was already provided", symbol));
err.span_suggestion(
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();
}
But the output is:
error: the `att_syntax` option was already provided
--> rust-issue-73193.rs:10:28
|
10 | options(nomem, att_syntax, nostack, att_syntax),
| ^^^^^^^^^^
|
help: remove this option
|
10 | options(nomem, , nostack, att_syntax),
| --
When I remove the tool-only suggestion, I get what I would expect for the full thing, which is:
error: the `att_syntax` option was already provided
--> rust-issue-73193.rs:10:28
|
10 | options(nomem, att_syntax, nostack, att_syntax),
| ^^^^^^^^^^ help: remove this option
Does anyone know why this might be happening? Thanks for your help.