Skip to content

Commit b589f86

Browse files
committed
tests: add regression test for incorrect BytePos manipulation triggering assertion
Issue: <#128717>
1 parent fac7753 commit b589f86

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

Diff for: tests/ui/typeck/suggest-arg-comma-delete-ice.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! Previously, we tried to remove extra arg commas when providing extra arg removal suggestions.
2+
//! One of the edge cases is having to account for an arg that has a closing delimiter `)`
3+
//! following it. However, the previous suggestion code assumed that the delimiter is in fact
4+
//! exactly the 1-byte `)` character. This assumption was proven incorrect, because we recover
5+
//! from Unicode-confusable delimiters in the parser, which means that the ending delimiter could be
6+
//! a multi-byte codepoint that looks *like* a `)`. Subtracing 1 byte could land us in the middle of
7+
//! a codepoint, triggering a codepoint boundary assertion.
8+
//!
9+
//! issue: rust-lang/rust#128717
10+
11+
fn main() {
12+
// The following example has been modified from #128717 to remove irrelevant Unicode as they do
13+
// not otherwise partake in the right delimiter calculation causing the codepoint boundary
14+
// assertion.
15+
main(rahh);
16+
//~^ ERROR unknown start of token
17+
//~| ERROR this function takes 0 arguments but 1 argument was supplied
18+
//~| ERROR cannot find value `rahh` in this scope
19+
}

Diff for: tests/ui/typeck/suggest-arg-comma-delete-ice.stderr

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
error: unknown start of token: \u{ff09}
2+
--> $DIR/suggest-arg-comma-delete-ice.rs:15:14
3+
|
4+
LL | main(rahh);
5+
| ^^
6+
|
7+
help: Unicode character ')' (Fullwidth Right Parenthesis) looks like ')' (Right Parenthesis), but it is not
8+
|
9+
LL | main(rahh);
10+
| ~
11+
12+
error[E0425]: cannot find value `rahh` in this scope
13+
--> $DIR/suggest-arg-comma-delete-ice.rs:15:10
14+
|
15+
LL | main(rahh);
16+
| ^^^^ not found in this scope
17+
18+
error[E0061]: this function takes 0 arguments but 1 argument was supplied
19+
--> $DIR/suggest-arg-comma-delete-ice.rs:15:5
20+
|
21+
LL | main(rahh);
22+
| ^^^^ ---- unexpected argument
23+
|
24+
note: function defined here
25+
--> $DIR/suggest-arg-comma-delete-ice.rs:11:4
26+
|
27+
LL | fn main() {
28+
| ^^^^
29+
help: remove the extra argument
30+
|
31+
LL - main(rahh);
32+
LL + main();
33+
|
34+
35+
error: aborting due to 3 previous errors
36+
37+
Some errors have detailed explanations: E0061, E0425.
38+
For more information about an error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)