diff options
Diffstat (limited to 'crates')
3 files changed, 75 insertions, 0 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index 26f184785..b60a2f68c 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs | |||
@@ -359,6 +359,12 @@ fn lhs( | |||
359 | return Some((m.complete(p, RANGE_EXPR), BlockLike::NotBlock)); | 359 | return Some((m.complete(p, RANGE_EXPR), BlockLike::NotBlock)); |
360 | } | 360 | } |
361 | _ => { | 361 | _ => { |
362 | // test expression_after_block | ||
363 | // fn foo() { | ||
364 | // let mut p = F{x: 5}; | ||
365 | // {p}.x = 10; | ||
366 | // } | ||
367 | // | ||
362 | let (lhs, blocklike) = atom::atom_expr(p, r)?; | 368 | let (lhs, blocklike) = atom::atom_expr(p, r)?; |
363 | return Some(postfix_expr(p, lhs, blocklike, !(r.prefer_stmt && blocklike.is_block()))); | 369 | return Some(postfix_expr(p, lhs, blocklike, !(r.prefer_stmt && blocklike.is_block()))); |
364 | } | 370 | } |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rs b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rs new file mode 100644 index 000000000..76007e3ee --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.rs | |||
@@ -0,0 +1,4 @@ | |||
1 | fn foo() { | ||
2 | let mut p = F{x: 5}; | ||
3 | {p}.x = 10; | ||
4 | } | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.txt b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.txt new file mode 100644 index 000000000..08128f365 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0138_expression_after_block.txt | |||
@@ -0,0 +1,65 @@ | |||
1 | SOURCE_FILE@[0; 52) | ||
2 | FN_DEF@[0; 51) | ||
3 | FN_KW@[0; 2) "fn" | ||
4 | WHITESPACE@[2; 3) " " | ||
5 | NAME@[3; 6) | ||
6 | IDENT@[3; 6) "foo" | ||
7 | PARAM_LIST@[6; 8) | ||
8 | L_PAREN@[6; 7) "(" | ||
9 | R_PAREN@[7; 8) ")" | ||
10 | WHITESPACE@[8; 9) " " | ||
11 | BLOCK@[9; 51) | ||
12 | L_CURLY@[9; 10) "{" | ||
13 | WHITESPACE@[10; 14) "\n " | ||
14 | LET_STMT@[14; 34) | ||
15 | LET_KW@[14; 17) "let" | ||
16 | WHITESPACE@[17; 18) " " | ||
17 | BIND_PAT@[18; 23) | ||
18 | MUT_KW@[18; 21) "mut" | ||
19 | WHITESPACE@[21; 22) " " | ||
20 | NAME@[22; 23) | ||
21 | IDENT@[22; 23) "p" | ||
22 | WHITESPACE@[23; 24) " " | ||
23 | EQ@[24; 25) "=" | ||
24 | WHITESPACE@[25; 26) " " | ||
25 | STRUCT_LIT@[26; 33) | ||
26 | PATH@[26; 27) | ||
27 | PATH_SEGMENT@[26; 27) | ||
28 | NAME_REF@[26; 27) | ||
29 | IDENT@[26; 27) "F" | ||
30 | NAMED_FIELD_LIST@[27; 33) | ||
31 | L_CURLY@[27; 28) "{" | ||
32 | NAMED_FIELD@[28; 32) | ||
33 | NAME_REF@[28; 29) | ||
34 | IDENT@[28; 29) "x" | ||
35 | COLON@[29; 30) ":" | ||
36 | WHITESPACE@[30; 31) " " | ||
37 | LITERAL@[31; 32) | ||
38 | INT_NUMBER@[31; 32) "5" | ||
39 | R_CURLY@[32; 33) "}" | ||
40 | SEMI@[33; 34) ";" | ||
41 | WHITESPACE@[34; 38) "\n " | ||
42 | EXPR_STMT@[38; 49) | ||
43 | BIN_EXPR@[38; 48) | ||
44 | FIELD_EXPR@[38; 43) | ||
45 | BLOCK_EXPR@[38; 41) | ||
46 | BLOCK@[38; 41) | ||
47 | L_CURLY@[38; 39) "{" | ||
48 | PATH_EXPR@[39; 40) | ||
49 | PATH@[39; 40) | ||
50 | PATH_SEGMENT@[39; 40) | ||
51 | NAME_REF@[39; 40) | ||
52 | IDENT@[39; 40) "p" | ||
53 | R_CURLY@[40; 41) "}" | ||
54 | DOT@[41; 42) "." | ||
55 | NAME_REF@[42; 43) | ||
56 | IDENT@[42; 43) "x" | ||
57 | WHITESPACE@[43; 44) " " | ||
58 | EQ@[44; 45) "=" | ||
59 | WHITESPACE@[45; 46) " " | ||
60 | LITERAL@[46; 48) | ||
61 | INT_NUMBER@[46; 48) "10" | ||
62 | SEMI@[48; 49) ";" | ||
63 | WHITESPACE@[49; 50) "\n" | ||
64 | R_CURLY@[50; 51) "}" | ||
65 | WHITESPACE@[51; 52) "\n" | ||