1
Fork 0

Implement assertions and fixes to not emit empty spans without suggestions

This commit is contained in:
Kevin Per 2022-10-11 16:17:59 +00:00
parent 4b8f431995
commit 28d0312b7d
8 changed files with 81 additions and 117 deletions

View file

@ -1374,9 +1374,17 @@ impl<'a> Parser<'a> {
kind: IncDecRecovery,
(pre_span, post_span): (Span, Span),
) -> MultiSugg {
let mut patches = Vec::new();
if !pre_span.is_empty() {
patches.push((pre_span, String::new()));
}
patches.push((post_span, format!(" {}= 1", kind.op.chr())));
MultiSugg {
msg: format!("use `{}= 1` instead", kind.op.chr()),
patches: vec![(pre_span, String::new()), (post_span, format!(" {}= 1", kind.op.chr()))],
patches,
applicability: Applicability::MachineApplicable,
}
}