forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#128864 - jieyouxu:funnicode, r=Urgau
Use `SourceMap::end_point` instead of `- BytePos(1)` in arg removal suggestion Previously, we tried to remove extra arg commas when providing extra arg removal suggestions. One of the edge cases is having to account for an arg that has a closing delimiter `)` following it. However, the previous suggestion code assumed that the delimiter is in fact exactly the 1-byte `)` character. This assumption was proven incorrect, because we recover from Unicode-confusable delimiters in the parser, which means that the ending delimiter could be a multi-byte codepoint that looks *like* a `)`. Subtracing 1 byte could land us in the middle of a codepoint, triggering a codepoint boundary assertion. This is fixed by using `SourceMap::end_point` which properly accounts for codepoint boundaries. Fixes rust-lang#128717. cc `@fmease` and rust-lang#128790
- Loading branch information
Showing
3 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//! Previously, we tried to remove extra arg commas when providing extra arg removal suggestions. | ||
//! One of the edge cases is having to account for an arg that has a closing delimiter `)` | ||
//! following it. However, the previous suggestion code assumed that the delimiter is in fact | ||
//! exactly the 1-byte `)` character. This assumption was proven incorrect, because we recover | ||
//! from Unicode-confusable delimiters in the parser, which means that the ending delimiter could be | ||
//! a multi-byte codepoint that looks *like* a `)`. Subtracing 1 byte could land us in the middle of | ||
//! a codepoint, triggering a codepoint boundary assertion. | ||
//! | ||
//! issue: rust-lang/rust#128717 | ||
|
||
fn main() { | ||
// The following example has been modified from #128717 to remove irrelevant Unicode as they do | ||
// not otherwise partake in the right delimiter calculation causing the codepoint boundary | ||
// assertion. | ||
main(rahh); | ||
//~^ ERROR unknown start of token | ||
//~| ERROR this function takes 0 arguments but 1 argument was supplied | ||
//~| ERROR cannot find value `rahh` in this scope | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
error: unknown start of token: \u{ff09} | ||
--> $DIR/suggest-arg-comma-delete-ice.rs:15:14 | ||
| | ||
LL | main(rahh); | ||
| ^^ | ||
| | ||
help: Unicode character ')' (Fullwidth Right Parenthesis) looks like ')' (Right Parenthesis), but it is not | ||
| | ||
LL | main(rahh); | ||
| ~ | ||
|
||
error[E0425]: cannot find value `rahh` in this scope | ||
--> $DIR/suggest-arg-comma-delete-ice.rs:15:10 | ||
| | ||
LL | main(rahh); | ||
| ^^^^ not found in this scope | ||
|
||
error[E0061]: this function takes 0 arguments but 1 argument was supplied | ||
--> $DIR/suggest-arg-comma-delete-ice.rs:15:5 | ||
| | ||
LL | main(rahh); | ||
| ^^^^ ---- unexpected argument | ||
| | ||
note: function defined here | ||
--> $DIR/suggest-arg-comma-delete-ice.rs:11:4 | ||
| | ||
LL | fn main() { | ||
| ^^^^ | ||
help: remove the extra argument | ||
| | ||
LL - main(rahh); | ||
LL + main(); | ||
| | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0061, E0425. | ||
For more information about an error, try `rustc --explain E0061`. |