diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-07-18 23:05:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-18 23:05:21 +0200 |
| commit | 50a90e394e047891fd8437e4fcff30aa54ebf136 (patch) | |
| tree | 757018421f07b352d666cfa66e264cba4180943d /compiler/rustc_parse/src/parser | |
| parent | c1bbe347c278b7bddb0655b5e7f2a606e32f2ba4 (diff) | |
| parent | 67ec1326ee4e360b92dc6a6a3834bf8948532770 (diff) | |
| download | rust-50a90e394e047891fd8437e4fcff30aa54ebf136.tar.gz rust-50a90e394e047891fd8437e4fcff30aa54ebf136.zip | |
Rollup merge of #127835 - estebank:issue-127823, r=compiler-errors
Fix ICE in suggestion caused by `⩵` being recovered as `==`
The second suggestion shown here would previously incorrectly assume that the span corresponding to `⩵` was 2 bytes wide composed by 2 1 byte wide chars, so a span pointing at `==` could point only at one of the `=` to remove it. Instead, we now replace the whole thing (as we should have the whole time):
```
error: unknown start of token: \u{2a75}
--> $DIR/unicode-double-equals-recovery.rs:1:16
|
LL | const A: usize ⩵ 2;
| ^
|
help: Unicode character '⩵' (Two Consecutive Equals Signs) looks like '==' (Double Equals Sign), but it is not
|
LL | const A: usize == 2;
| ~~
error: unexpected `==`
--> $DIR/unicode-double-equals-recovery.rs:1:16
|
LL | const A: usize ⩵ 2;
| ^
|
help: try using `=` instead
|
LL | const A: usize = 2;
| ~
```
Fix #127823.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/diagnostics.rs | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 2fe3ab56146..326478a7175 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -566,10 +566,7 @@ impl<'a> Parser<'a> { && expected.iter().any(|tok| matches!(tok, TokenType::Token(TokenKind::Eq))) { // Likely typo: `=` → `==` in let expr or enum item - return Err(self.dcx().create_err(UseEqInstead { - span: self.token.span, - suggestion: self.token.span.with_lo(self.token.span.lo() + BytePos(1)), - })); + return Err(self.dcx().create_err(UseEqInstead { span: self.token.span })); } if self.token.is_keyword(kw::Move) && self.prev_token.is_keyword(kw::Async) { |
