diff options
Diffstat (limited to 'crates')
3 files changed, 218 insertions, 0 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index 70c71a8e1..0df57afa7 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs | |||
@@ -155,6 +155,7 @@ fn current_op(p: &Parser) -> (u8, Op) { | |||
155 | (PLUS, EQ) => return (1, Op::Composite(PLUSEQ, 2)), | 155 | (PLUS, EQ) => return (1, Op::Composite(PLUSEQ, 2)), |
156 | (MINUS, EQ) => return (1, Op::Composite(MINUSEQ, 2)), | 156 | (MINUS, EQ) => return (1, Op::Composite(MINUSEQ, 2)), |
157 | (STAR, EQ) => return (1, Op::Composite(STAREQ, 2)), | 157 | (STAR, EQ) => return (1, Op::Composite(STAREQ, 2)), |
158 | (PERCENT, EQ) => return (1, Op::Composite(PERCENTEQ, 2)), | ||
158 | (SLASH, EQ) => return (1, Op::Composite(SLASHEQ, 2)), | 159 | (SLASH, EQ) => return (1, Op::Composite(SLASHEQ, 2)), |
159 | (PIPE, EQ) => return (1, Op::Composite(PIPEEQ, 2)), | 160 | (PIPE, EQ) => return (1, Op::Composite(PIPEEQ, 2)), |
160 | (AMP, EQ) => return (1, Op::Composite(AMPEQ, 2)), | 161 | (AMP, EQ) => return (1, Op::Composite(AMPEQ, 2)), |
diff --git a/crates/ra_syntax/tests/data/parser/ok/0048_compound_assignment.rs b/crates/ra_syntax/tests/data/parser/ok/0048_compound_assignment.rs new file mode 100644 index 000000000..871720a49 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0048_compound_assignment.rs | |||
@@ -0,0 +1,17 @@ | |||
1 | // https://github.com/rust-analyzer/rust-analyzer/pull/983 | ||
2 | |||
3 | fn compound_assignment() { | ||
4 | let mut a = 0; | ||
5 | a += 1; | ||
6 | a -= 2; | ||
7 | a *= 3; | ||
8 | a %= 4; | ||
9 | a /= 5; | ||
10 | a |= 6; | ||
11 | a &= 7; | ||
12 | a ^= 8; | ||
13 | a <= 9; | ||
14 | a >= 10; | ||
15 | a >>= 11; | ||
16 | a <<= 12; | ||
17 | } | ||
diff --git a/crates/ra_syntax/tests/data/parser/ok/0048_compound_assignment.txt b/crates/ra_syntax/tests/data/parser/ok/0048_compound_assignment.txt new file mode 100644 index 000000000..c5ff06823 --- /dev/null +++ b/crates/ra_syntax/tests/data/parser/ok/0048_compound_assignment.txt | |||
@@ -0,0 +1,200 @@ | |||
1 | SOURCE_FILE@[0; 257) | ||
2 | COMMENT@[0; 58) | ||
3 | WHITESPACE@[58; 60) | ||
4 | FN_DEF@[60; 256) | ||
5 | FN_KW@[60; 62) | ||
6 | WHITESPACE@[62; 63) | ||
7 | NAME@[63; 82) | ||
8 | IDENT@[63; 82) "compound_assignment" | ||
9 | PARAM_LIST@[82; 84) | ||
10 | L_PAREN@[82; 83) | ||
11 | R_PAREN@[83; 84) | ||
12 | WHITESPACE@[84; 85) | ||
13 | BLOCK@[85; 256) | ||
14 | L_CURLY@[85; 86) | ||
15 | WHITESPACE@[86; 91) | ||
16 | LET_STMT@[91; 105) | ||
17 | LET_KW@[91; 94) | ||
18 | WHITESPACE@[94; 95) | ||
19 | BIND_PAT@[95; 100) | ||
20 | MUT_KW@[95; 98) | ||
21 | WHITESPACE@[98; 99) | ||
22 | NAME@[99; 100) | ||
23 | IDENT@[99; 100) "a" | ||
24 | WHITESPACE@[100; 101) | ||
25 | EQ@[101; 102) | ||
26 | WHITESPACE@[102; 103) | ||
27 | LITERAL@[103; 104) | ||
28 | INT_NUMBER@[103; 104) "0" | ||
29 | SEMI@[104; 105) | ||
30 | WHITESPACE@[105; 110) | ||
31 | EXPR_STMT@[110; 117) | ||
32 | BIN_EXPR@[110; 116) | ||
33 | PATH_EXPR@[110; 111) | ||
34 | PATH@[110; 111) | ||
35 | PATH_SEGMENT@[110; 111) | ||
36 | NAME_REF@[110; 111) | ||
37 | IDENT@[110; 111) "a" | ||
38 | WHITESPACE@[111; 112) | ||
39 | PLUSEQ@[112; 114) | ||
40 | WHITESPACE@[114; 115) | ||
41 | LITERAL@[115; 116) | ||
42 | INT_NUMBER@[115; 116) "1" | ||
43 | SEMI@[116; 117) | ||
44 | WHITESPACE@[117; 122) | ||
45 | EXPR_STMT@[122; 129) | ||
46 | BIN_EXPR@[122; 128) | ||
47 | PATH_EXPR@[122; 123) | ||
48 | PATH@[122; 123) | ||
49 | PATH_SEGMENT@[122; 123) | ||
50 | NAME_REF@[122; 123) | ||
51 | IDENT@[122; 123) "a" | ||
52 | WHITESPACE@[123; 124) | ||
53 | MINUSEQ@[124; 126) | ||
54 | WHITESPACE@[126; 127) | ||
55 | LITERAL@[127; 128) | ||
56 | INT_NUMBER@[127; 128) "2" | ||
57 | SEMI@[128; 129) | ||
58 | WHITESPACE@[129; 134) | ||
59 | EXPR_STMT@[134; 141) | ||
60 | BIN_EXPR@[134; 140) | ||
61 | PATH_EXPR@[134; 135) | ||
62 | PATH@[134; 135) | ||
63 | PATH_SEGMENT@[134; 135) | ||
64 | NAME_REF@[134; 135) | ||
65 | IDENT@[134; 135) "a" | ||
66 | WHITESPACE@[135; 136) | ||
67 | STAREQ@[136; 138) | ||
68 | WHITESPACE@[138; 139) | ||
69 | LITERAL@[139; 140) | ||
70 | INT_NUMBER@[139; 140) "3" | ||
71 | SEMI@[140; 141) | ||
72 | WHITESPACE@[141; 146) | ||
73 | EXPR_STMT@[146; 153) | ||
74 | BIN_EXPR@[146; 152) | ||
75 | PATH_EXPR@[146; 147) | ||
76 | PATH@[146; 147) | ||
77 | PATH_SEGMENT@[146; 147) | ||
78 | NAME_REF@[146; 147) | ||
79 | IDENT@[146; 147) "a" | ||
80 | WHITESPACE@[147; 148) | ||
81 | PERCENTEQ@[148; 150) | ||
82 | WHITESPACE@[150; 151) | ||
83 | LITERAL@[151; 152) | ||
84 | INT_NUMBER@[151; 152) "4" | ||
85 | SEMI@[152; 153) | ||
86 | WHITESPACE@[153; 158) | ||
87 | EXPR_STMT@[158; 165) | ||
88 | BIN_EXPR@[158; 164) | ||
89 | PATH_EXPR@[158; 159) | ||
90 | PATH@[158; 159) | ||
91 | PATH_SEGMENT@[158; 159) | ||
92 | NAME_REF@[158; 159) | ||
93 | IDENT@[158; 159) "a" | ||
94 | WHITESPACE@[159; 160) | ||
95 | SLASHEQ@[160; 162) | ||
96 | WHITESPACE@[162; 163) | ||
97 | LITERAL@[163; 164) | ||
98 | INT_NUMBER@[163; 164) "5" | ||
99 | SEMI@[164; 165) | ||
100 | WHITESPACE@[165; 170) | ||
101 | EXPR_STMT@[170; 177) | ||
102 | BIN_EXPR@[170; 176) | ||
103 | PATH_EXPR@[170; 171) | ||
104 | PATH@[170; 171) | ||
105 | PATH_SEGMENT@[170; 171) | ||
106 | NAME_REF@[170; 171) | ||
107 | IDENT@[170; 171) "a" | ||
108 | WHITESPACE@[171; 172) | ||
109 | PIPEEQ@[172; 174) | ||
110 | WHITESPACE@[174; 175) | ||
111 | LITERAL@[175; 176) | ||
112 | INT_NUMBER@[175; 176) "6" | ||
113 | SEMI@[176; 177) | ||
114 | WHITESPACE@[177; 182) | ||
115 | EXPR_STMT@[182; 189) | ||
116 | BIN_EXPR@[182; 188) | ||
117 | PATH_EXPR@[182; 183) | ||
118 | PATH@[182; 183) | ||
119 | PATH_SEGMENT@[182; 183) | ||
120 | NAME_REF@[182; 183) | ||
121 | IDENT@[182; 183) "a" | ||
122 | WHITESPACE@[183; 184) | ||
123 | AMPEQ@[184; 186) | ||
124 | WHITESPACE@[186; 187) | ||
125 | LITERAL@[187; 188) | ||
126 | INT_NUMBER@[187; 188) "7" | ||
127 | SEMI@[188; 189) | ||
128 | WHITESPACE@[189; 194) | ||
129 | EXPR_STMT@[194; 201) | ||
130 | BIN_EXPR@[194; 200) | ||
131 | PATH_EXPR@[194; 195) | ||
132 | PATH@[194; 195) | ||
133 | PATH_SEGMENT@[194; 195) | ||
134 | NAME_REF@[194; 195) | ||
135 | IDENT@[194; 195) "a" | ||
136 | WHITESPACE@[195; 196) | ||
137 | CARETEQ@[196; 198) | ||
138 | WHITESPACE@[198; 199) | ||
139 | LITERAL@[199; 200) | ||
140 | INT_NUMBER@[199; 200) "8" | ||
141 | SEMI@[200; 201) | ||
142 | WHITESPACE@[201; 206) | ||
143 | EXPR_STMT@[206; 213) | ||
144 | BIN_EXPR@[206; 212) | ||
145 | PATH_EXPR@[206; 207) | ||
146 | PATH@[206; 207) | ||
147 | PATH_SEGMENT@[206; 207) | ||
148 | NAME_REF@[206; 207) | ||
149 | IDENT@[206; 207) "a" | ||
150 | WHITESPACE@[207; 208) | ||
151 | LTEQ@[208; 210) | ||
152 | WHITESPACE@[210; 211) | ||
153 | LITERAL@[211; 212) | ||
154 | INT_NUMBER@[211; 212) "9" | ||
155 | SEMI@[212; 213) | ||
156 | WHITESPACE@[213; 218) | ||
157 | EXPR_STMT@[218; 226) | ||
158 | BIN_EXPR@[218; 225) | ||
159 | PATH_EXPR@[218; 219) | ||
160 | PATH@[218; 219) | ||
161 | PATH_SEGMENT@[218; 219) | ||
162 | NAME_REF@[218; 219) | ||
163 | IDENT@[218; 219) "a" | ||
164 | WHITESPACE@[219; 220) | ||
165 | GTEQ@[220; 222) | ||
166 | WHITESPACE@[222; 223) | ||
167 | LITERAL@[223; 225) | ||
168 | INT_NUMBER@[223; 225) "10" | ||
169 | SEMI@[225; 226) | ||
170 | WHITESPACE@[226; 231) | ||
171 | EXPR_STMT@[231; 240) | ||
172 | BIN_EXPR@[231; 239) | ||
173 | PATH_EXPR@[231; 232) | ||
174 | PATH@[231; 232) | ||
175 | PATH_SEGMENT@[231; 232) | ||
176 | NAME_REF@[231; 232) | ||
177 | IDENT@[231; 232) "a" | ||
178 | WHITESPACE@[232; 233) | ||
179 | SHREQ@[233; 236) | ||
180 | WHITESPACE@[236; 237) | ||
181 | LITERAL@[237; 239) | ||
182 | INT_NUMBER@[237; 239) "11" | ||
183 | SEMI@[239; 240) | ||
184 | WHITESPACE@[240; 245) | ||
185 | EXPR_STMT@[245; 254) | ||
186 | BIN_EXPR@[245; 253) | ||
187 | PATH_EXPR@[245; 246) | ||
188 | PATH@[245; 246) | ||
189 | PATH_SEGMENT@[245; 246) | ||
190 | NAME_REF@[245; 246) | ||
191 | IDENT@[245; 246) "a" | ||
192 | WHITESPACE@[246; 247) | ||
193 | SHLEQ@[247; 250) | ||
194 | WHITESPACE@[250; 251) | ||
195 | LITERAL@[251; 253) | ||
196 | INT_NUMBER@[251; 253) "12" | ||
197 | SEMI@[253; 254) | ||
198 | WHITESPACE@[254; 255) | ||
199 | R_CURLY@[255; 256) | ||
200 | WHITESPACE@[256; 257) | ||