diff options
Diffstat (limited to 'crates/ra_syntax')
8 files changed, 193 insertions, 141 deletions
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rs b/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rs index 1080b48a1..f1c3f7118 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rs +++ b/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.rs | |||
@@ -1,9 +1,5 @@ | |||
1 | fn foo() { | 1 | fn foo() { |
2 | **&1 + 1; | 2 | **&1; |
3 | !!true; | 3 | !!true; |
4 | --1; | 4 | --1; |
5 | *&1 as u64; | ||
6 | *x(1); | ||
7 | &x[1]; | ||
8 | -1..2; | ||
9 | } | 5 | } |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.txt index e2b60d99f..2d71efd86 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0019_unary_expr.txt | |||
@@ -1,5 +1,5 @@ | |||
1 | SOURCE_FILE@[0; 97) | 1 | SOURCE_FILE@[0; 44) |
2 | FN_DEF@[0; 96) | 2 | FN_DEF@[0; 43) |
3 | FN_KW@[0; 2) "fn" | 3 | FN_KW@[0; 2) "fn" |
4 | WHITESPACE@[2; 3) " " | 4 | WHITESPACE@[2; 3) " " |
5 | NAME@[3; 6) | 5 | NAME@[3; 6) |
@@ -8,104 +8,38 @@ SOURCE_FILE@[0; 97) | |||
8 | L_PAREN@[6; 7) "(" | 8 | L_PAREN@[6; 7) "(" |
9 | R_PAREN@[7; 8) ")" | 9 | R_PAREN@[7; 8) ")" |
10 | WHITESPACE@[8; 9) " " | 10 | WHITESPACE@[8; 9) " " |
11 | BLOCK_EXPR@[9; 96) | 11 | BLOCK_EXPR@[9; 43) |
12 | BLOCK@[9; 96) | 12 | BLOCK@[9; 43) |
13 | L_CURLY@[9; 10) "{" | 13 | L_CURLY@[9; 10) "{" |
14 | WHITESPACE@[10; 15) "\n " | 14 | WHITESPACE@[10; 15) "\n " |
15 | EXPR_STMT@[15; 24) | 15 | EXPR_STMT@[15; 20) |
16 | BIN_EXPR@[15; 23) | 16 | PREFIX_EXPR@[15; 19) |
17 | PREFIX_EXPR@[15; 19) | 17 | STAR@[15; 16) "*" |
18 | STAR@[15; 16) "*" | 18 | PREFIX_EXPR@[16; 19) |
19 | PREFIX_EXPR@[16; 19) | 19 | STAR@[16; 17) "*" |
20 | STAR@[16; 17) "*" | 20 | REF_EXPR@[17; 19) |
21 | REF_EXPR@[17; 19) | 21 | AMP@[17; 18) "&" |
22 | AMP@[17; 18) "&" | 22 | LITERAL@[18; 19) |
23 | LITERAL@[18; 19) | 23 | INT_NUMBER@[18; 19) "1" |
24 | INT_NUMBER@[18; 19) "1" | 24 | SEMI@[19; 20) ";" |
25 | WHITESPACE@[19; 20) " " | 25 | WHITESPACE@[20; 25) "\n " |
26 | PLUS@[20; 21) "+" | 26 | EXPR_STMT@[25; 32) |
27 | WHITESPACE@[21; 22) " " | 27 | PREFIX_EXPR@[25; 31) |
28 | LITERAL@[22; 23) | 28 | EXCL@[25; 26) "!" |
29 | INT_NUMBER@[22; 23) "1" | 29 | PREFIX_EXPR@[26; 31) |
30 | SEMI@[23; 24) ";" | 30 | EXCL@[26; 27) "!" |
31 | WHITESPACE@[24; 29) "\n " | 31 | LITERAL@[27; 31) |
32 | EXPR_STMT@[29; 36) | 32 | TRUE_KW@[27; 31) "true" |
33 | PREFIX_EXPR@[29; 35) | 33 | SEMI@[31; 32) ";" |
34 | EXCL@[29; 30) "!" | 34 | WHITESPACE@[32; 37) "\n " |
35 | PREFIX_EXPR@[30; 35) | 35 | EXPR_STMT@[37; 41) |
36 | EXCL@[30; 31) "!" | 36 | PREFIX_EXPR@[37; 40) |
37 | LITERAL@[31; 35) | 37 | MINUS@[37; 38) "-" |
38 | TRUE_KW@[31; 35) "true" | 38 | PREFIX_EXPR@[38; 40) |
39 | SEMI@[35; 36) ";" | 39 | MINUS@[38; 39) "-" |
40 | WHITESPACE@[36; 41) "\n " | 40 | LITERAL@[39; 40) |
41 | EXPR_STMT@[41; 45) | 41 | INT_NUMBER@[39; 40) "1" |
42 | PREFIX_EXPR@[41; 44) | 42 | SEMI@[40; 41) ";" |
43 | MINUS@[41; 42) "-" | 43 | WHITESPACE@[41; 42) "\n" |
44 | PREFIX_EXPR@[42; 44) | 44 | R_CURLY@[42; 43) "}" |
45 | MINUS@[42; 43) "-" | 45 | WHITESPACE@[43; 44) "\n" |
46 | LITERAL@[43; 44) | ||
47 | INT_NUMBER@[43; 44) "1" | ||
48 | SEMI@[44; 45) ";" | ||
49 | WHITESPACE@[45; 50) "\n " | ||
50 | EXPR_STMT@[50; 61) | ||
51 | CAST_EXPR@[50; 60) | ||
52 | PREFIX_EXPR@[50; 53) | ||
53 | STAR@[50; 51) "*" | ||
54 | REF_EXPR@[51; 53) | ||
55 | AMP@[51; 52) "&" | ||
56 | LITERAL@[52; 53) | ||
57 | INT_NUMBER@[52; 53) "1" | ||
58 | WHITESPACE@[53; 54) " " | ||
59 | AS_KW@[54; 56) "as" | ||
60 | WHITESPACE@[56; 57) " " | ||
61 | PATH_TYPE@[57; 60) | ||
62 | PATH@[57; 60) | ||
63 | PATH_SEGMENT@[57; 60) | ||
64 | NAME_REF@[57; 60) | ||
65 | IDENT@[57; 60) "u64" | ||
66 | SEMI@[60; 61) ";" | ||
67 | WHITESPACE@[61; 66) "\n " | ||
68 | EXPR_STMT@[66; 72) | ||
69 | PREFIX_EXPR@[66; 71) | ||
70 | STAR@[66; 67) "*" | ||
71 | CALL_EXPR@[67; 71) | ||
72 | PATH_EXPR@[67; 68) | ||
73 | PATH@[67; 68) | ||
74 | PATH_SEGMENT@[67; 68) | ||
75 | NAME_REF@[67; 68) | ||
76 | IDENT@[67; 68) "x" | ||
77 | ARG_LIST@[68; 71) | ||
78 | L_PAREN@[68; 69) "(" | ||
79 | LITERAL@[69; 70) | ||
80 | INT_NUMBER@[69; 70) "1" | ||
81 | R_PAREN@[70; 71) ")" | ||
82 | SEMI@[71; 72) ";" | ||
83 | WHITESPACE@[72; 77) "\n " | ||
84 | EXPR_STMT@[77; 83) | ||
85 | REF_EXPR@[77; 82) | ||
86 | AMP@[77; 78) "&" | ||
87 | INDEX_EXPR@[78; 82) | ||
88 | PATH_EXPR@[78; 79) | ||
89 | PATH@[78; 79) | ||
90 | PATH_SEGMENT@[78; 79) | ||
91 | NAME_REF@[78; 79) | ||
92 | IDENT@[78; 79) "x" | ||
93 | L_BRACK@[79; 80) "[" | ||
94 | LITERAL@[80; 81) | ||
95 | INT_NUMBER@[80; 81) "1" | ||
96 | R_BRACK@[81; 82) "]" | ||
97 | SEMI@[82; 83) ";" | ||
98 | WHITESPACE@[83; 88) "\n " | ||
99 | EXPR_STMT@[88; 94) | ||
100 | RANGE_EXPR@[88; 93) | ||
101 | PREFIX_EXPR@[88; 90) | ||
102 | MINUS@[88; 89) "-" | ||
103 | LITERAL@[89; 90) | ||
104 | INT_NUMBER@[89; 90) "1" | ||
105 | DOTDOT@[90; 92) ".." | ||
106 | LITERAL@[92; 93) | ||
107 | INT_NUMBER@[92; 93) "2" | ||
108 | SEMI@[93; 94) ";" | ||
109 | WHITESPACE@[94; 95) "\n" | ||
110 | R_CURLY@[95; 96) "}" | ||
111 | WHITESPACE@[96; 97) "\n" | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rs b/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rs index 050638f56..2dac6be95 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rs +++ b/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.rs | |||
@@ -1,5 +1,4 @@ | |||
1 | fn foo() { | 1 | fn foo() { |
2 | let _ = &1; | 2 | let _ = &1; |
3 | let _ = &mut &f(); | 3 | let _ = &mut &f(); |
4 | let _ = &1 as *const i32; | ||
5 | } | 4 | } |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.txt b/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.txt index d6334e55b..8f34afe76 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0082_ref_expr.txt | |||
@@ -1,5 +1,5 @@ | |||
1 | SOURCE_FILE@[0; 82) | 1 | SOURCE_FILE@[0; 52) |
2 | FN_DEF@[0; 81) | 2 | FN_DEF@[0; 51) |
3 | FN_KW@[0; 2) "fn" | 3 | FN_KW@[0; 2) "fn" |
4 | WHITESPACE@[2; 3) " " | 4 | WHITESPACE@[2; 3) " " |
5 | NAME@[3; 6) | 5 | NAME@[3; 6) |
@@ -8,8 +8,8 @@ SOURCE_FILE@[0; 82) | |||
8 | L_PAREN@[6; 7) "(" | 8 | L_PAREN@[6; 7) "(" |
9 | R_PAREN@[7; 8) ")" | 9 | R_PAREN@[7; 8) ")" |
10 | WHITESPACE@[8; 9) " " | 10 | WHITESPACE@[8; 9) " " |
11 | BLOCK_EXPR@[9; 81) | 11 | BLOCK_EXPR@[9; 51) |
12 | BLOCK@[9; 81) | 12 | BLOCK@[9; 51) |
13 | L_CURLY@[9; 10) "{" | 13 | L_CURLY@[9; 10) "{" |
14 | WHITESPACE@[10; 15) "\n " | 14 | WHITESPACE@[10; 15) "\n " |
15 | LET_STMT@[15; 26) | 15 | LET_STMT@[15; 26) |
@@ -50,33 +50,6 @@ SOURCE_FILE@[0; 82) | |||
50 | L_PAREN@[46; 47) "(" | 50 | L_PAREN@[46; 47) "(" |
51 | R_PAREN@[47; 48) ")" | 51 | R_PAREN@[47; 48) ")" |
52 | SEMI@[48; 49) ";" | 52 | SEMI@[48; 49) ";" |
53 | WHITESPACE@[49; 54) "\n " | 53 | WHITESPACE@[49; 50) "\n" |
54 | LET_STMT@[54; 79) | 54 | R_CURLY@[50; 51) "}" |
55 | LET_KW@[54; 57) "let" | 55 | WHITESPACE@[51; 52) "\n" |
56 | WHITESPACE@[57; 58) " " | ||
57 | PLACEHOLDER_PAT@[58; 59) | ||
58 | UNDERSCORE@[58; 59) "_" | ||
59 | WHITESPACE@[59; 60) " " | ||
60 | EQ@[60; 61) "=" | ||
61 | WHITESPACE@[61; 62) " " | ||
62 | CAST_EXPR@[62; 78) | ||
63 | REF_EXPR@[62; 64) | ||
64 | AMP@[62; 63) "&" | ||
65 | LITERAL@[63; 64) | ||
66 | INT_NUMBER@[63; 64) "1" | ||
67 | WHITESPACE@[64; 65) " " | ||
68 | AS_KW@[65; 67) "as" | ||
69 | WHITESPACE@[67; 68) " " | ||
70 | POINTER_TYPE@[68; 78) | ||
71 | STAR@[68; 69) "*" | ||
72 | CONST_KW@[69; 74) "const" | ||
73 | WHITESPACE@[74; 75) " " | ||
74 | PATH_TYPE@[75; 78) | ||
75 | PATH@[75; 78) | ||
76 | PATH_SEGMENT@[75; 78) | ||
77 | NAME_REF@[75; 78) | ||
78 | IDENT@[75; 78) "i32" | ||
79 | SEMI@[78; 79) ";" | ||
80 | WHITESPACE@[79; 80) "\n" | ||
81 | R_CURLY@[80; 81) "}" | ||
82 | WHITESPACE@[81; 82) "\n" | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rs b/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rs new file mode 100644 index 000000000..a06dec1fa --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.rs | |||
@@ -0,0 +1,3 @@ | |||
1 | fn foo() { | ||
2 | let _ = &1 as *const i32; | ||
3 | } | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.txt b/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.txt new file mode 100644 index 000000000..9e3767fb7 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/inline/ok/0146_as_precedence.txt | |||
@@ -0,0 +1,43 @@ | |||
1 | SOURCE_FILE@[0; 43) | ||
2 | FN_DEF@[0; 42) | ||
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_EXPR@[9; 42) | ||
12 | BLOCK@[9; 42) | ||
13 | L_CURLY@[9; 10) "{" | ||
14 | WHITESPACE@[10; 15) "\n " | ||
15 | LET_STMT@[15; 40) | ||
16 | LET_KW@[15; 18) "let" | ||
17 | WHITESPACE@[18; 19) " " | ||
18 | PLACEHOLDER_PAT@[19; 20) | ||
19 | UNDERSCORE@[19; 20) "_" | ||
20 | WHITESPACE@[20; 21) " " | ||
21 | EQ@[21; 22) "=" | ||
22 | WHITESPACE@[22; 23) " " | ||
23 | CAST_EXPR@[23; 39) | ||
24 | REF_EXPR@[23; 25) | ||
25 | AMP@[23; 24) "&" | ||
26 | LITERAL@[24; 25) | ||
27 | INT_NUMBER@[24; 25) "1" | ||
28 | WHITESPACE@[25; 26) " " | ||
29 | AS_KW@[26; 28) "as" | ||
30 | WHITESPACE@[28; 29) " " | ||
31 | POINTER_TYPE@[29; 39) | ||
32 | STAR@[29; 30) "*" | ||
33 | CONST_KW@[30; 35) "const" | ||
34 | WHITESPACE@[35; 36) " " | ||
35 | PATH_TYPE@[36; 39) | ||
36 | PATH@[36; 39) | ||
37 | PATH_SEGMENT@[36; 39) | ||
38 | NAME_REF@[36; 39) | ||
39 | IDENT@[36; 39) "i32" | ||
40 | SEMI@[39; 40) ";" | ||
41 | WHITESPACE@[40; 41) "\n" | ||
42 | R_CURLY@[41; 42) "}" | ||
43 | WHITESPACE@[42; 43) "\n" | ||
diff --git a/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rs b/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rs new file mode 100644 index 000000000..100fccc64 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.rs | |||
@@ -0,0 +1,7 @@ | |||
1 | fn foo() { | ||
2 | 1 + *&2 + 3; | ||
3 | *&1 as u64; | ||
4 | *x(1); | ||
5 | &x[1]; | ||
6 | -1..2; | ||
7 | } | ||
diff --git a/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.txt b/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.txt new file mode 100644 index 000000000..d30cb63ff --- /dev/null +++ b/crates/ra_syntax/test_data/parser/ok/0058_unary_expr_precedence.txt | |||
@@ -0,0 +1,97 @@ | |||
1 | SOURCE_FILE@[0; 79) | ||
2 | FN_DEF@[0; 78) | ||
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_EXPR@[9; 78) | ||
12 | BLOCK@[9; 78) | ||
13 | L_CURLY@[9; 10) "{" | ||
14 | WHITESPACE@[10; 15) "\n " | ||
15 | EXPR_STMT@[15; 27) | ||
16 | BIN_EXPR@[15; 26) | ||
17 | BIN_EXPR@[15; 22) | ||
18 | LITERAL@[15; 16) | ||
19 | INT_NUMBER@[15; 16) "1" | ||
20 | WHITESPACE@[16; 17) " " | ||
21 | PLUS@[17; 18) "+" | ||
22 | WHITESPACE@[18; 19) " " | ||
23 | PREFIX_EXPR@[19; 22) | ||
24 | STAR@[19; 20) "*" | ||
25 | REF_EXPR@[20; 22) | ||
26 | AMP@[20; 21) "&" | ||
27 | LITERAL@[21; 22) | ||
28 | INT_NUMBER@[21; 22) "2" | ||
29 | WHITESPACE@[22; 23) " " | ||
30 | PLUS@[23; 24) "+" | ||
31 | WHITESPACE@[24; 25) " " | ||
32 | LITERAL@[25; 26) | ||
33 | INT_NUMBER@[25; 26) "3" | ||
34 | SEMI@[26; 27) ";" | ||
35 | WHITESPACE@[27; 32) "\n " | ||
36 | EXPR_STMT@[32; 43) | ||
37 | CAST_EXPR@[32; 42) | ||
38 | PREFIX_EXPR@[32; 35) | ||
39 | STAR@[32; 33) "*" | ||
40 | REF_EXPR@[33; 35) | ||
41 | AMP@[33; 34) "&" | ||
42 | LITERAL@[34; 35) | ||
43 | INT_NUMBER@[34; 35) "1" | ||
44 | WHITESPACE@[35; 36) " " | ||
45 | AS_KW@[36; 38) "as" | ||
46 | WHITESPACE@[38; 39) " " | ||
47 | PATH_TYPE@[39; 42) | ||
48 | PATH@[39; 42) | ||
49 | PATH_SEGMENT@[39; 42) | ||
50 | NAME_REF@[39; 42) | ||
51 | IDENT@[39; 42) "u64" | ||
52 | SEMI@[42; 43) ";" | ||
53 | WHITESPACE@[43; 48) "\n " | ||
54 | EXPR_STMT@[48; 54) | ||
55 | PREFIX_EXPR@[48; 53) | ||
56 | STAR@[48; 49) "*" | ||
57 | CALL_EXPR@[49; 53) | ||
58 | PATH_EXPR@[49; 50) | ||
59 | PATH@[49; 50) | ||
60 | PATH_SEGMENT@[49; 50) | ||
61 | NAME_REF@[49; 50) | ||
62 | IDENT@[49; 50) "x" | ||
63 | ARG_LIST@[50; 53) | ||
64 | L_PAREN@[50; 51) "(" | ||
65 | LITERAL@[51; 52) | ||
66 | INT_NUMBER@[51; 52) "1" | ||
67 | R_PAREN@[52; 53) ")" | ||
68 | SEMI@[53; 54) ";" | ||
69 | WHITESPACE@[54; 59) "\n " | ||
70 | EXPR_STMT@[59; 65) | ||
71 | REF_EXPR@[59; 64) | ||
72 | AMP@[59; 60) "&" | ||
73 | INDEX_EXPR@[60; 64) | ||
74 | PATH_EXPR@[60; 61) | ||
75 | PATH@[60; 61) | ||
76 | PATH_SEGMENT@[60; 61) | ||
77 | NAME_REF@[60; 61) | ||
78 | IDENT@[60; 61) "x" | ||
79 | L_BRACK@[61; 62) "[" | ||
80 | LITERAL@[62; 63) | ||
81 | INT_NUMBER@[62; 63) "1" | ||
82 | R_BRACK@[63; 64) "]" | ||
83 | SEMI@[64; 65) ";" | ||
84 | WHITESPACE@[65; 70) "\n " | ||
85 | EXPR_STMT@[70; 76) | ||
86 | RANGE_EXPR@[70; 75) | ||
87 | PREFIX_EXPR@[70; 72) | ||
88 | MINUS@[70; 71) "-" | ||
89 | LITERAL@[71; 72) | ||
90 | INT_NUMBER@[71; 72) "1" | ||
91 | DOTDOT@[72; 74) ".." | ||
92 | LITERAL@[74; 75) | ||
93 | INT_NUMBER@[74; 75) "2" | ||
94 | SEMI@[75; 76) ";" | ||
95 | WHITESPACE@[76; 77) "\n" | ||
96 | R_CURLY@[77; 78) "}" | ||
97 | WHITESPACE@[78; 79) "\n" | ||