mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-02 04:48:13 +00:00
fix: Improve parser recovery a bit
This commit is contained in:
parent
62e7e2b489
commit
e0dca847ad
15 changed files with 86 additions and 20 deletions
|
|
@ -870,6 +870,10 @@ mod err {
|
|||
run_and_expect_errors("test_data/parser/inline/err/tuple_pat_leading_comma.rs");
|
||||
}
|
||||
#[test]
|
||||
fn type_in_array_recover() {
|
||||
run_and_expect_errors("test_data/parser/inline/err/type_in_array_recover.rs");
|
||||
}
|
||||
#[test]
|
||||
fn unsafe_block_in_mod() {
|
||||
run_and_expect_errors("test_data/parser/inline/err/unsafe_block_in_mod.rs");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ SOURCE_FILE
|
|||
WHITESPACE " "
|
||||
LET_STMT
|
||||
LET_KW "let"
|
||||
ERROR
|
||||
R_BRACK "]"
|
||||
ERROR
|
||||
R_BRACK "]"
|
||||
WHITESPACE " "
|
||||
R_CURLY "}"
|
||||
WHITESPACE "\n"
|
||||
|
|
@ -149,7 +149,8 @@ error 17: expected expression, item or let statement
|
|||
error 25: expected a name
|
||||
error 26: expected `;`, `{`, or `(`
|
||||
error 30: expected pattern
|
||||
error 31: expected SEMICOLON
|
||||
error 30: expected SEMICOLON
|
||||
error 30: expected expression, item or let statement
|
||||
error 53: expected expression
|
||||
error 54: expected R_PAREN
|
||||
error 54: expected SEMICOLON
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ SOURCE_FILE
|
|||
L_CURLY "{"
|
||||
WHITESPACE " "
|
||||
DOT2 ".."
|
||||
ERROR
|
||||
COMMA ","
|
||||
COMMA ","
|
||||
WHITESPACE " "
|
||||
R_CURLY "}"
|
||||
SEMICOLON ";"
|
||||
|
|
@ -39,8 +38,7 @@ SOURCE_FILE
|
|||
L_CURLY "{"
|
||||
WHITESPACE " "
|
||||
DOT2 ".."
|
||||
ERROR
|
||||
COMMA ","
|
||||
COMMA ","
|
||||
WHITESPACE " "
|
||||
RECORD_EXPR_FIELD
|
||||
NAME_REF
|
||||
|
|
@ -55,5 +53,6 @@ SOURCE_FILE
|
|||
R_CURLY "}"
|
||||
WHITESPACE "\n"
|
||||
error 21: expected expression
|
||||
error 21: cannot use a comma after the base struct
|
||||
error 36: expected expression
|
||||
error 37: expected COMMA
|
||||
error 36: cannot use a comma after the base struct
|
||||
|
|
|
|||
|
|
@ -26,6 +26,36 @@ SOURCE_FILE
|
|||
WHITESPACE " "
|
||||
R_CURLY "}"
|
||||
WHITESPACE "\n"
|
||||
STRUCT
|
||||
STRUCT_KW "struct"
|
||||
WHITESPACE " "
|
||||
NAME
|
||||
IDENT "S"
|
||||
WHITESPACE " "
|
||||
RECORD_FIELD_LIST
|
||||
L_CURLY "{"
|
||||
WHITESPACE " "
|
||||
RECORD_FIELD
|
||||
NAME
|
||||
IDENT "f"
|
||||
COLON ":"
|
||||
WHITESPACE " "
|
||||
RECORD_FIELD
|
||||
VISIBILITY
|
||||
PUB_KW "pub"
|
||||
WHITESPACE " "
|
||||
NAME
|
||||
IDENT "g"
|
||||
COLON ":"
|
||||
WHITESPACE " "
|
||||
TUPLE_TYPE
|
||||
L_PAREN "("
|
||||
R_PAREN ")"
|
||||
WHITESPACE " "
|
||||
R_CURLY "}"
|
||||
WHITESPACE "\n"
|
||||
error 12: expected COLON
|
||||
error 12: expected type
|
||||
error 12: expected COMMA
|
||||
error 38: expected type
|
||||
error 38: expected COMMA
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
struct S { f pub g: () }
|
||||
struct S { f: pub g: () }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
SOURCE_FILE
|
||||
CONST
|
||||
CONST_KW "const"
|
||||
WHITESPACE " "
|
||||
UNDERSCORE "_"
|
||||
COLON ":"
|
||||
WHITESPACE " "
|
||||
SLICE_TYPE
|
||||
L_BRACK "["
|
||||
REF_TYPE
|
||||
AMP "&"
|
||||
R_BRACK "]"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n"
|
||||
error 11: expected type
|
||||
|
|
@ -0,0 +1 @@
|
|||
const _: [&];
|
||||
Loading…
Add table
Add a link
Reference in a new issue