From 359d3be308cab2415218200f5799c5031213c250 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 2 May 2020 14:34:39 +0200 Subject: Fix parsing of blocks without `{` --- .../parser/err/0010_unsafe_lambda_block.rast | 2 +- .../test_data/parser/err/0163_weird_blocks.rast | 71 ++++++++++++++++++++++ .../test_data/parser/err/0163_weird_blocks.rs | 6 ++ .../parser/inline/ok/0105_block_expr.rast | 21 ------- .../test_data/parser/inline/ok/0105_block_expr.rs | 3 - 5 files changed, 78 insertions(+), 25 deletions(-) create mode 100644 crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast create mode 100644 crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rs delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.rast delete mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.rs (limited to 'crates/ra_syntax/test_data/parser') diff --git a/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast b/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast index 06a326d26..3bf57eacc 100644 --- a/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast +++ b/crates/ra_syntax/test_data/parser/err/0010_unsafe_lambda_block.rast @@ -40,5 +40,5 @@ SOURCE_FILE@0..42 WHITESPACE@39..40 "\n" R_CURLY@40..41 "}" WHITESPACE@41..42 "\n" -error 24..24: expected `{` +error 24..24: expected a block error 24..24: expected SEMICOLON diff --git a/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast b/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast new file mode 100644 index 000000000..e46456384 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rast @@ -0,0 +1,71 @@ +SOURCE_FILE@0..83 + FN_DEF@0..82 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..7 + IDENT@3..7 "main" + PARAM_LIST@7..9 + L_PAREN@7..8 "(" + R_PAREN@8..9 ")" + WHITESPACE@9..10 " " + BLOCK_EXPR@10..82 + L_CURLY@10..11 "{" + WHITESPACE@11..16 "\n " + EXPR_STMT@16..29 + BLOCK_EXPR@16..29 + L_CURLY@16..17 "{" + WHITESPACE@17..18 " " + ERROR@18..24 + UNSAFE_KW@18..24 "unsafe" + WHITESPACE@24..25 " " + LITERAL@25..27 + INT_NUMBER@25..27 "92" + WHITESPACE@27..28 " " + R_CURLY@28..29 "}" + WHITESPACE@29..34 "\n " + EXPR_STMT@34..46 + BLOCK_EXPR@34..46 + L_CURLY@34..35 "{" + WHITESPACE@35..36 " " + ERROR@36..41 + ASYNC_KW@36..41 "async" + WHITESPACE@41..42 " " + LITERAL@42..44 + INT_NUMBER@42..44 "92" + WHITESPACE@44..45 " " + R_CURLY@45..46 "}" + WHITESPACE@46..51 "\n " + EXPR_STMT@51..61 + BLOCK_EXPR@51..61 + L_CURLY@51..52 "{" + WHITESPACE@52..53 " " + EXPR_STMT@53..56 + EFFECT_EXPR@53..56 + TRY_KW@53..56 "try" + WHITESPACE@56..57 " " + LITERAL@57..59 + INT_NUMBER@57..59 "92" + WHITESPACE@59..60 " " + R_CURLY@60..61 "}" + WHITESPACE@61..66 "\n " + BLOCK_EXPR@66..80 + L_CURLY@66..67 "{" + WHITESPACE@67..68 " " + EXPR_STMT@68..75 + ERROR@68..75 + LABEL@68..75 + LIFETIME@68..74 "\'label" + COLON@74..75 ":" + WHITESPACE@75..76 " " + LITERAL@76..78 + INT_NUMBER@76..78 "92" + WHITESPACE@78..79 " " + R_CURLY@79..80 "}" + WHITESPACE@80..81 "\n" + R_CURLY@81..82 "}" + WHITESPACE@82..83 "\n" +error 24..24: expected existential, fn, trait or impl +error 41..41: expected existential, fn, trait or impl +error 56..56: expected a block +error 75..75: expected a loop +error 75..75: expected SEMICOLON diff --git a/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rs b/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rs new file mode 100644 index 000000000..8fa324c1a --- /dev/null +++ b/crates/ra_syntax/test_data/parser/err/0163_weird_blocks.rs @@ -0,0 +1,6 @@ +fn main() { + { unsafe 92 } + { async 92 } + { try 92 } + { 'label: 92 } +} diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.rast deleted file mode 100644 index f3a5e3096..000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.rast +++ /dev/null @@ -1,21 +0,0 @@ -SOURCE_FILE@0..21 - FN_DEF@0..20 - FN_KW@0..2 "fn" - WHITESPACE@2..3 " " - NAME@3..6 - IDENT@3..6 "foo" - PARAM_LIST@6..8 - L_PAREN@6..7 "(" - R_PAREN@7..8 ")" - WHITESPACE@8..9 " " - BLOCK_EXPR@9..20 - L_CURLY@9..10 "{" - WHITESPACE@10..15 "\n " - EXPR_STMT@15..18 - BLOCK_EXPR@15..17 - L_CURLY@15..16 "{" - R_CURLY@16..17 "}" - SEMICOLON@17..18 ";" - WHITESPACE@18..19 "\n" - R_CURLY@19..20 "}" - WHITESPACE@20..21 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.rs b/crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.rs deleted file mode 100644 index 9c6019fb1..000000000 --- a/crates/ra_syntax/test_data/parser/inline/ok/0105_block_expr.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn foo() { - {}; -} -- cgit v1.2.3