From 11717ca5d4f12ff49645e6eb21e4976f0e879144 Mon Sep 17 00:00:00 2001 From: jnyfah Date: Fri, 10 Jan 2025 14:22:00 +0100 Subject: [PATCH 1/5] Missing errors --- crates/parser/src/grammar/expressions.rs | 10 +++++---- crates/parser/src/parser.rs | 27 ++++++++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs index 3b3f11be1307..6494ce8d7187 100644 --- a/crates/parser/src/grammar/expressions.rs +++ b/crates/parser/src/grammar/expressions.rs @@ -134,10 +134,12 @@ pub(super) fn let_stmt(p: &mut Parser<'_>, with_semi: Semicolon) { // test_err let_else_right_curly_brace // fn func() { let Some(_) = {Some(1)} else { panic!("h") };} if let Some(expr) = expr_after_eq { - if BlockLike::is_blocklike(expr.kind()) { - p.error( - "right curly brace `}` before `else` in a `let...else` statement not allowed", - ) + if let Some(token) = expr.last_token(p) { + if token == T!['}'] { + p.error( + "right curly brace `}` before `else` in a `let...else` statement not allowed" + ) + } } } diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs index 75a75f601cf1..832ba8d23a37 100644 --- a/crates/parser/src/parser.rs +++ b/crates/parser/src/parser.rs @@ -318,7 +318,8 @@ impl Marker { _ => unreachable!(), } p.push_event(Event::Finish); - CompletedMarker::new(self.pos, kind) + let end_pos = p.events.len() as u32; + CompletedMarker::new(self.pos, end_pos, kind) } /// Abandons the syntax tree node. All its children @@ -336,13 +337,14 @@ impl Marker { } pub(crate) struct CompletedMarker { - pos: u32, + start_pos: u32, + end_pos: u32, kind: SyntaxKind, } impl CompletedMarker { - fn new(pos: u32, kind: SyntaxKind) -> Self { - CompletedMarker { pos, kind } + fn new(start_pos: u32, end_pos: u32, kind: SyntaxKind) -> Self { + CompletedMarker { start_pos, end_pos, kind } } /// This method allows to create a new node which starts @@ -360,10 +362,10 @@ impl CompletedMarker { /// distance to `NEWSTART` into forward_parent(=2 in this case); pub(crate) fn precede(self, p: &mut Parser<'_>) -> Marker { let new_pos = p.start(); - let idx = self.pos as usize; + let idx = self.start_pos as usize; match &mut p.events[idx] { Event::Start { forward_parent, .. } => { - *forward_parent = Some(new_pos.pos - self.pos); + *forward_parent = Some(new_pos.pos - self.start_pos); } _ => unreachable!(), } @@ -376,7 +378,7 @@ impl CompletedMarker { let idx = m.pos as usize; match &mut p.events[idx] { Event::Start { forward_parent, .. } => { - *forward_parent = Some(self.pos - m.pos); + *forward_parent = Some(self.start_pos - m.pos); } _ => unreachable!(), } @@ -386,4 +388,15 @@ impl CompletedMarker { pub(crate) fn kind(&self) -> SyntaxKind { self.kind } + + pub(crate) fn last_token(&self, p: &Parser<'_>) -> Option { + let end_pos = self.end_pos as usize; + if end_pos > p.events.len() { + return None; + } + p.events[..end_pos].iter().rev().find_map(|event| match event { + Event::Token { kind, .. } => Some(*kind), + _ => None, + }) + } } From e3deeec2f26eee44d10c28efe95c06bd5ea6123b Mon Sep 17 00:00:00 2001 From: jnyfah Date: Thu, 16 Jan 2025 12:11:55 +0100 Subject: [PATCH 2/5] update blocklike --- crates/parser/src/event.rs | 2 +- crates/parser/src/grammar.rs | 5 +++-- crates/parser/src/grammar/expressions.rs | 10 ++++------ crates/parser/src/grammar/expressions/atom.rs | 2 +- crates/parser/src/parser.rs | 4 +--- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/crates/parser/src/event.rs b/crates/parser/src/event.rs index e38571dd3ec6..b197b086f377 100644 --- a/crates/parser/src/event.rs +++ b/crates/parser/src/event.rs @@ -12,7 +12,7 @@ use crate::{ /// `Parser` produces a flat list of `Event`s. /// They are converted to a tree-structure in /// a separate pass, via `TreeBuilder`. -#[derive(Debug)] +#[derive(Debug, PartialEq)] pub(crate) enum Event { /// This event signifies the start of the node. /// It should be either abandoned (in which case the diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index fe6b904bd889..d3aa56c7ebd6 100644 --- a/crates/parser/src/grammar.rs +++ b/crates/parser/src/grammar.rs @@ -204,8 +204,9 @@ impl BlockLike { self == BlockLike::Block } - fn is_blocklike(kind: SyntaxKind) -> bool { - matches!(kind, BLOCK_EXPR | IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR) + fn is_blocklike(expr: &CompletedMarker, p: &Parser<'_>) -> bool { + matches!(expr.kind(), BLOCK_EXPR | IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR) + || (expr.last_token(p) == Some(T!['}']) && !matches!(expr.kind(), CLOSURE_EXPR)) } } diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs index 6494ce8d7187..e7ba33bcb640 100644 --- a/crates/parser/src/grammar/expressions.rs +++ b/crates/parser/src/grammar/expressions.rs @@ -134,12 +134,10 @@ pub(super) fn let_stmt(p: &mut Parser<'_>, with_semi: Semicolon) { // test_err let_else_right_curly_brace // fn func() { let Some(_) = {Some(1)} else { panic!("h") };} if let Some(expr) = expr_after_eq { - if let Some(token) = expr.last_token(p) { - if token == T!['}'] { - p.error( - "right curly brace `}` before `else` in a `let...else` statement not allowed" - ) - } + if BlockLike::is_blocklike(&expr, p) { + p.error( + "right curly brace `}` before `else` in a `let...else` statement not allowed", + ) } } diff --git a/crates/parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs index 407320e1d082..40705d4a392d 100644 --- a/crates/parser/src/grammar/expressions/atom.rs +++ b/crates/parser/src/grammar/expressions/atom.rs @@ -198,7 +198,7 @@ pub(super) fn atom_expr( } }; let blocklike = - if BlockLike::is_blocklike(done.kind()) { BlockLike::Block } else { BlockLike::NotBlock }; + if BlockLike::is_blocklike(&done, p) { BlockLike::Block } else { BlockLike::NotBlock }; Some((done, blocklike)) } diff --git a/crates/parser/src/parser.rs b/crates/parser/src/parser.rs index 832ba8d23a37..2f6ba525747c 100644 --- a/crates/parser/src/parser.rs +++ b/crates/parser/src/parser.rs @@ -391,9 +391,7 @@ impl CompletedMarker { pub(crate) fn last_token(&self, p: &Parser<'_>) -> Option { let end_pos = self.end_pos as usize; - if end_pos > p.events.len() { - return None; - } + debug_assert_eq!(p.events[end_pos - 1], Event::Finish); p.events[..end_pos].iter().rev().find_map(|event| match event { Event::Token { kind, .. } => Some(*kind), _ => None, From 2ac6cb1521e45ca442d14f9f4dc0471f087db0ae Mon Sep 17 00:00:00 2001 From: jnyfah Date: Thu, 16 Jan 2025 12:54:26 +0100 Subject: [PATCH 3/5] revert blocklike changes --- crates/parser/src/grammar.rs | 5 ++--- crates/parser/src/grammar/expressions.rs | 10 ++++++---- crates/parser/src/grammar/expressions/atom.rs | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index d3aa56c7ebd6..fe6b904bd889 100644 --- a/crates/parser/src/grammar.rs +++ b/crates/parser/src/grammar.rs @@ -204,9 +204,8 @@ impl BlockLike { self == BlockLike::Block } - fn is_blocklike(expr: &CompletedMarker, p: &Parser<'_>) -> bool { - matches!(expr.kind(), BLOCK_EXPR | IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR) - || (expr.last_token(p) == Some(T!['}']) && !matches!(expr.kind(), CLOSURE_EXPR)) + fn is_blocklike(kind: SyntaxKind) -> bool { + matches!(kind, BLOCK_EXPR | IF_EXPR | WHILE_EXPR | FOR_EXPR | LOOP_EXPR | MATCH_EXPR) } } diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs index e7ba33bcb640..6494ce8d7187 100644 --- a/crates/parser/src/grammar/expressions.rs +++ b/crates/parser/src/grammar/expressions.rs @@ -134,10 +134,12 @@ pub(super) fn let_stmt(p: &mut Parser<'_>, with_semi: Semicolon) { // test_err let_else_right_curly_brace // fn func() { let Some(_) = {Some(1)} else { panic!("h") };} if let Some(expr) = expr_after_eq { - if BlockLike::is_blocklike(&expr, p) { - p.error( - "right curly brace `}` before `else` in a `let...else` statement not allowed", - ) + if let Some(token) = expr.last_token(p) { + if token == T!['}'] { + p.error( + "right curly brace `}` before `else` in a `let...else` statement not allowed" + ) + } } } diff --git a/crates/parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs index 40705d4a392d..407320e1d082 100644 --- a/crates/parser/src/grammar/expressions/atom.rs +++ b/crates/parser/src/grammar/expressions/atom.rs @@ -198,7 +198,7 @@ pub(super) fn atom_expr( } }; let blocklike = - if BlockLike::is_blocklike(&done, p) { BlockLike::Block } else { BlockLike::NotBlock }; + if BlockLike::is_blocklike(done.kind()) { BlockLike::Block } else { BlockLike::NotBlock }; Some((done, blocklike)) } From b96819ca44e3056175301d83593ba4afcfa96cd8 Mon Sep 17 00:00:00 2001 From: jnyfah Date: Thu, 16 Jan 2025 16:19:47 +0100 Subject: [PATCH 4/5] 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; +}; From 31c07e46767d9f0fbef6633a1ec70c524448922a Mon Sep 17 00:00:00 2001 From: jnyfah Date: Thu, 16 Jan 2025 16:46:06 +0100 Subject: [PATCH 5/5] CRLF to LF --- ...056_let_else_right_curly_brace_struct.rast | 95 +++++++++++-------- .../0056_let_else_right_curly_brace_struct.rs | 12 ++- ...let_else_right_curly_brace_arithmetic.rast | 12 +-- ...et_else_right_curly_brace_format_args.rast | 10 +- ...0058_let_else_right_curly_brace_range.rast | 12 +-- ...59_let_else_right_curly_brace_closure.rast | 12 +-- ...0060_let_else_right_curly_brace_unary.rast | 12 +-- ...61_let_else_right_curly_brace_do_yeet.rast | 14 +-- ...062_let_else_right_curly_brace_become.rast | 12 +-- ..._let_else_right_curly_brace_reference.rast | 12 +-- ...let_else_right_curly_brace_assignment.rast | 12 +-- 11 files changed, 115 insertions(+), 100 deletions(-) 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 index f62640ba60b4..578dc2b0f966 100644 --- 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 @@ -18,49 +18,62 @@ SOURCE_FILE NAME_REF IDENT "i32" R_CURLY "}" - WHITESPACE "\r\n" - ERROR - LET_KW "let" + WHITESPACE "\n" + FN + FN_KW "fn" WHITESPACE " " - IDENT_PAT - NAME - IDENT "foo" - WHITESPACE " " - EQ "=" + NAME + IDENT "f" + PARAM_LIST + L_PAREN "(" + R_PAREN ")" WHITESPACE " " - RECORD_EXPR - PATH - PATH_SEGMENT - NAME_REF - IDENT "X" - WHITESPACE " " - RECORD_EXPR_FIELD_LIST + BLOCK_EXPR + STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " - RECORD_EXPR_FIELD - NAME_REF - IDENT "a" - COLON ":" + WHITESPACE "\n " + LET_STMT + LET_KW "let" + WHITESPACE " " + IDENT_PAT + NAME + IDENT "foo" WHITESPACE " " - LITERAL - INT_NUMBER "1" - WHITESPACE "\r\n" + EQ "=" + WHITESPACE " " + RECORD_EXPR + PATH + PATH_SEGMENT + NAME_REF + IDENT "X" + WHITESPACE " " + RECORD_EXPR_FIELD_LIST + L_CURLY "{" + WHITESPACE "\n " + RECORD_EXPR_FIELD + NAME_REF + IDENT "a" + COLON ":" + WHITESPACE " " + LITERAL + INT_NUMBER "1" + WHITESPACE "\n " + R_CURLY "}" + WHITESPACE " " + LET_ELSE + ELSE_KW "else" + WHITESPACE " " + BLOCK_EXPR + STMT_LIST + L_CURLY "{" + WHITESPACE "\n " + EXPR_STMT + RETURN_EXPR + RETURN_KW "return" + SEMICOLON ";" + WHITESPACE "\n " + R_CURLY "}" + SEMICOLON ";" + WHITESPACE "\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 +error 63: 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 index 76a6bba18cd3..c0c0edc98301 100644 --- 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 @@ -1,6 +1,8 @@ struct X {a: i32} -let foo = X { - a: 1 -} else { - return; -}; +fn f() { + let foo = X { + a: 1 + } else { + return; + }; +} \ No newline at end of file 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 index 1f2c1b9cb75e..8e994f22d41b 100644 --- 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 @@ -17,10 +17,10 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " LITERAL INT_NUMBER "1" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" WHITESPACE " " LET_ELSE @@ -29,14 +29,14 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " EXPR_STMT RETURN_EXPR RETURN_KW "return" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" error 0: expected an item -error 25: right curly brace `}` before `else` in a `let...else` statement not allowed +error 23: 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.rast b/crates/parser/test_data/parser/err/0057_let_else_right_curly_brace_format_args.rast index 031ed98e67a4..055b583acec8 100644 --- 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 @@ -11,7 +11,7 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " LET_STMT LET_KW "let" WHITESPACE " " @@ -47,7 +47,7 @@ SOURCE_FILE WHITESPACE " " R_CURLY "}" SEMICOLON ";" - WHITESPACE "\r\n\r\n " + WHITESPACE "\n\n " LET_STMT LET_KW "let" WHITESPACE " " @@ -84,7 +84,7 @@ SOURCE_FILE WHITESPACE " " R_CURLY "}" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" - WHITESPACE "\r\n" -error 92: right curly brace `}` before `else` in a `let...else` statement not allowed + WHITESPACE "\n" +error 89: 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.rast b/crates/parser/test_data/parser/err/0058_let_else_right_curly_brace_range.rast index a59f5c462a74..8c7fd8c295d9 100644 --- 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 @@ -15,10 +15,10 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " LITERAL INT_NUMBER "1" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" WHITESPACE " " LET_ELSE @@ -27,14 +27,14 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " EXPR_STMT RETURN_EXPR RETURN_KW "return" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" error 0: expected an item -error 24: right curly brace `}` before `else` in a `let...else` statement not allowed +error 22: 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.rast b/crates/parser/test_data/parser/err/0059_let_else_right_curly_brace_closure.rast index 3cffa70aff09..57925a0d192f 100644 --- 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 @@ -27,13 +27,13 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " PATH_EXPR PATH PATH_SEGMENT NAME_REF IDENT "x" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" WHITESPACE " " LET_ELSE @@ -42,14 +42,14 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " EXPR_STMT RETURN_EXPR RETURN_KW "return" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" error 0: expected an item -error 30: right curly brace `}` before `else` in a `let...else` statement not allowed +error 28: 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.rast b/crates/parser/test_data/parser/err/0060_let_else_right_curly_brace_unary.rast index ddec752bcf83..4fb70bd50e38 100644 --- 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 @@ -13,10 +13,10 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " LITERAL INT_NUMBER "1" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" WHITESPACE " " LET_ELSE @@ -25,14 +25,14 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " EXPR_STMT RETURN_EXPR RETURN_KW "return" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" error 0: expected an item -error 22: right curly brace `}` before `else` in a `let...else` statement not allowed +error 20: 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.rast b/crates/parser/test_data/parser/err/0061_let_else_right_curly_brace_do_yeet.rast index 277778885bc5..e8eeeee695e9 100644 --- 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 @@ -33,7 +33,7 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " LET_STMT LET_KW "let" WHITESPACE " " @@ -51,11 +51,11 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " TUPLE_EXPR L_PAREN "(" R_PAREN ")" - WHITESPACE "\r\n " + WHITESPACE "\n " R_CURLY "}" WHITESPACE " " LET_ELSE @@ -64,7 +64,7 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " EXPR_STMT RETURN_EXPR RETURN_KW "return" @@ -82,9 +82,9 @@ SOURCE_FILE R_PAREN ")" R_PAREN ")" SEMICOLON ";" - WHITESPACE "\r\n " + WHITESPACE "\n " R_CURLY "}" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" -error 70: right curly brace `}` before `else` in a `let...else` statement not allowed +error 67: 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.rast b/crates/parser/test_data/parser/err/0062_let_else_right_curly_brace_become.rast index 75da59f98df4..cc5e1278c3de 100644 --- 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 @@ -14,11 +14,11 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " TUPLE_EXPR L_PAREN "(" R_PAREN ")" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" WHITESPACE " " LET_ELSE @@ -27,14 +27,14 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " EXPR_STMT RETURN_EXPR RETURN_KW "return" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" error 0: expected an item -error 29: right curly brace `}` before `else` in a `let...else` statement not allowed +error 27: 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.rast b/crates/parser/test_data/parser/err/0063_let_else_right_curly_brace_reference.rast index ff1e69c6c324..ea2f4f28e2d8 100644 --- 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 @@ -13,10 +13,10 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " LITERAL INT_NUMBER "1" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" WHITESPACE " " LET_ELSE @@ -25,14 +25,14 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " EXPR_STMT RETURN_EXPR RETURN_KW "return" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" error 0: expected an item -error 22: right curly brace `}` before `else` in a `let...else` statement not allowed +error 20: 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.rast b/crates/parser/test_data/parser/err/0064_let_else_right_curly_brace_assignment.rast index a53e08d0bba4..47396140c5c3 100644 --- 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 @@ -20,10 +20,10 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " LITERAL INT_NUMBER "1" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" WHITESPACE " " LET_ELSE @@ -32,14 +32,14 @@ SOURCE_FILE BLOCK_EXPR STMT_LIST L_CURLY "{" - WHITESPACE "\r\n " + WHITESPACE "\n " EXPR_STMT RETURN_EXPR RETURN_KW "return" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" R_CURLY "}" SEMICOLON ";" - WHITESPACE "\r\n" + WHITESPACE "\n" error 0: expected an item -error 27: right curly brace `}` before `else` in a `let...else` statement not allowed +error 25: right curly brace `}` before `else` in a `let...else` statement not allowed