diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-10-21 17:29:58 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-21 17:29:58 +0530 |
| commit | 0a0e9f73affa3daffbe76b1e8881ba71e1ab1eef (patch) | |
| tree | 230b9a0848c07d97273cf30f8578905ce4549e7b /compiler/rustc_parse/src/parser | |
| parent | 66d91d8276160d10f6c4032c85703a9715f5de60 (diff) | |
| parent | 28d0312b7d47b8bc8fcb4888ca627231715db3cd (diff) | |
| download | rust-0a0e9f73affa3daffbe76b1e8881ba71e1ab1eef.tar.gz rust-0a0e9f73affa3daffbe76b1e8881ba71e1ab1eef.zip | |
Rollup merge of #102922 - kper:bugfix/102902-filtering-json, r=oli-obk
Filtering spans when emitting json According to the issue #102902, we shouldn't emit spans which have an empty span and no suggested replacement.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 40d85c833a7..d654d84cdd5 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -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, } } |
