From ded10a13d2a0ccb4475cb7a330179a1f39e2b4ff Mon Sep 17 00:00:00 2001 From: yukang Date: Sat, 26 Nov 2022 07:10:04 +0800 Subject: will not suggest for postfix operator when can not handle precedences well --- compiler/rustc_parse/src/parser/diagnostics.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_parse/src/parser') diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index f8c6ff994c4..a9555cddb1b 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1316,7 +1316,11 @@ impl<'a> Parser<'a> { self.prefix_inc_dec_suggest(base_src, kind, spans).emit(&mut err) } UnaryFixity::Post => { - self.postfix_inc_dec_suggest(base_src, kind, spans).emit(&mut err) + // won't suggest since we can not handle the precedences + // for example: `a + b++` has been parsed (a + b)++ and we can not suggest here + if !matches!(base.kind, ExprKind::Binary(_, _, _)) { + self.postfix_inc_dec_suggest(base_src, kind, spans).emit(&mut err) + } } } } -- cgit 1.4.1-3-g733a5