X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_parse%2Fsrc%2Fparser%2Fdiagnostics.rs;h=7e11ca57cebdad6b271efb01a5f4f6c0f5d0743c;hb=28d0312b7d47b8bc8fcb4888ca627231715db3cd;hp=828b7d2f2f7be6ea0435fcaec8daf8fce5a7cc98;hpb=4b8f4319954ff2642690b9e5cbe4af352d095bf6;p=rust.git diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 828b7d2f2f7..7e11ca57ceb 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1374,9 +1374,17 @@ fn inc_dec_standalone_suggest( 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, } }