diff options
-rw-r--r-- | crates/ra_parser/src/grammar/types.rs | 3 | ||||
-rw-r--r-- | crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rs | 1 | ||||
-rw-r--r-- | crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.txt | 83 |
3 files changed, 85 insertions, 2 deletions
diff --git a/crates/ra_parser/src/grammar/types.rs b/crates/ra_parser/src/grammar/types.rs index c0b722569..9acc00793 100644 --- a/crates/ra_parser/src/grammar/types.rs +++ b/crates/ra_parser/src/grammar/types.rs | |||
@@ -205,6 +205,7 @@ pub(super) fn for_binder(p: &mut Parser) { | |||
205 | // type A = for<'a> fn() -> (); | 205 | // type A = for<'a> fn() -> (); |
206 | // fn foo<T>(_t: &T) where for<'a> &'a T: Iterator {} | 206 | // fn foo<T>(_t: &T) where for<'a> &'a T: Iterator {} |
207 | // fn bar<T>(_t: &T) where for<'a> &'a mut T: Iterator {} | 207 | // fn bar<T>(_t: &T) where for<'a> &'a mut T: Iterator {} |
208 | // fn baz<T>(_t: &T) where for<'a> <&'a T as Baz>::Foo: Iterator {} | ||
208 | pub(super) fn for_type(p: &mut Parser) { | 209 | pub(super) fn for_type(p: &mut Parser) { |
209 | assert!(p.at(T![for])); | 210 | assert!(p.at(T![for])); |
210 | let m = p.start(); | 211 | let m = p.start(); |
@@ -212,7 +213,7 @@ pub(super) fn for_type(p: &mut Parser) { | |||
212 | match p.current() { | 213 | match p.current() { |
213 | T![fn] | T![unsafe] | T![extern] => fn_pointer_type(p), | 214 | T![fn] | T![unsafe] | T![extern] => fn_pointer_type(p), |
214 | T![&] => reference_type(p), | 215 | T![&] => reference_type(p), |
215 | _ if paths::is_path_start(p) => path_type_(p, false), | 216 | _ if paths::is_path_start(p) || p.at(T![<]) => path_type_(p, false), |
216 | _ => p.error("expected a path"), | 217 | _ => p.error("expected a path"), |
217 | } | 218 | } |
218 | m.complete(p, FOR_TYPE); | 219 | m.complete(p, FOR_TYPE); |
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rs b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rs index 7cde5c532..d6774d438 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rs +++ b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rs | |||
@@ -1,3 +1,4 @@ | |||
1 | type A = for<'a> fn() -> (); | 1 | type A = for<'a> fn() -> (); |
2 | fn foo<T>(_t: &T) where for<'a> &'a T: Iterator {} | 2 | fn foo<T>(_t: &T) where for<'a> &'a T: Iterator {} |
3 | fn bar<T>(_t: &T) where for<'a> &'a mut T: Iterator {} | 3 | fn bar<T>(_t: &T) where for<'a> &'a mut T: Iterator {} |
4 | fn baz<T>(_t: &T) where for<'a> <&'a T as Baz>::Foo: Iterator {} | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.txt b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.txt index 599cf9452..c12ce4ddb 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.txt +++ b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.txt | |||
@@ -1,4 +1,4 @@ | |||
1 | SOURCE_FILE@[0; 135) | 1 | SOURCE_FILE@[0; 200) |
2 | TYPE_ALIAS_DEF@[0; 28) | 2 | TYPE_ALIAS_DEF@[0; 28) |
3 | TYPE_KW@[0; 4) "type" | 3 | TYPE_KW@[0; 4) "type" |
4 | WHITESPACE@[4; 5) " " | 4 | WHITESPACE@[4; 5) " " |
@@ -157,3 +157,84 @@ SOURCE_FILE@[0; 135) | |||
157 | L_CURLY@[132; 133) "{" | 157 | L_CURLY@[132; 133) "{" |
158 | R_CURLY@[133; 134) "}" | 158 | R_CURLY@[133; 134) "}" |
159 | WHITESPACE@[134; 135) "\n" | 159 | WHITESPACE@[134; 135) "\n" |
160 | FN_DEF@[135; 199) | ||
161 | FN_KW@[135; 137) "fn" | ||
162 | WHITESPACE@[137; 138) " " | ||
163 | NAME@[138; 141) | ||
164 | IDENT@[138; 141) "baz" | ||
165 | TYPE_PARAM_LIST@[141; 144) | ||
166 | L_ANGLE@[141; 142) "<" | ||
167 | TYPE_PARAM@[142; 143) | ||
168 | NAME@[142; 143) | ||
169 | IDENT@[142; 143) "T" | ||
170 | R_ANGLE@[143; 144) ">" | ||
171 | PARAM_LIST@[144; 152) | ||
172 | L_PAREN@[144; 145) "(" | ||
173 | PARAM@[145; 151) | ||
174 | BIND_PAT@[145; 147) | ||
175 | NAME@[145; 147) | ||
176 | IDENT@[145; 147) "_t" | ||
177 | COLON@[147; 148) ":" | ||
178 | WHITESPACE@[148; 149) " " | ||
179 | REFERENCE_TYPE@[149; 151) | ||
180 | AMP@[149; 150) "&" | ||
181 | PATH_TYPE@[150; 151) | ||
182 | PATH@[150; 151) | ||
183 | PATH_SEGMENT@[150; 151) | ||
184 | NAME_REF@[150; 151) | ||
185 | IDENT@[150; 151) "T" | ||
186 | R_PAREN@[151; 152) ")" | ||
187 | WHITESPACE@[152; 153) " " | ||
188 | WHERE_CLAUSE@[153; 196) | ||
189 | WHERE_KW@[153; 158) "where" | ||
190 | WHITESPACE@[158; 159) " " | ||
191 | WHERE_PRED@[159; 196) | ||
192 | FOR_TYPE@[159; 186) | ||
193 | FOR_KW@[159; 162) "for" | ||
194 | TYPE_PARAM_LIST@[162; 166) | ||
195 | L_ANGLE@[162; 163) "<" | ||
196 | LIFETIME_PARAM@[163; 165) | ||
197 | LIFETIME@[163; 165) "\'a" | ||
198 | R_ANGLE@[165; 166) ">" | ||
199 | WHITESPACE@[166; 167) " " | ||
200 | PATH_TYPE@[167; 186) | ||
201 | PATH@[167; 186) | ||
202 | PATH@[167; 181) | ||
203 | PATH_SEGMENT@[167; 181) | ||
204 | L_ANGLE@[167; 168) "<" | ||
205 | REFERENCE_TYPE@[168; 173) | ||
206 | AMP@[168; 169) "&" | ||
207 | LIFETIME@[169; 171) "\'a" | ||
208 | WHITESPACE@[171; 172) " " | ||
209 | PATH_TYPE@[172; 173) | ||
210 | PATH@[172; 173) | ||
211 | PATH_SEGMENT@[172; 173) | ||
212 | NAME_REF@[172; 173) | ||
213 | IDENT@[172; 173) "T" | ||
214 | WHITESPACE@[173; 174) " " | ||
215 | AS_KW@[174; 176) "as" | ||
216 | WHITESPACE@[176; 177) " " | ||
217 | PATH_TYPE@[177; 180) | ||
218 | PATH@[177; 180) | ||
219 | PATH_SEGMENT@[177; 180) | ||
220 | NAME_REF@[177; 180) | ||
221 | IDENT@[177; 180) "Baz" | ||
222 | R_ANGLE@[180; 181) ">" | ||
223 | COLONCOLON@[181; 183) "::" | ||
224 | PATH_SEGMENT@[183; 186) | ||
225 | NAME_REF@[183; 186) | ||
226 | IDENT@[183; 186) "Foo" | ||
227 | COLON@[186; 187) ":" | ||
228 | WHITESPACE@[187; 188) " " | ||
229 | TYPE_BOUND_LIST@[188; 196) | ||
230 | TYPE_BOUND@[188; 196) | ||
231 | PATH_TYPE@[188; 196) | ||
232 | PATH@[188; 196) | ||
233 | PATH_SEGMENT@[188; 196) | ||
234 | NAME_REF@[188; 196) | ||
235 | IDENT@[188; 196) "Iterator" | ||
236 | WHITESPACE@[196; 197) " " | ||
237 | BLOCK@[197; 199) | ||
238 | L_CURLY@[197; 198) "{" | ||
239 | R_CURLY@[198; 199) "}" | ||
240 | WHITESPACE@[199; 200) "\n" | ||