diff options
6 files changed, 226 insertions, 6 deletions
diff --git a/crates/ra_syntax/src/grammar/expressions.rs b/crates/ra_syntax/src/grammar/expressions.rs index 2236555e0..7ee32fa7c 100644 --- a/crates/ra_syntax/src/grammar/expressions.rs +++ b/crates/ra_syntax/src/grammar/expressions.rs | |||
@@ -305,6 +305,8 @@ fn postfix_expr( | |||
305 | // fn foo() { | 305 | // fn foo() { |
306 | // let _ = f(); | 306 | // let _ = f(); |
307 | // let _ = f()(1)(1, 2,); | 307 | // let _ = f()(1)(1, 2,); |
308 | // let _ = f(<Foo>::func()); | ||
309 | // f(<Foo as Trait>::func()); | ||
308 | // } | 310 | // } |
309 | fn call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { | 311 | fn call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker { |
310 | assert!(p.at(L_PAREN)); | 312 | assert!(p.at(L_PAREN)); |
diff --git a/crates/ra_syntax/src/grammar/expressions/atom.rs b/crates/ra_syntax/src/grammar/expressions/atom.rs index 167a76551..5feca090c 100644 --- a/crates/ra_syntax/src/grammar/expressions/atom.rs +++ b/crates/ra_syntax/src/grammar/expressions/atom.rs | |||
@@ -40,6 +40,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet = LITERAL_FIRST.union(token_set![ | |||
40 | L_PAREN, | 40 | L_PAREN, |
41 | L_CURLY, | 41 | L_CURLY, |
42 | L_BRACK, | 42 | L_BRACK, |
43 | L_ANGLE, // Universal function call syntax | ||
43 | PIPE, | 44 | PIPE, |
44 | MOVE_KW, | 45 | MOVE_KW, |
45 | IF_KW, | 46 | IF_KW, |
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0042_call_expr.rs b/crates/ra_syntax/tests/data/parser/inline/ok/0042_call_expr.rs index 0c9a20718..ffbf46d6d 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0042_call_expr.rs +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0042_call_expr.rs | |||
@@ -1,4 +1,6 @@ | |||
1 | fn foo() { | 1 | fn foo() { |
2 | let _ = f(); | 2 | let _ = f(); |
3 | let _ = f()(1)(1, 2,); | 3 | let _ = f()(1)(1, 2,); |
4 | let _ = f(<Foo>::func()); | ||
5 | f(<Foo as Trait>::func()); | ||
4 | } | 6 | } |
diff --git a/crates/ra_syntax/tests/data/parser/inline/ok/0042_call_expr.txt b/crates/ra_syntax/tests/data/parser/inline/ok/0042_call_expr.txt index 6364dc73c..0ddf393f2 100644 --- a/crates/ra_syntax/tests/data/parser/inline/ok/0042_call_expr.txt +++ b/crates/ra_syntax/tests/data/parser/inline/ok/0042_call_expr.txt | |||
@@ -1,5 +1,5 @@ | |||
1 | SOURCE_FILE@[0; 57) | 1 | SOURCE_FILE@[0; 118) |
2 | FN_DEF@[0; 56) | 2 | FN_DEF@[0; 117) |
3 | FN_KW@[0; 2) | 3 | FN_KW@[0; 2) |
4 | WHITESPACE@[2; 3) | 4 | WHITESPACE@[2; 3) |
5 | NAME@[3; 6) | 5 | NAME@[3; 6) |
@@ -8,7 +8,7 @@ SOURCE_FILE@[0; 57) | |||
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@[9; 56) | 11 | BLOCK@[9; 117) |
12 | L_CURLY@[9; 10) | 12 | L_CURLY@[9; 10) |
13 | WHITESPACE@[10; 15) | 13 | WHITESPACE@[10; 15) |
14 | LET_STMT@[15; 27) | 14 | LET_STMT@[15; 27) |
@@ -65,6 +65,83 @@ SOURCE_FILE@[0; 57) | |||
65 | COMMA@[51; 52) | 65 | COMMA@[51; 52) |
66 | R_PAREN@[52; 53) | 66 | R_PAREN@[52; 53) |
67 | SEMI@[53; 54) | 67 | SEMI@[53; 54) |
68 | WHITESPACE@[54; 55) | 68 | WHITESPACE@[54; 59) |
69 | R_CURLY@[55; 56) | 69 | LET_STMT@[59; 84) |
70 | WHITESPACE@[56; 57) | 70 | LET_KW@[59; 62) |
71 | WHITESPACE@[62; 63) | ||
72 | PLACEHOLDER_PAT@[63; 64) | ||
73 | UNDERSCORE@[63; 64) | ||
74 | WHITESPACE@[64; 65) | ||
75 | EQ@[65; 66) | ||
76 | WHITESPACE@[66; 67) | ||
77 | CALL_EXPR@[67; 83) | ||
78 | PATH_EXPR@[67; 68) | ||
79 | PATH@[67; 68) | ||
80 | PATH_SEGMENT@[67; 68) | ||
81 | NAME_REF@[67; 68) | ||
82 | IDENT@[67; 68) "f" | ||
83 | ARG_LIST@[68; 83) | ||
84 | L_PAREN@[68; 69) | ||
85 | CALL_EXPR@[69; 82) | ||
86 | PATH_EXPR@[69; 80) | ||
87 | PATH@[69; 80) | ||
88 | PATH@[69; 74) | ||
89 | PATH_SEGMENT@[69; 74) | ||
90 | L_ANGLE@[69; 70) | ||
91 | PATH_TYPE@[70; 73) | ||
92 | PATH@[70; 73) | ||
93 | PATH_SEGMENT@[70; 73) | ||
94 | NAME_REF@[70; 73) | ||
95 | IDENT@[70; 73) "Foo" | ||
96 | R_ANGLE@[73; 74) | ||
97 | COLONCOLON@[74; 76) | ||
98 | PATH_SEGMENT@[76; 80) | ||
99 | NAME_REF@[76; 80) | ||
100 | IDENT@[76; 80) "func" | ||
101 | ARG_LIST@[80; 82) | ||
102 | L_PAREN@[80; 81) | ||
103 | R_PAREN@[81; 82) | ||
104 | R_PAREN@[82; 83) | ||
105 | SEMI@[83; 84) | ||
106 | WHITESPACE@[84; 89) | ||
107 | EXPR_STMT@[89; 115) | ||
108 | CALL_EXPR@[89; 114) | ||
109 | PATH_EXPR@[89; 90) | ||
110 | PATH@[89; 90) | ||
111 | PATH_SEGMENT@[89; 90) | ||
112 | NAME_REF@[89; 90) | ||
113 | IDENT@[89; 90) "f" | ||
114 | ARG_LIST@[90; 114) | ||
115 | L_PAREN@[90; 91) | ||
116 | CALL_EXPR@[91; 113) | ||
117 | PATH_EXPR@[91; 111) | ||
118 | PATH@[91; 111) | ||
119 | PATH@[91; 105) | ||
120 | PATH_SEGMENT@[91; 105) | ||
121 | L_ANGLE@[91; 92) | ||
122 | PATH_TYPE@[92; 95) | ||
123 | PATH@[92; 95) | ||
124 | PATH_SEGMENT@[92; 95) | ||
125 | NAME_REF@[92; 95) | ||
126 | IDENT@[92; 95) "Foo" | ||
127 | WHITESPACE@[95; 96) | ||
128 | AS_KW@[96; 98) | ||
129 | WHITESPACE@[98; 99) | ||
130 | PATH_TYPE@[99; 104) | ||
131 | PATH@[99; 104) | ||
132 | PATH_SEGMENT@[99; 104) | ||
133 | NAME_REF@[99; 104) | ||
134 | IDENT@[99; 104) "Trait" | ||
135 | R_ANGLE@[104; 105) | ||
136 | COLONCOLON@[105; 107) | ||
137 | PATH_SEGMENT@[107; 111) | ||
138 | NAME_REF@[107; 111) | ||
139 | IDENT@[107; 111) "func" | ||
140 | ARG_LIST@[111; 113) | ||
141 | L_PAREN@[111; 112) | ||
142 | R_PAREN@[112; 113) | ||
143 | R_PAREN@[113; 114) | ||
144 | SEMI@[114; 115) | ||
145 | WHITESPACE@[115; 116) | ||
146 | R_CURLY@[116; 117) | ||
147 | WHITESPACE@[117; 118) | ||
diff --git a/crates/ra_syntax/tests/data/parser/ok/0042_ufcs_call_list.rs b/crates/ra_syntax/tests/data/parser/ok/0042_ufcs_call_list.rs new file mode 100644 index 000000000..6c02e65ed --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0042_ufcs_call_list.rs | |||
@@ -0,0 +1,15 @@ | |||
1 | // https://github.com/rust-analyzer/rust-analyzer/issues/596 | ||
2 | |||
3 | struct Foo; | ||
4 | |||
5 | impl Foo { | ||
6 | fn bar() -> bool { | ||
7 | unimplemented!() | ||
8 | } | ||
9 | } | ||
10 | |||
11 | fn baz(_: bool) {} | ||
12 | |||
13 | fn main() { | ||
14 | baz(<Foo>::bar()) | ||
15 | } | ||
diff --git a/crates/ra_syntax/tests/data/parser/ok/0042_ufcs_call_list.txt b/crates/ra_syntax/tests/data/parser/ok/0042_ufcs_call_list.txt new file mode 100644 index 000000000..d1d890e50 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0042_ufcs_call_list.txt | |||
@@ -0,0 +1,123 @@ | |||
1 | SOURCE_FILE@[0; 199) | ||
2 | COMMENT@[0; 60) | ||
3 | WHITESPACE@[60; 62) | ||
4 | STRUCT_DEF@[62; 73) | ||
5 | STRUCT_KW@[62; 68) | ||
6 | WHITESPACE@[68; 69) | ||
7 | NAME@[69; 72) | ||
8 | IDENT@[69; 72) "Foo" | ||
9 | SEMI@[72; 73) | ||
10 | WHITESPACE@[73; 75) | ||
11 | IMPL_BLOCK@[75; 141) | ||
12 | IMPL_KW@[75; 79) | ||
13 | WHITESPACE@[79; 80) | ||
14 | PATH_TYPE@[80; 83) | ||
15 | PATH@[80; 83) | ||
16 | PATH_SEGMENT@[80; 83) | ||
17 | NAME_REF@[80; 83) | ||
18 | IDENT@[80; 83) "Foo" | ||
19 | WHITESPACE@[83; 84) | ||
20 | ITEM_LIST@[84; 141) | ||
21 | L_CURLY@[84; 85) | ||
22 | WHITESPACE@[85; 90) | ||
23 | FN_DEF@[90; 139) | ||
24 | FN_KW@[90; 92) | ||
25 | WHITESPACE@[92; 93) | ||
26 | NAME@[93; 96) | ||
27 | IDENT@[93; 96) "bar" | ||
28 | PARAM_LIST@[96; 98) | ||
29 | L_PAREN@[96; 97) | ||
30 | R_PAREN@[97; 98) | ||
31 | WHITESPACE@[98; 99) | ||
32 | RET_TYPE@[99; 106) | ||
33 | THIN_ARROW@[99; 101) | ||
34 | WHITESPACE@[101; 102) | ||
35 | PATH_TYPE@[102; 106) | ||
36 | PATH@[102; 106) | ||
37 | PATH_SEGMENT@[102; 106) | ||
38 | NAME_REF@[102; 106) | ||
39 | IDENT@[102; 106) "bool" | ||
40 | WHITESPACE@[106; 107) | ||
41 | BLOCK@[107; 139) | ||
42 | L_CURLY@[107; 108) | ||
43 | WHITESPACE@[108; 117) | ||
44 | MACRO_CALL@[117; 133) | ||
45 | PATH@[117; 130) | ||
46 | PATH_SEGMENT@[117; 130) | ||
47 | NAME_REF@[117; 130) | ||
48 | IDENT@[117; 130) "unimplemented" | ||
49 | EXCL@[130; 131) | ||
50 | TOKEN_TREE@[131; 133) | ||
51 | L_PAREN@[131; 132) | ||
52 | R_PAREN@[132; 133) | ||
53 | WHITESPACE@[133; 138) | ||
54 | R_CURLY@[138; 139) | ||
55 | WHITESPACE@[139; 140) | ||
56 | R_CURLY@[140; 141) | ||
57 | WHITESPACE@[141; 143) | ||
58 | FN_DEF@[143; 161) | ||
59 | FN_KW@[143; 145) | ||
60 | WHITESPACE@[145; 146) | ||
61 | NAME@[146; 149) | ||
62 | IDENT@[146; 149) "baz" | ||
63 | PARAM_LIST@[149; 158) | ||
64 | L_PAREN@[149; 150) | ||
65 | PARAM@[150; 157) | ||
66 | PLACEHOLDER_PAT@[150; 151) | ||
67 | UNDERSCORE@[150; 151) | ||
68 | COLON@[151; 152) | ||
69 | WHITESPACE@[152; 153) | ||
70 | PATH_TYPE@[153; 157) | ||
71 | PATH@[153; 157) | ||
72 | PATH_SEGMENT@[153; 157) | ||
73 | NAME_REF@[153; 157) | ||
74 | IDENT@[153; 157) "bool" | ||
75 | R_PAREN@[157; 158) | ||
76 | WHITESPACE@[158; 159) | ||
77 | BLOCK@[159; 161) | ||
78 | L_CURLY@[159; 160) | ||
79 | R_CURLY@[160; 161) | ||
80 | WHITESPACE@[161; 163) | ||
81 | FN_DEF@[163; 198) | ||
82 | FN_KW@[163; 165) | ||
83 | WHITESPACE@[165; 166) | ||
84 | NAME@[166; 170) | ||
85 | IDENT@[166; 170) "main" | ||
86 | PARAM_LIST@[170; 172) | ||
87 | L_PAREN@[170; 171) | ||
88 | R_PAREN@[171; 172) | ||
89 | WHITESPACE@[172; 173) | ||
90 | BLOCK@[173; 198) | ||
91 | L_CURLY@[173; 174) | ||
92 | WHITESPACE@[174; 179) | ||
93 | CALL_EXPR@[179; 196) | ||
94 | PATH_EXPR@[179; 182) | ||
95 | PATH@[179; 182) | ||
96 | PATH_SEGMENT@[179; 182) | ||
97 | NAME_REF@[179; 182) | ||
98 | IDENT@[179; 182) "baz" | ||
99 | ARG_LIST@[182; 196) | ||
100 | L_PAREN@[182; 183) | ||
101 | CALL_EXPR@[183; 195) | ||
102 | PATH_EXPR@[183; 193) | ||
103 | PATH@[183; 193) | ||
104 | PATH@[183; 188) | ||
105 | PATH_SEGMENT@[183; 188) | ||
106 | L_ANGLE@[183; 184) | ||
107 | PATH_TYPE@[184; 187) | ||
108 | PATH@[184; 187) | ||
109 | PATH_SEGMENT@[184; 187) | ||
110 | NAME_REF@[184; 187) | ||
111 | IDENT@[184; 187) "Foo" | ||
112 | R_ANGLE@[187; 188) | ||
113 | COLONCOLON@[188; 190) | ||
114 | PATH_SEGMENT@[190; 193) | ||
115 | NAME_REF@[190; 193) | ||
116 | IDENT@[190; 193) "bar" | ||
117 | ARG_LIST@[193; 195) | ||
118 | L_PAREN@[193; 194) | ||
119 | R_PAREN@[194; 195) | ||
120 | R_PAREN@[195; 196) | ||
121 | WHITESPACE@[196; 197) | ||
122 | R_CURLY@[197; 198) | ||
123 | WHITESPACE@[198; 199) | ||