From 623faefcda3536185232be1676709b0233bb10ba Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 2 May 2020 01:57:21 +0200 Subject: Cleanup inline tests --- crates/ra_parser/src/grammar/expressions/atom.rs | 6 ++-- .../parser/inline/ok/0105_block_expr.rast | 32 ++++------------------ .../test_data/parser/inline/ok/0105_block_expr.rs | 2 -- .../inline/ok/0127_attr_on_last_expr_in_block.rast | 2 +- .../parser/inline/ok/0137_await_expr.rast | 2 +- .../parser/inline/ok/0161_labeled_block.rast | 26 ++++++++++++++++++ .../parser/inline/ok/0161_labeled_block.rs | 1 + .../parser/inline/ok/0162_unsafe_block.rast | 23 ++++++++++++++++ .../parser/inline/ok/0162_unsafe_block.rs | 1 + 9 files changed, 63 insertions(+), 32 deletions(-) create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rast create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rs create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rast create mode 100644 crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rs diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index c76b7330c..efb424dae 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs @@ -92,6 +92,8 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar T![loop] => loop_expr(p, Some(m)), T![for] => for_expr(p, Some(m)), T![while] => while_expr(p, Some(m)), + // test labeled_block + // fn f() { 'label: {}; } T!['{'] => { block_expr(p); m.complete(p, EFFECT_EXPR) @@ -115,6 +117,8 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar m.complete(p, EFFECT_EXPR) } T![match] => match_expr(p), + // test unsafe_block + // fn f() { unsafe { } } T![unsafe] if la == T!['{'] => { let m = p.start(); p.bump(T![unsafe]); @@ -466,8 +470,6 @@ fn match_guard(p: &mut Parser) -> CompletedMarker { // test block_expr // fn foo() { // {}; -// unsafe {}; -// 'label: {}; // } pub(super) fn block_expr(p: &mut Parser) -> CompletedMarker { assert!(p.at(T!['{'])); 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 index fa3c9db9f..f3a5e3096 100644 --- 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 @@ -1,5 +1,5 @@ -SOURCE_FILE@0..52 - FN_DEF@0..51 +SOURCE_FILE@0..21 + FN_DEF@0..20 FN_KW@0..2 "fn" WHITESPACE@2..3 " " NAME@3..6 @@ -8,7 +8,7 @@ SOURCE_FILE@0..52 L_PAREN@6..7 "(" R_PAREN@7..8 ")" WHITESPACE@8..9 " " - BLOCK_EXPR@9..51 + BLOCK_EXPR@9..20 L_CURLY@9..10 "{" WHITESPACE@10..15 "\n " EXPR_STMT@15..18 @@ -16,26 +16,6 @@ SOURCE_FILE@0..52 L_CURLY@15..16 "{" R_CURLY@16..17 "}" SEMICOLON@17..18 ";" - WHITESPACE@18..23 "\n " - EXPR_STMT@23..33 - EFFECT_EXPR@23..32 - UNSAFE_KW@23..29 "unsafe" - WHITESPACE@29..30 " " - BLOCK_EXPR@30..32 - L_CURLY@30..31 "{" - R_CURLY@31..32 "}" - SEMICOLON@32..33 ";" - WHITESPACE@33..38 "\n " - EXPR_STMT@38..49 - EFFECT_EXPR@38..48 - LABEL@38..45 - LIFETIME@38..44 "\'label" - COLON@44..45 ":" - WHITESPACE@45..46 " " - BLOCK_EXPR@46..48 - L_CURLY@46..47 "{" - R_CURLY@47..48 "}" - SEMICOLON@48..49 ";" - WHITESPACE@49..50 "\n" - R_CURLY@50..51 "}" - WHITESPACE@51..52 "\n" + 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 index 2fed74c5e..9c6019fb1 100644 --- 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 @@ -1,5 +1,3 @@ fn foo() { {}; - unsafe {}; - 'label: {}; } diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast b/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast index aabcd422f..93cc41533 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0127_attr_on_last_expr_in_block.rast @@ -15,7 +15,7 @@ SOURCE_FILE@0..47 BLOCK_EXPR@15..31 L_CURLY@15..16 "{" WHITESPACE@16..17 " " - EFFECT_EXPR@17..29 + TRY_EXPR@17..29 ATTR@17..21 POUND@17..18 "#" L_BRACK@18..19 "[" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast b/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast index b3ab326e3..8e8d9e992 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0137_await_expr.rast @@ -39,7 +39,7 @@ SOURCE_FILE@0..67 WHITESPACE@38..43 "\n " EXPR_STMT@43..64 METHOD_CALL_EXPR@43..63 - EFFECT_EXPR@43..55 + TRY_EXPR@43..55 AWAIT_EXPR@43..54 CALL_EXPR@43..48 FIELD_EXPR@43..46 diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rast b/crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rast new file mode 100644 index 000000000..9efebd8b8 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rast @@ -0,0 +1,26 @@ +SOURCE_FILE@0..23 + FN_DEF@0..22 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..4 + IDENT@3..4 "f" + PARAM_LIST@4..6 + L_PAREN@4..5 "(" + R_PAREN@5..6 ")" + WHITESPACE@6..7 " " + BLOCK_EXPR@7..22 + L_CURLY@7..8 "{" + WHITESPACE@8..9 " " + EXPR_STMT@9..20 + EFFECT_EXPR@9..19 + LABEL@9..16 + LIFETIME@9..15 "\'label" + COLON@15..16 ":" + WHITESPACE@16..17 " " + BLOCK_EXPR@17..19 + L_CURLY@17..18 "{" + R_CURLY@18..19 "}" + SEMICOLON@19..20 ";" + WHITESPACE@20..21 " " + R_CURLY@21..22 "}" + WHITESPACE@22..23 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rs b/crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rs new file mode 100644 index 000000000..18b4ff4b1 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0161_labeled_block.rs @@ -0,0 +1 @@ +fn f() { 'label: {}; } diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rast b/crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rast new file mode 100644 index 000000000..4991f2c36 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rast @@ -0,0 +1,23 @@ +SOURCE_FILE@0..22 + FN_DEF@0..21 + FN_KW@0..2 "fn" + WHITESPACE@2..3 " " + NAME@3..4 + IDENT@3..4 "f" + PARAM_LIST@4..6 + L_PAREN@4..5 "(" + R_PAREN@5..6 ")" + WHITESPACE@6..7 " " + BLOCK_EXPR@7..21 + L_CURLY@7..8 "{" + WHITESPACE@8..9 " " + EFFECT_EXPR@9..19 + UNSAFE_KW@9..15 "unsafe" + WHITESPACE@15..16 " " + BLOCK_EXPR@16..19 + L_CURLY@16..17 "{" + WHITESPACE@17..18 " " + R_CURLY@18..19 "}" + WHITESPACE@19..20 " " + R_CURLY@20..21 "}" + WHITESPACE@21..22 "\n" diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rs b/crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rs new file mode 100644 index 000000000..dfb9b2a1c --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0162_unsafe_block.rs @@ -0,0 +1 @@ +fn f() { unsafe { } } -- cgit v1.2.3