From b96819ca44e3056175301d83593ba4afcfa96cd8 Mon Sep 17 00:00:00 2001 From: jnyfah Date: Thu, 16 Jan 2025 16:19:47 +0100 Subject: [PATCH] added tests --- ...056_let_else_right_curly_brace_struct.rast | 66 ++++++++++++++ .../0056_let_else_right_curly_brace_struct.rs | 6 ++ ...let_else_right_curly_brace_arithmetic.rast | 42 +++++++++ ...7_let_else_right_curly_brace_arithmetic.rs | 5 ++ ...et_else_right_curly_brace_format_args.rast | 90 +++++++++++++++++++ ..._let_else_right_curly_brace_format_args.rs | 5 ++ ...0058_let_else_right_curly_brace_range.rast | 40 +++++++++ .../0058_let_else_right_curly_brace_range.rs | 5 ++ ...59_let_else_right_curly_brace_closure.rast | 55 ++++++++++++ ...0059_let_else_right_curly_brace_closure.rs | 5 ++ ...0060_let_else_right_curly_brace_unary.rast | 38 ++++++++ .../0060_let_else_right_curly_brace_unary.rs | 5 ++ ...61_let_else_right_curly_brace_do_yeet.rast | 90 +++++++++++++++++++ ...0061_let_else_right_curly_brace_do_yeet.rs | 7 ++ ...062_let_else_right_curly_brace_become.rast | 40 +++++++++ .../0062_let_else_right_curly_brace_become.rs | 5 ++ ..._let_else_right_curly_brace_reference.rast | 38 ++++++++ ...63_let_else_right_curly_brace_reference.rs | 5 ++ ...let_else_right_curly_brace_assignment.rast | 45 ++++++++++ ...4_let_else_right_curly_brace_assignment.rs | 5 ++ 20 files changed, 597 insertions(+) create mode 100644 crates/parser/test_data/parser/err/0056_let_else_right_curly_brace_struct.rast create mode 100644 crates/parser/test_data/parser/err/0056_let_else_right_curly_brace_struct.rs create mode 100644 crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_arithmetic.rast create mode 100644 crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_arithmetic.rs create mode 100644 crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_format_args.rast create mode 100644 crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_format_args.rs create mode 100644 crates/parser/test_data/parser/err/0058_let_else_right_curly_brace_range.rast create mode 100644 crates/parser/test_data/parser/err/0058_let_else_right_curly_brace_range.rs create mode 100644 crates/parser/test_data/parser/err/0059_let_else_right_curly_brace_closure.rast create mode 100644 crates/parser/test_data/parser/err/0059_let_else_right_curly_brace_closure.rs create mode 100644 crates/parser/test_data/parser/err/0060_let_else_right_curly_brace_unary.rast create mode 100644 crates/parser/test_data/parser/err/0060_let_else_right_curly_brace_unary.rs create mode 100644 crates/parser/test_data/parser/err/0061_let_else_right_curly_brace_do_yeet.rast create mode 100644 crates/parser/test_data/parser/err/0061_let_else_right_curly_brace_do_yeet.rs create mode 100644 crates/parser/test_data/parser/err/0062_let_else_right_curly_brace_become.rast create mode 100644 crates/parser/test_data/parser/err/0062_let_else_right_curly_brace_become.rs create mode 100644 crates/parser/test_data/parser/err/0063_let_else_right_curly_brace_reference.rast create mode 100644 crates/parser/test_data/parser/err/0063_let_else_right_curly_brace_reference.rs create mode 100644 crates/parser/test_data/parser/err/0064_let_else_right_curly_brace_assignment.rast create mode 100644 crates/parser/test_data/parser/err/0064_let_else_right_curly_brace_assignment.rs diff --git a/crates/parser/test_data/parser/err/0056_let_else_right_curly_brace_struct.rast b/crates/parser/test_data/parser/err/0056_let_else_right_curly_brace_struct.rast new file mode 100644 index 000000000000..f62640ba60b4 --- /dev/null +++ b/crates/parser/test_data/parser/err/0056_let_else_right_curly_brace_struct.rast @@ -0,0 +1,66 @@ +SOURCE_FILE + STRUCT + STRUCT_KW "struct" + WHITESPACE " " + NAME + IDENT "X" + WHITESPACE " " + RECORD_FIELD_LIST + L_CURLY "{" + RECORD_FIELD + NAME + IDENT "a" + COLON ":" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + IDENT "i32" + R_CURLY "}" + WHITESPACE "\r\n" + ERROR + LET_KW "let" + WHITESPACE " " + IDENT_PAT + NAME + IDENT "foo" + WHITESPACE " " + EQ "=" + WHITESPACE " " + RECORD_EXPR + PATH + PATH_SEGMENT + NAME_REF + IDENT "X" + WHITESPACE " " + RECORD_EXPR_FIELD_LIST + L_CURLY "{" + WHITESPACE "\r\n " + RECORD_EXPR_FIELD + NAME_REF + IDENT "a" + COLON ":" + WHITESPACE " " + LITERAL + INT_NUMBER "1" + WHITESPACE "\r\n" + R_CURLY "}" + WHITESPACE " " + LET_ELSE + ELSE_KW "else" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + EXPR_STMT + RETURN_EXPR + RETURN_KW "return" + SEMICOLON ";" + WHITESPACE "\r\n" + R_CURLY "}" + SEMICOLON ";" + WHITESPACE "\r\n" +error 19: expected an item +error 45: right curly brace `}` before `else` in a `let...else` statement not allowed diff --git a/crates/parser/test_data/parser/err/0056_let_else_right_curly_brace_struct.rs b/crates/parser/test_data/parser/err/0056_let_else_right_curly_brace_struct.rs new file mode 100644 index 000000000000..76a6bba18cd3 --- /dev/null +++ b/crates/parser/test_data/parser/err/0056_let_else_right_curly_brace_struct.rs @@ -0,0 +1,6 @@ +struct X {a: i32} +let foo = X { + a: 1 +} else { + return; +}; diff --git a/crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_arithmetic.rast b/crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_arithmetic.rast new file mode 100644 index 000000000000..1f2c1b9cb75e --- /dev/null +++ b/crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_arithmetic.rast @@ -0,0 +1,42 @@ +SOURCE_FILE + ERROR + LET_KW "let" + WHITESPACE " " + IDENT_PAT + NAME + IDENT "foo" + WHITESPACE " " + EQ "=" + WHITESPACE " " + BIN_EXPR + LITERAL + INT_NUMBER "1" + WHITESPACE " " + PLUS "+" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + LITERAL + INT_NUMBER "1" + WHITESPACE "\r\n" + R_CURLY "}" + WHITESPACE " " + LET_ELSE + ELSE_KW "else" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + EXPR_STMT + RETURN_EXPR + RETURN_KW "return" + SEMICOLON ";" + WHITESPACE "\r\n" + R_CURLY "}" + SEMICOLON ";" + WHITESPACE "\r\n" +error 0: expected an item +error 25: right curly brace `}` before `else` in a `let...else` statement not allowed diff --git a/crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_arithmetic.rs b/crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_arithmetic.rs new file mode 100644 index 000000000000..c29ddcce1ff5 --- /dev/null +++ b/crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_arithmetic.rs @@ -0,0 +1,5 @@ +let foo = 1 + { + 1 +} else { + return; +}; diff --git a/crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_format_args.rast b/crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_format_args.rast new file mode 100644 index 000000000000..031ed98e67a4 --- /dev/null +++ b/crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_format_args.rast @@ -0,0 +1,90 @@ +SOURCE_FILE + FN + FN_KW "fn" + WHITESPACE " " + NAME + IDENT "r" + PARAM_LIST + L_PAREN "(" + R_PAREN ")" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + LET_STMT + LET_KW "let" + WHITESPACE " " + IDENT_PAT + NAME + IDENT "ok" + WHITESPACE " " + EQ "=" + WHITESPACE " " + MACRO_EXPR + MACRO_CALL + PATH + PATH_SEGMENT + NAME_REF + IDENT "format_args" + BANG "!" + TOKEN_TREE + L_PAREN "(" + STRING "\"\"" + R_PAREN ")" + WHITESPACE " " + LET_ELSE + ELSE_KW "else" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE " " + EXPR_STMT + RETURN_EXPR + RETURN_KW "return" + SEMICOLON ";" + WHITESPACE " " + R_CURLY "}" + SEMICOLON ";" + WHITESPACE "\r\n\r\n " + LET_STMT + LET_KW "let" + WHITESPACE " " + IDENT_PAT + NAME + IDENT "bad" + WHITESPACE " " + EQ "=" + WHITESPACE " " + MACRO_EXPR + MACRO_CALL + PATH + PATH_SEGMENT + NAME_REF + IDENT "format_args" + BANG "!" + WHITESPACE " " + TOKEN_TREE + L_CURLY "{" + STRING "\"\"" + R_CURLY "}" + WHITESPACE " " + LET_ELSE + ELSE_KW "else" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE " " + EXPR_STMT + RETURN_EXPR + RETURN_KW "return" + SEMICOLON ";" + WHITESPACE " " + R_CURLY "}" + SEMICOLON ";" + WHITESPACE "\r\n" + R_CURLY "}" + WHITESPACE "\r\n" +error 92: right curly brace `}` before `else` in a `let...else` statement not allowed diff --git a/crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_format_args.rs b/crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_format_args.rs new file mode 100644 index 000000000000..5916fa07dc2f --- /dev/null +++ b/crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_format_args.rs @@ -0,0 +1,5 @@ +fn r() { + let ok = format_args!("") else { return; }; + + let bad = format_args! {""} else { return; }; +} diff --git a/crates/parser/test_data/parser/err/0058_let_else_right_curly_brace_range.rast b/crates/parser/test_data/parser/err/0058_let_else_right_curly_brace_range.rast new file mode 100644 index 000000000000..a59f5c462a74 --- /dev/null +++ b/crates/parser/test_data/parser/err/0058_let_else_right_curly_brace_range.rast @@ -0,0 +1,40 @@ +SOURCE_FILE + ERROR + LET_KW "let" + WHITESPACE " " + IDENT_PAT + NAME + IDENT "foo" + WHITESPACE " " + EQ "=" + WHITESPACE " " + RANGE_EXPR + LITERAL + INT_NUMBER "1" + DOT2 ".." + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + LITERAL + INT_NUMBER "1" + WHITESPACE "\r\n" + R_CURLY "}" + WHITESPACE " " + LET_ELSE + ELSE_KW "else" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + EXPR_STMT + RETURN_EXPR + RETURN_KW "return" + SEMICOLON ";" + WHITESPACE "\r\n" + R_CURLY "}" + SEMICOLON ";" + WHITESPACE "\r\n" +error 0: expected an item +error 24: right curly brace `}` before `else` in a `let...else` statement not allowed diff --git a/crates/parser/test_data/parser/err/0058_let_else_right_curly_brace_range.rs b/crates/parser/test_data/parser/err/0058_let_else_right_curly_brace_range.rs new file mode 100644 index 000000000000..5417131d28ea --- /dev/null +++ b/crates/parser/test_data/parser/err/0058_let_else_right_curly_brace_range.rs @@ -0,0 +1,5 @@ +let foo = 1..{ + 1 +} else { + return; +}; diff --git a/crates/parser/test_data/parser/err/0059_let_else_right_curly_brace_closure.rast b/crates/parser/test_data/parser/err/0059_let_else_right_curly_brace_closure.rast new file mode 100644 index 000000000000..3cffa70aff09 --- /dev/null +++ b/crates/parser/test_data/parser/err/0059_let_else_right_curly_brace_closure.rast @@ -0,0 +1,55 @@ +SOURCE_FILE + ERROR + LET_KW "let" + WHITESPACE " " + IDENT_PAT + NAME + IDENT "foo" + WHITESPACE " " + EQ "=" + WHITESPACE " " + CLOSURE_EXPR + PARAM_LIST + PIPE "|" + PARAM + IDENT_PAT + NAME + IDENT "x" + COLON ":" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + IDENT "i32" + PIPE "|" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + PATH_EXPR + PATH + PATH_SEGMENT + NAME_REF + IDENT "x" + WHITESPACE "\r\n" + R_CURLY "}" + WHITESPACE " " + LET_ELSE + ELSE_KW "else" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + EXPR_STMT + RETURN_EXPR + RETURN_KW "return" + SEMICOLON ";" + WHITESPACE "\r\n" + R_CURLY "}" + SEMICOLON ";" + WHITESPACE "\r\n" +error 0: expected an item +error 30: right curly brace `}` before `else` in a `let...else` statement not allowed diff --git a/crates/parser/test_data/parser/err/0059_let_else_right_curly_brace_closure.rs b/crates/parser/test_data/parser/err/0059_let_else_right_curly_brace_closure.rs new file mode 100644 index 000000000000..89c7579b071f --- /dev/null +++ b/crates/parser/test_data/parser/err/0059_let_else_right_curly_brace_closure.rs @@ -0,0 +1,5 @@ +let foo = |x: i32| { + x +} else { + return; +}; diff --git a/crates/parser/test_data/parser/err/0060_let_else_right_curly_brace_unary.rast b/crates/parser/test_data/parser/err/0060_let_else_right_curly_brace_unary.rast new file mode 100644 index 000000000000..ddec752bcf83 --- /dev/null +++ b/crates/parser/test_data/parser/err/0060_let_else_right_curly_brace_unary.rast @@ -0,0 +1,38 @@ +SOURCE_FILE + ERROR + LET_KW "let" + WHITESPACE " " + IDENT_PAT + NAME + IDENT "foo" + WHITESPACE " " + EQ "=" + WHITESPACE " " + PREFIX_EXPR + MINUS "-" + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + LITERAL + INT_NUMBER "1" + WHITESPACE "\r\n" + R_CURLY "}" + WHITESPACE " " + LET_ELSE + ELSE_KW "else" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + EXPR_STMT + RETURN_EXPR + RETURN_KW "return" + SEMICOLON ";" + WHITESPACE "\r\n" + R_CURLY "}" + SEMICOLON ";" + WHITESPACE "\r\n" +error 0: expected an item +error 22: right curly brace `}` before `else` in a `let...else` statement not allowed diff --git a/crates/parser/test_data/parser/err/0060_let_else_right_curly_brace_unary.rs b/crates/parser/test_data/parser/err/0060_let_else_right_curly_brace_unary.rs new file mode 100644 index 000000000000..1ba7f7d761ba --- /dev/null +++ b/crates/parser/test_data/parser/err/0060_let_else_right_curly_brace_unary.rs @@ -0,0 +1,5 @@ +let foo = -{ + 1 +} else { + return; +}; diff --git a/crates/parser/test_data/parser/err/0061_let_else_right_curly_brace_do_yeet.rast b/crates/parser/test_data/parser/err/0061_let_else_right_curly_brace_do_yeet.rast new file mode 100644 index 000000000000..277778885bc5 --- /dev/null +++ b/crates/parser/test_data/parser/err/0061_let_else_right_curly_brace_do_yeet.rast @@ -0,0 +1,90 @@ +SOURCE_FILE + FN + FN_KW "fn" + WHITESPACE " " + NAME + IDENT "o" + PARAM_LIST + L_PAREN "(" + R_PAREN ")" + WHITESPACE " " + RET_TYPE + THIN_ARROW "->" + WHITESPACE " " + PATH_TYPE + PATH + PATH_SEGMENT + NAME_REF + IDENT "Result" + GENERIC_ARG_LIST + L_ANGLE "<" + TYPE_ARG + TUPLE_TYPE + L_PAREN "(" + R_PAREN ")" + COMMA "," + WHITESPACE " " + TYPE_ARG + TUPLE_TYPE + L_PAREN "(" + R_PAREN ")" + R_ANGLE ">" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + LET_STMT + LET_KW "let" + WHITESPACE " " + IDENT_PAT + NAME + IDENT "foo" + WHITESPACE " " + EQ "=" + WHITESPACE " " + YEET_EXPR + DO_KW "do" + WHITESPACE " " + YEET_KW "yeet" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + TUPLE_EXPR + L_PAREN "(" + R_PAREN ")" + WHITESPACE "\r\n " + R_CURLY "}" + WHITESPACE " " + LET_ELSE + ELSE_KW "else" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + EXPR_STMT + RETURN_EXPR + RETURN_KW "return" + WHITESPACE " " + CALL_EXPR + PATH_EXPR + PATH + PATH_SEGMENT + NAME_REF + IDENT "Ok" + ARG_LIST + L_PAREN "(" + TUPLE_EXPR + L_PAREN "(" + R_PAREN ")" + R_PAREN ")" + SEMICOLON ";" + WHITESPACE "\r\n " + R_CURLY "}" + SEMICOLON ";" + WHITESPACE "\r\n" + R_CURLY "}" +error 70: right curly brace `}` before `else` in a `let...else` statement not allowed diff --git a/crates/parser/test_data/parser/err/0061_let_else_right_curly_brace_do_yeet.rs b/crates/parser/test_data/parser/err/0061_let_else_right_curly_brace_do_yeet.rs new file mode 100644 index 000000000000..188fb07d91b4 --- /dev/null +++ b/crates/parser/test_data/parser/err/0061_let_else_right_curly_brace_do_yeet.rs @@ -0,0 +1,7 @@ +fn o() -> Result<(), ()> { + let foo = do yeet { + () + } else { + return Ok(()); + }; +} \ No newline at end of file diff --git a/crates/parser/test_data/parser/err/0062_let_else_right_curly_brace_become.rast b/crates/parser/test_data/parser/err/0062_let_else_right_curly_brace_become.rast new file mode 100644 index 000000000000..75da59f98df4 --- /dev/null +++ b/crates/parser/test_data/parser/err/0062_let_else_right_curly_brace_become.rast @@ -0,0 +1,40 @@ +SOURCE_FILE + ERROR + LET_KW "let" + WHITESPACE " " + IDENT_PAT + NAME + IDENT "foo" + WHITESPACE " " + EQ "=" + WHITESPACE " " + BECOME_EXPR + BECOME_KW "become" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + TUPLE_EXPR + L_PAREN "(" + R_PAREN ")" + WHITESPACE "\r\n" + R_CURLY "}" + WHITESPACE " " + LET_ELSE + ELSE_KW "else" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + EXPR_STMT + RETURN_EXPR + RETURN_KW "return" + SEMICOLON ";" + WHITESPACE "\r\n" + R_CURLY "}" + SEMICOLON ";" + WHITESPACE "\r\n" +error 0: expected an item +error 29: right curly brace `}` before `else` in a `let...else` statement not allowed diff --git a/crates/parser/test_data/parser/err/0062_let_else_right_curly_brace_become.rs b/crates/parser/test_data/parser/err/0062_let_else_right_curly_brace_become.rs new file mode 100644 index 000000000000..622548b8f33c --- /dev/null +++ b/crates/parser/test_data/parser/err/0062_let_else_right_curly_brace_become.rs @@ -0,0 +1,5 @@ +let foo = become { + () +} else { + return; +}; diff --git a/crates/parser/test_data/parser/err/0063_let_else_right_curly_brace_reference.rast b/crates/parser/test_data/parser/err/0063_let_else_right_curly_brace_reference.rast new file mode 100644 index 000000000000..ff1e69c6c324 --- /dev/null +++ b/crates/parser/test_data/parser/err/0063_let_else_right_curly_brace_reference.rast @@ -0,0 +1,38 @@ +SOURCE_FILE + ERROR + LET_KW "let" + WHITESPACE " " + IDENT_PAT + NAME + IDENT "foo" + WHITESPACE " " + EQ "=" + WHITESPACE " " + REF_EXPR + AMP "&" + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + LITERAL + INT_NUMBER "1" + WHITESPACE "\r\n" + R_CURLY "}" + WHITESPACE " " + LET_ELSE + ELSE_KW "else" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + EXPR_STMT + RETURN_EXPR + RETURN_KW "return" + SEMICOLON ";" + WHITESPACE "\r\n" + R_CURLY "}" + SEMICOLON ";" + WHITESPACE "\r\n" +error 0: expected an item +error 22: right curly brace `}` before `else` in a `let...else` statement not allowed diff --git a/crates/parser/test_data/parser/err/0063_let_else_right_curly_brace_reference.rs b/crates/parser/test_data/parser/err/0063_let_else_right_curly_brace_reference.rs new file mode 100644 index 000000000000..9a00dca3689f --- /dev/null +++ b/crates/parser/test_data/parser/err/0063_let_else_right_curly_brace_reference.rs @@ -0,0 +1,5 @@ +let foo = &{ + 1 +} else { + return; +}; diff --git a/crates/parser/test_data/parser/err/0064_let_else_right_curly_brace_assignment.rast b/crates/parser/test_data/parser/err/0064_let_else_right_curly_brace_assignment.rast new file mode 100644 index 000000000000..a53e08d0bba4 --- /dev/null +++ b/crates/parser/test_data/parser/err/0064_let_else_right_curly_brace_assignment.rast @@ -0,0 +1,45 @@ +SOURCE_FILE + ERROR + LET_KW "let" + WHITESPACE " " + IDENT_PAT + NAME + IDENT "foo" + WHITESPACE " " + EQ "=" + WHITESPACE " " + BIN_EXPR + PATH_EXPR + PATH + PATH_SEGMENT + NAME_REF + IDENT "bar" + WHITESPACE " " + EQ "=" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + LITERAL + INT_NUMBER "1" + WHITESPACE "\r\n" + R_CURLY "}" + WHITESPACE " " + LET_ELSE + ELSE_KW "else" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\r\n " + EXPR_STMT + RETURN_EXPR + RETURN_KW "return" + SEMICOLON ";" + WHITESPACE "\r\n" + R_CURLY "}" + SEMICOLON ";" + WHITESPACE "\r\n" +error 0: expected an item +error 27: right curly brace `}` before `else` in a `let...else` statement not allowed diff --git a/crates/parser/test_data/parser/err/0064_let_else_right_curly_brace_assignment.rs b/crates/parser/test_data/parser/err/0064_let_else_right_curly_brace_assignment.rs new file mode 100644 index 000000000000..08e677416f10 --- /dev/null +++ b/crates/parser/test_data/parser/err/0064_let_else_right_curly_brace_assignment.rs @@ -0,0 +1,5 @@ +let foo = bar = { + 1 +} else { + return; +};