-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #16124 - ohno418:call-expr-missing-arg, r=Veykril
fix: Recover from missing argument in call expressions Previously, when parsing an argument list with a missing argument (e.g., `(a, , b)` in `foo(a, , b)`), the parser would stop upon an unexpected token (at the second comma in the example), resulting in an incorrect parse tree. This commit improves error handling in such cases, ensuring a more accurate parse tree is built. --- Fixes #15683.
- Loading branch information
Showing
16 changed files
with
267 additions
and
30 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
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
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
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ fn main() { | |
foo(bar::); | ||
foo(bar:); | ||
foo(bar+); | ||
foo(a, , b); | ||
} |
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ use {a; | |
use b; | ||
struct T; | ||
fn test() {} | ||
use {a ,, b}; |
44 changes: 44 additions & 0 deletions
44
crates/parser/test_data/parser/inline/err/0029_tuple_field_list_recovery.rast
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,44 @@ | ||
SOURCE_FILE | ||
STRUCT | ||
STRUCT_KW "struct" | ||
WHITESPACE " " | ||
NAME | ||
IDENT "S" | ||
TUPLE_FIELD_LIST | ||
L_PAREN "(" | ||
STRUCT | ||
STRUCT_KW "struct" | ||
WHITESPACE " " | ||
NAME | ||
IDENT "S" | ||
SEMICOLON ";" | ||
WHITESPACE "\n" | ||
STRUCT | ||
STRUCT_KW "struct" | ||
WHITESPACE " " | ||
NAME | ||
IDENT "S" | ||
TUPLE_FIELD_LIST | ||
L_PAREN "(" | ||
TUPLE_FIELD | ||
PATH_TYPE | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "A" | ||
COMMA "," | ||
ERROR | ||
COMMA "," | ||
TUPLE_FIELD | ||
PATH_TYPE | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "B" | ||
R_PAREN ")" | ||
SEMICOLON ";" | ||
WHITESPACE "\n" | ||
error 9: expected a type | ||
error 9: expected R_PAREN | ||
error 9: expected SEMICOLON | ||
error 30: expected tuple field |
2 changes: 2 additions & 0 deletions
2
crates/parser/test_data/parser/inline/err/0029_tuple_field_list_recovery.rs
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,2 @@ | ||
struct S(struct S; | ||
struct S(A,,B); |
33 changes: 33 additions & 0 deletions
33
crates/parser/test_data/parser/inline/err/0030_generic_arg_list_recover.rast
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,33 @@ | ||
SOURCE_FILE | ||
TYPE_ALIAS | ||
TYPE_KW "type" | ||
WHITESPACE " " | ||
NAME | ||
IDENT "T" | ||
WHITESPACE " " | ||
EQ "=" | ||
WHITESPACE " " | ||
PATH_TYPE | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "T" | ||
GENERIC_ARG_LIST | ||
L_ANGLE "<" | ||
CONST_ARG | ||
LITERAL | ||
INT_NUMBER "0" | ||
COMMA "," | ||
WHITESPACE " " | ||
ERROR | ||
COMMA "," | ||
TYPE_ARG | ||
PATH_TYPE | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "T" | ||
R_ANGLE ">" | ||
SEMICOLON ";" | ||
WHITESPACE "\n" | ||
error 14: expected generic argument |
1 change: 1 addition & 0 deletions
1
crates/parser/test_data/parser/inline/err/0030_generic_arg_list_recover.rs
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 @@ | ||
type T = T<0, ,T>; |
45 changes: 45 additions & 0 deletions
45
crates/parser/test_data/parser/inline/err/0031_generic_param_list_recover.rast
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,45 @@ | ||
SOURCE_FILE | ||
FN | ||
FN_KW "fn" | ||
WHITESPACE " " | ||
NAME | ||
IDENT "f" | ||
GENERIC_PARAM_LIST | ||
L_ANGLE "<" | ||
TYPE_PARAM | ||
NAME | ||
IDENT "T" | ||
COLON ":" | ||
WHITESPACE " " | ||
TYPE_BOUND_LIST | ||
TYPE_BOUND | ||
PATH_TYPE | ||
PATH | ||
PATH_SEGMENT | ||
NAME_REF | ||
IDENT "Clone" | ||
COMMA "," | ||
ERROR | ||
COMMA "," | ||
WHITESPACE " " | ||
TYPE_PARAM | ||
NAME | ||
IDENT "U" | ||
COLON ":" | ||
TYPE_BOUND_LIST | ||
COMMA "," | ||
WHITESPACE " " | ||
TYPE_PARAM | ||
NAME | ||
IDENT "V" | ||
R_ANGLE ">" | ||
PARAM_LIST | ||
L_PAREN "(" | ||
R_PAREN ")" | ||
WHITESPACE " " | ||
BLOCK_EXPR | ||
STMT_LIST | ||
L_CURLY "{" | ||
R_CURLY "}" | ||
WHITESPACE "\n" | ||
error 14: expected generic parameter |
1 change: 1 addition & 0 deletions
1
crates/parser/test_data/parser/inline/err/0031_generic_param_list_recover.rs
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 @@ | ||
fn f<T: Clone,, U:, V>() {} |