about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/diagnostics.rs
diff options
context:
space:
mode:
authoryukang <moorekang@gmail.com>2022-11-26 07:10:04 +0800
committeryukang <moorekang@gmail.com>2022-11-26 17:08:25 +0800
commitded10a13d2a0ccb4475cb7a330179a1f39e2b4ff (patch)
treeb5d6d45c0c5476df20f017ea4c902b589771a126 /compiler/rustc_parse/src/parser/diagnostics.rs
parentdee85a391f091f314a24fb5a090f2e528f4eb81c (diff)
downloadrust-ded10a13d2a0ccb4475cb7a330179a1f39e2b4ff.tar.gz
rust-ded10a13d2a0ccb4475cb7a330179a1f39e2b4ff.zip
will not suggest for postfix operator when can not handle precedences well
Diffstat (limited to 'compiler/rustc_parse/src/parser/diagnostics.rs')
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs6
1 files changed, 5 insertions, 1 deletions
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)
+                        }
                     }
                 }
             }