about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-08-09 17:27:39 +0000
committerbors <bors@rust-lang.org>2024-08-09 17:27:39 +0000
commit19ebdcedf1f5619f8f06c546c7541bb9b54aecda (patch)
tree42df35380f272a19d6558a2d8dfe4e63f5bba588 /compiler/rustc_parse/src/parser
parent899eb03926be23f2e5d2ffcaa1d6f9ac40af7f13 (diff)
parentcea3b42f5848f1c8f676ee5830ff67aa50cd8099 (diff)
downloadrust-19ebdcedf1f5619f8f06c546c7541bb9b54aecda.tar.gz
rust-19ebdcedf1f5619f8f06c546c7541bb9b54aecda.zip
Auto merge of #128883 - matthiaskrgr:rollup-mkzi7my, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #128815 (Add `Steal::is_stolen()`)
 - #128817 (VxWorks code refactored )
 - #128822 (add `builder-config` into tarball sources)
 - #128838 (rustdoc: do not run doctests with invalid langstrings)
 - #128852 (use stable sort to sort multipart diagnostics)
 - #128859 (Fix the name of signal 19 in library/std/src/sys/pal/unix/process/process_unix/tests.rs for mips/sparc linux)
 - #128864 (Use `SourceMap::end_point` instead of `- BytePos(1)` in arg removal suggestion)
 - #128865 (Ensure let stmt compound assignment removal suggestion respect codepoint boundaries)
 - #128874 (Disable verbose bootstrap command failure logging by default)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/stmt.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs
index b3efb87a4a2..a3b782d651d 100644
--- a/compiler/rustc_parse/src/parser/stmt.rs
+++ b/compiler/rustc_parse/src/parser/stmt.rs
@@ -408,10 +408,14 @@ impl<'a> Parser<'a> {
     fn parse_initializer(&mut self, eq_optional: bool) -> PResult<'a, Option<P<Expr>>> {
         let eq_consumed = match self.token.kind {
             token::BinOpEq(..) => {
-                // Recover `let x <op>= 1` as `let x = 1`
+                // Recover `let x <op>= 1` as `let x = 1` We must not use `+ BytePos(1)` here
+                // because `<op>` can be a multi-byte lookalike that was recovered, e.g. `➖=` (the
+                // `➖` is a U+2796 Heavy Minus Sign Unicode Character) that was recovered as a
+                // `-=`.
+                let extra_op_span = self.psess.source_map().start_point(self.token.span);
                 self.dcx().emit_err(errors::CompoundAssignmentExpressionInLet {
                     span: self.token.span,
-                    suggestion: self.token.span.with_hi(self.token.span.lo() + BytePos(1)),
+                    suggestion: extra_op_span,
                 });
                 self.bump();
                 true