diff options
author | Matthew Jasper <[email protected]> | 2020-06-10 11:30:48 +0100 |
---|---|---|
committer | Matthew Jasper <[email protected]> | 2020-06-10 11:30:58 +0100 |
commit | 506e1ddbfa5213f254923da9bbf0efddc6f1fc34 (patch) | |
tree | 2c220370c38a8a79a6d9b07d0fe184db0d827e1d | |
parent | 560b98bc505be6ff70876df661e4055e1b38a78c (diff) |
Separating parsing of `for` in predicates and types
12 files changed, 507 insertions, 291 deletions
diff --git a/crates/ra_parser/src/grammar/type_params.rs b/crates/ra_parser/src/grammar/type_params.rs index 50e4900c3..b3508c732 100644 --- a/crates/ra_parser/src/grammar/type_params.rs +++ b/crates/ra_parser/src/grammar/type_params.rs | |||
@@ -191,10 +191,30 @@ fn where_predicate(p: &mut Parser) { | |||
191 | } | 191 | } |
192 | _ => { | 192 | _ => { |
193 | // test where_pred_for | 193 | // test where_pred_for |
194 | // fn test<F>() | 194 | // fn for_trait<F>() |
195 | // where | 195 | // where |
196 | // for<'a> F: Fn(&'a str) | 196 | // for<'a> F: Fn(&'a str) |
197 | // { } | 197 | // { } |
198 | // fn for_ref<F>() | ||
199 | // where | ||
200 | // for<'a> &'a F: Debug | ||
201 | // { } | ||
202 | // fn for_parens<F>() | ||
203 | // where | ||
204 | // for<'a> (&'a F): Fn(&'a str) | ||
205 | // { } | ||
206 | // fn for_slice<F>() | ||
207 | // where | ||
208 | // for<'a> [&'a F]: Eq | ||
209 | // { } | ||
210 | // fn for_qpath<T>(_t: &T) | ||
211 | // where | ||
212 | // for<'a> <&'a T as Baz>::Foo: Iterator | ||
213 | // { } | ||
214 | if p.at(T![for]) { | ||
215 | types::for_binder(p); | ||
216 | } | ||
217 | |||
198 | types::type_(p); | 218 | types::type_(p); |
199 | 219 | ||
200 | if p.at(T![:]) { | 220 | if p.at(T![:]) { |
diff --git a/crates/ra_parser/src/grammar/types.rs b/crates/ra_parser/src/grammar/types.rs index fe1a039cb..63dd3774f 100644 --- a/crates/ra_parser/src/grammar/types.rs +++ b/crates/ra_parser/src/grammar/types.rs | |||
@@ -216,19 +216,20 @@ pub(super) fn for_binder(p: &mut Parser) { | |||
216 | 216 | ||
217 | // test for_type | 217 | // test for_type |
218 | // type A = for<'a> fn() -> (); | 218 | // type A = for<'a> fn() -> (); |
219 | // fn foo<T>(_t: &T) where for<'a> &'a T: Iterator {} | 219 | // type B = for<'a> unsafe extern "C" fn(&'a ()) -> (); |
220 | // fn bar<T>(_t: &T) where for<'a> &'a mut T: Iterator {} | ||
221 | // fn baz<T>(_t: &T) where for<'a> <&'a T as Baz>::Foo: Iterator {} | ||
222 | pub(super) fn for_type(p: &mut Parser) { | 220 | pub(super) fn for_type(p: &mut Parser) { |
223 | assert!(p.at(T![for])); | 221 | assert!(p.at(T![for])); |
224 | let m = p.start(); | 222 | let m = p.start(); |
225 | for_binder(p); | 223 | for_binder(p); |
226 | match p.current() { | 224 | match p.current() { |
227 | T![fn] | T![unsafe] | T![extern] => fn_pointer_type(p), | 225 | T![fn] | T![unsafe] | T![extern] => {} |
228 | T![&] => reference_type(p), | 226 | // OK: legacy trait object format |
229 | _ if paths::is_path_start(p) => path_type_(p, false), | 227 | _ if paths::is_use_path_start(p) => {} |
230 | _ => p.error("expected a path"), | 228 | _ => { |
229 | p.error("expected a function pointer or path"); | ||
230 | } | ||
231 | } | 231 | } |
232 | type_no_bounds(p); | ||
232 | m.complete(p, FOR_TYPE); | 233 | m.complete(p, FOR_TYPE); |
233 | } | 234 | } |
234 | 235 | ||
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index eddc807d5..9d02aeef3 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -285,6 +285,8 @@ where | |||
285 | let pred = predicates.next().unwrap(); | 285 | let pred = predicates.next().unwrap(); |
286 | let mut bounds = pred.type_bound_list().unwrap().bounds(); | 286 | let mut bounds = pred.type_bound_list().unwrap().bounds(); |
287 | 287 | ||
288 | assert!(pred.for_token().is_none()); | ||
289 | assert!(pred.type_param_list().is_none()); | ||
288 | assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string()); | 290 | assert_eq!("T", pred.type_ref().unwrap().syntax().text().to_string()); |
289 | assert_bound("Clone", bounds.next()); | 291 | assert_bound("Clone", bounds.next()); |
290 | assert_bound("Copy", bounds.next()); | 292 | assert_bound("Copy", bounds.next()); |
@@ -322,6 +324,8 @@ where | |||
322 | let pred = predicates.next().unwrap(); | 324 | let pred = predicates.next().unwrap(); |
323 | let mut bounds = pred.type_bound_list().unwrap().bounds(); | 325 | let mut bounds = pred.type_bound_list().unwrap().bounds(); |
324 | 326 | ||
325 | assert_eq!("for<'a> F", pred.type_ref().unwrap().syntax().text().to_string()); | 327 | assert!(pred.for_token().is_some()); |
328 | assert_eq!("<'a>", pred.type_param_list().unwrap().syntax().text().to_string()); | ||
329 | assert_eq!("F", pred.type_ref().unwrap().syntax().text().to_string()); | ||
326 | assert_bound("Fn(&'a str)", bounds.next()); | 330 | assert_bound("Fn(&'a str)", bounds.next()); |
327 | } | 331 | } |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index cb430ca01..40081ebb1 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -2052,6 +2052,8 @@ pub struct WherePred { | |||
2052 | } | 2052 | } |
2053 | impl ast::TypeBoundsOwner for WherePred {} | 2053 | impl ast::TypeBoundsOwner for WherePred {} |
2054 | impl WherePred { | 2054 | impl WherePred { |
2055 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![for]) } | ||
2056 | pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } | ||
2055 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | 2057 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { |
2056 | support::token(&self.syntax, T![lifetime]) | 2058 | support::token(&self.syntax, T![lifetime]) |
2057 | } | 2059 | } |
diff --git a/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast b/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast index 568a4cc02..4d6461d1e 100644 --- a/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast +++ b/crates/ra_syntax/test_data/parser/err/0027_incomplere_where_for.rast | |||
@@ -12,17 +12,16 @@ [email protected] | |||
12 | [email protected] "where" | 12 | [email protected] "where" |
13 | [email protected] " " | 13 | [email protected] " " |
14 | [email protected] | 14 | [email protected] |
15 | [email protected] | 15 | [email protected] "for" |
16 | [email protected] "for" | 16 | [email protected] |
17 | [email protected] | 17 | [email protected] "<" |
18 | [email protected] "<" | 18 | [email protected] |
19 | [email protected] | 19 | [email protected] "\'a" |
20 | [email protected] "\'a" | 20 | [email protected] ">" |
21 | [email protected] ">" | ||
22 | [email protected] "\n" | 21 | [email protected] "\n" |
23 | [email protected] | 22 | [email protected] |
24 | [email protected] "{" | 23 | [email protected] "{" |
25 | [email protected] "}" | 24 | [email protected] "}" |
26 | [email protected] "\n" | 25 | [email protected] "\n" |
27 | error 26..26: expected a path | 26 | error 26..26: expected type |
28 | error 26..26: expected colon | 27 | error 26..26: expected colon |
diff --git a/crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rast b/crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rast new file mode 100644 index 000000000..3400beff0 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rast | |||
@@ -0,0 +1,88 @@ | |||
1 | [email protected] | ||
2 | [email protected] | ||
3 | [email protected] "type" | ||
4 | [email protected] " " | ||
5 | [email protected] | ||
6 | [email protected] "A" | ||
7 | [email protected] " " | ||
8 | [email protected] "=" | ||
9 | [email protected] " " | ||
10 | [email protected] | ||
11 | [email protected] "for" | ||
12 | [email protected] | ||
13 | [email protected] "<" | ||
14 | [email protected] | ||
15 | [email protected] "\'a" | ||
16 | [email protected] ">" | ||
17 | [email protected] " " | ||
18 | [email protected] | ||
19 | [email protected] "&" | ||
20 | [email protected] "\'a" | ||
21 | [email protected] " " | ||
22 | [email protected] | ||
23 | [email protected] | ||
24 | [email protected] | ||
25 | [email protected] | ||
26 | [email protected] "u32" | ||
27 | [email protected] ";" | ||
28 | [email protected] "\n" | ||
29 | [email protected] | ||
30 | [email protected] "type" | ||
31 | [email protected] " " | ||
32 | [email protected] | ||
33 | [email protected] "B" | ||
34 | [email protected] " " | ||
35 | [email protected] "=" | ||
36 | [email protected] " " | ||
37 | [email protected] | ||
38 | [email protected] "for" | ||
39 | [email protected] | ||
40 | [email protected] "<" | ||
41 | [email protected] | ||
42 | [email protected] "\'a" | ||
43 | [email protected] ">" | ||
44 | [email protected] " " | ||
45 | [email protected] | ||
46 | [email protected] "(" | ||
47 | [email protected] | ||
48 | [email protected] "&" | ||
49 | [email protected] "\'a" | ||
50 | [email protected] " " | ||
51 | [email protected] | ||
52 | [email protected] | ||
53 | [email protected] | ||
54 | [email protected] | ||
55 | [email protected] "u32" | ||
56 | [email protected] "," | ||
57 | [email protected] ")" | ||
58 | [email protected] ";" | ||
59 | [email protected] "\n" | ||
60 | [email protected] | ||
61 | [email protected] "type" | ||
62 | [email protected] " " | ||
63 | [email protected] | ||
64 | [email protected] "B" | ||
65 | [email protected] " " | ||
66 | [email protected] "=" | ||
67 | [email protected] " " | ||
68 | [email protected] | ||
69 | [email protected] "for" | ||
70 | [email protected] | ||
71 | [email protected] "<" | ||
72 | [email protected] | ||
73 | [email protected] "\'a" | ||
74 | [email protected] ">" | ||
75 | [email protected] " " | ||
76 | [email protected] | ||
77 | [email protected] "[" | ||
78 | [email protected] | ||
79 | [email protected] | ||
80 | [email protected] | ||
81 | [email protected] | ||
82 | [email protected] "u32" | ||
83 | [email protected] "]" | ||
84 | [email protected] ";" | ||
85 | [email protected] "\n" | ||
86 | error 16..16: expected a function pointer or path | ||
87 | error 42..42: expected a function pointer or path | ||
88 | error 71..71: expected a function pointer or path | ||
diff --git a/crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rs b/crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rs new file mode 100644 index 000000000..f34ac7fc5 --- /dev/null +++ b/crates/ra_syntax/test_data/parser/err/0044_unexpected_for_type.rs | |||
@@ -0,0 +1,3 @@ | |||
1 | type A = for<'a> &'a u32; | ||
2 | type B = for<'a> (&'a u32,); | ||
3 | type B = for<'a> [u32]; | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast b/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast index 9dc473e43..4f88bfe43 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rast | |||
@@ -1,61 +1,310 @@ | |||
1 | SOURCE_FILE@0..49 | 1 | SOURCE_FILE@0..292 |
2 | FN_DEF@0..48 | 2 | FN_DEF@0..53 |
3 | [email protected] "fn" | 3 | [email protected] "fn" |
4 | [email protected] " " | 4 | [email protected] " " |
5 | [email protected] | 5 | [email protected] |
6 | [email protected] "test" | 6 | [email protected] "for_trait" |
7 | [email protected] | 7 | [email protected] |
8 | [email protected] "<" | 8 | [email protected] "<" |
9 | [email protected] | 9 | [email protected] |
10 | [email protected] | 10 | [email protected] |
11 | [email protected] "F" | 11 | [email protected] "F" |
12 | [email protected] ">" | 12 | [email protected] ">" |
13 | [email protected] | 13 | [email protected] |
14 | [email protected] "(" | 14 | [email protected] "(" |
15 | [email protected] ")" | 15 | [email protected] ")" |
16 | [email protected] "\n" | 16 | [email protected] "\n" |
17 | [email protected] | 17 | [email protected] |
18 | [email protected] "where" | 18 | [email protected] "where" |
19 | [email protected] "\n " | 19 | [email protected] "\n " |
20 | [email protected] | 20 | [email protected] |
21 | [email protected] | 21 | [email protected] "for" |
22 | [email protected] "for" | 22 | [email protected] |
23 | [email protected] | 23 | [email protected] "<" |
24 | [email protected] "<" | 24 | [email protected] |
25 | [email protected] | 25 | [email protected] "\'a" |
26 | [email protected] "\'a" | 26 | [email protected] ">" |
27 | [email protected] ">" | 27 | [email protected] " " |
28 | [email protected] " " | 28 | [email protected] |
29 | [email protected] | 29 | [email protected] |
30 | [email protected] | 30 | [email protected] |
31 | [email protected] | 31 | [email protected] |
32 | [email protected] | 32 | [email protected] "F" |
33 | [email protected] "F" | 33 | [email protected] ":" |
34 | [email protected] ":" | 34 | [email protected] " " |
35 | [email protected] " " | 35 | [email protected] |
36 | [email protected] | 36 | [email protected] |
37 | [email protected] | 37 | [email protected] |
38 | [email protected] | 38 | [email protected] |
39 | [email protected] | 39 | [email protected] |
40 | [email protected] | 40 | [email protected] |
41 | [email protected] | 41 | [email protected] "Fn" |
42 | [email protected] "Fn" | 42 | [email protected] |
43 | [email protected] | 43 | [email protected] "(" |
44 | [email protected] "(" | 44 | [email protected] |
45 | [email protected] | 45 | [email protected] |
46 | [email protected] | 46 | [email protected] "&" |
47 | [email protected] "&" | 47 | [email protected] "\'a" |
48 | [email protected] "\'a" | 48 | [email protected] " " |
49 | [email protected] " " | 49 | [email protected] |
50 | [email protected] | 50 | [email protected] |
51 | [email protected] | 51 | [email protected] |
52 | [email protected] | 52 | [email protected] |
53 | [email protected] | 53 | [email protected] "str" |
54 | [email protected] "str" | 54 | [email protected] ")" |
55 | [email protected] ")" | 55 | [email protected] "\n" |
56 | [email protected] "\n" | 56 | [email protected] |
57 | [email protected] | 57 | [email protected] "{" |
58 | [email protected] "{" | 58 | [email protected] " " |
59 | [email protected] " " | 59 | [email protected] "}" |
60 | [email protected] "}" | 60 | [email protected] "\n" |
61 | [email protected] "\n" | 61 | [email protected] |
62 | [email protected] "fn" | ||
63 | [email protected] " " | ||
64 | [email protected] | ||
65 | [email protected] "for_ref" | ||
66 | [email protected] | ||
67 | [email protected] "<" | ||
68 | [email protected] | ||
69 | [email protected] | ||
70 | [email protected] "F" | ||
71 | [email protected] ">" | ||
72 | [email protected] | ||
73 | [email protected] "(" | ||
74 | [email protected] ")" | ||
75 | [email protected] "\n" | ||
76 | [email protected] | ||
77 | [email protected] "where" | ||
78 | [email protected] "\n " | ||
79 | [email protected] | ||
80 | [email protected] "for" | ||
81 | [email protected] | ||
82 | [email protected] "<" | ||
83 | [email protected] | ||
84 | [email protected] "\'a" | ||
85 | [email protected] ">" | ||
86 | [email protected] " " | ||
87 | [email protected] | ||
88 | [email protected] "&" | ||
89 | [email protected] "\'a" | ||
90 | [email protected] " " | ||
91 | [email protected] | ||
92 | [email protected] | ||
93 | [email protected] | ||
94 | [email protected] | ||
95 | [email protected] "F" | ||
96 | [email protected] ":" | ||
97 | [email protected] " " | ||
98 | [email protected] | ||
99 | [email protected] | ||
100 | [email protected] | ||
101 | [email protected] | ||
102 | [email protected] | ||
103 | [email protected] | ||
104 | [email protected] "Debug" | ||
105 | [email protected] "\n" | ||
106 | [email protected] | ||
107 | [email protected] "{" | ||
108 | [email protected] " " | ||
109 | [email protected] "}" | ||
110 | [email protected] "\n" | ||
111 | [email protected] | ||
112 | [email protected] "fn" | ||
113 | [email protected] " " | ||
114 | [email protected] | ||
115 | [email protected] "for_parens" | ||
116 | [email protected] | ||
117 | [email protected] "<" | ||
118 | [email protected] | ||
119 | [email protected] | ||
120 | [email protected] "F" | ||
121 | [email protected] ">" | ||
122 | [email protected] | ||
123 | [email protected] "(" | ||
124 | [email protected] ")" | ||
125 | [email protected] "\n" | ||
126 | [email protected] | ||
127 | [email protected] "where" | ||
128 | [email protected] "\n " | ||
129 | [email protected] | ||
130 | [email protected] "for" | ||
131 | [email protected] | ||
132 | [email protected] "<" | ||
133 | [email protected] | ||
134 | [email protected] "\'a" | ||
135 | [email protected] ">" | ||
136 | [email protected] " " | ||
137 | [email protected] | ||
138 | [email protected] "(" | ||
139 | [email protected] | ||
140 | [email protected] "&" | ||
141 | [email protected] "\'a" | ||
142 | [email protected] " " | ||
143 | [email protected] | ||
144 | [email protected] | ||
145 | [email protected] | ||
146 | [email protected] | ||
147 | [email protected] "F" | ||
148 | [email protected] ")" | ||
149 | [email protected] ":" | ||
150 | [email protected] " " | ||
151 | [email protected] | ||
152 | [email protected] | ||
153 | [email protected] | ||
154 | [email protected] | ||
155 | [email protected] | ||
156 | [email protected] | ||
157 | [email protected] "Fn" | ||
158 | [email protected] | ||
159 | [email protected] "(" | ||
160 | [email protected] | ||
161 | [email protected] | ||
162 | [email protected] "&" | ||
163 | [email protected] "\'a" | ||
164 | [email protected] " " | ||
165 | [email protected] | ||
166 | [email protected] | ||
167 | [email protected] | ||
168 | [email protected] | ||
169 | [email protected] "str" | ||
170 | [email protected] ")" | ||
171 | [email protected] "\n" | ||
172 | [email protected] | ||
173 | [email protected] "{" | ||
174 | [email protected] " " | ||
175 | [email protected] "}" | ||
176 | [email protected] "\n" | ||
177 | [email protected] | ||
178 | [email protected] "fn" | ||
179 | [email protected] " " | ||
180 | [email protected] | ||
181 | [email protected] "for_slice" | ||
182 | [email protected] | ||
183 | [email protected] "<" | ||
184 | [email protected] | ||
185 | [email protected] | ||
186 | [email protected] "F" | ||
187 | [email protected] ">" | ||
188 | [email protected] | ||
189 | [email protected] "(" | ||
190 | [email protected] ")" | ||
191 | [email protected] "\n" | ||
192 | [email protected] | ||
193 | [email protected] "where" | ||
194 | [email protected] "\n " | ||
195 | [email protected] | ||
196 | [email protected] "for" | ||
197 | [email protected] | ||
198 | [email protected] "<" | ||
199 | [email protected] | ||
200 | [email protected] "\'a" | ||
201 | [email protected] ">" | ||
202 | [email protected] " " | ||
203 | [email protected] | ||
204 | [email protected] "[" | ||
205 | [email protected] | ||
206 | [email protected] "&" | ||
207 | [email protected] "\'a" | ||
208 | [email protected] " " | ||
209 | [email protected] | ||
210 | [email protected] | ||
211 | [email protected] | ||
212 | [email protected] | ||
213 | [email protected] "F" | ||
214 | [email protected] "]" | ||
215 | [email protected] ":" | ||
216 | [email protected] " " | ||
217 | [email protected] | ||
218 | [email protected] | ||
219 | [email protected] | ||
220 | [email protected] | ||
221 | [email protected] | ||
222 | [email protected] | ||
223 | [email protected] "Eq" | ||
224 | [email protected] "\n" | ||
225 | [email protected] | ||
226 | [email protected] "{" | ||
227 | [email protected] " " | ||
228 | [email protected] "}" | ||
229 | [email protected] "\n" | ||
230 | [email protected] | ||
231 | [email protected] "fn" | ||
232 | [email protected] " " | ||
233 | [email protected] | ||
234 | [email protected] "for_qpath" | ||
235 | [email protected] | ||
236 | [email protected] "<" | ||
237 | [email protected] | ||
238 | [email protected] | ||
239 | [email protected] "T" | ||
240 | [email protected] ">" | ||
241 | [email protected] | ||
242 | [email protected] "(" | ||
243 | [email protected] | ||
244 | [email protected] | ||
245 | [email protected] | ||
246 | [email protected] "_t" | ||
247 | [email protected] ":" | ||
248 | [email protected] " " | ||
249 | [email protected] | ||
250 | [email protected] "&" | ||
251 | [email protected] | ||
252 | [email protected] | ||
253 | [email protected] | ||
254 | [email protected] | ||
255 | [email protected] "T" | ||
256 | [email protected] ")" | ||
257 | [email protected] "\n" | ||
258 | [email protected] | ||
259 | [email protected] "where" | ||
260 | [email protected] "\n " | ||
261 | [email protected] | ||
262 | [email protected] "for" | ||
263 | [email protected] | ||
264 | [email protected] "<" | ||
265 | [email protected] | ||
266 | [email protected] "\'a" | ||
267 | [email protected] ">" | ||
268 | [email protected] " " | ||
269 | [email protected] | ||
270 | [email protected] | ||
271 | [email protected] | ||
272 | [email protected] | ||
273 | [email protected] "<" | ||
274 | [email protected] | ||
275 | [email protected] "&" | ||
276 | [email protected] "\'a" | ||
277 | [email protected] " " | ||
278 | [email protected] | ||
279 | [email protected] | ||
280 | [email protected] | ||
281 | [email protected] | ||
282 | [email protected] "T" | ||
283 | [email protected] " " | ||
284 | [email protected] "as" | ||
285 | [email protected] " " | ||
286 | [email protected] | ||
287 | [email protected] | ||
288 | [email protected] | ||
289 | [email protected] | ||
290 | [email protected] "Baz" | ||
291 | [email protected] ">" | ||
292 | [email protected] "::" | ||
293 | [email protected] | ||
294 | [email protected] | ||
295 | [email protected] "Foo" | ||
296 | [email protected] ":" | ||
297 | [email protected] " " | ||
298 | [email protected] | ||
299 | [email protected] | ||
300 | [email protected] | ||
301 | [email protected] | ||
302 | [email protected] | ||
303 | [email protected] | ||
304 | [email protected] "Iterator" | ||
305 | [email protected] "\n" | ||
306 | [email protected] | ||
307 | [email protected] "{" | ||
308 | [email protected] " " | ||
309 | [email protected] "}" | ||
310 | [email protected] "\n" | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rs b/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rs index b448c6178..2d47596be 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rs +++ b/crates/ra_syntax/test_data/parser/inline/ok/0003_where_pred_for.rs | |||
@@ -1,4 +1,20 @@ | |||
1 | fn test<F>() | 1 | fn for_trait<F>() |
2 | where | 2 | where |
3 | for<'a> F: Fn(&'a str) | 3 | for<'a> F: Fn(&'a str) |
4 | { } | 4 | { } |
5 | fn for_ref<F>() | ||
6 | where | ||
7 | for<'a> &'a F: Debug | ||
8 | { } | ||
9 | fn for_parens<F>() | ||
10 | where | ||
11 | for<'a> (&'a F): Fn(&'a str) | ||
12 | { } | ||
13 | fn for_slice<F>() | ||
14 | where | ||
15 | for<'a> [&'a F]: Eq | ||
16 | { } | ||
17 | fn for_qpath<T>(_t: &T) | ||
18 | where | ||
19 | for<'a> <&'a T as Baz>::Foo: Iterator | ||
20 | { } | ||
diff --git a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast index dfb8d57ad..26a80017a 100644 --- a/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast +++ b/crates/ra_syntax/test_data/parser/inline/ok/0081_for_type.rast | |||
@@ -1,4 +1,4 @@ | |||
1 | [email protected]00 | 1 | SOURCE_FILE@0..82 |
2 | [email protected] | 2 | [email protected] |
3 | [email protected] "type" | 3 | [email protected] "type" |
4 | [email protected] " " | 4 | [email protected] " " |
@@ -29,212 +29,48 @@ [email protected] | |||
29 | [email protected] ")" | 29 | [email protected] ")" |
30 | [email protected] ";" | 30 | [email protected] ";" |
31 | [email protected] "\n" | 31 | [email protected] "\n" |
32 | [email protected] | 32 | [email protected] |
33 | [email protected] "fn" | 33 | [email protected] "type" |
34 | [email protected] " " | 34 | [email protected] " " |
35 | [email protected] | 35 | [email protected] |
36 | [email protected] "foo" | 36 | [email protected] "B" |
37 | [email protected] | 37 | [email protected] " " |
38 | [email protected] "<" | 38 | [email protected] "=" |
39 | [email protected] | 39 | [email protected] " " |
40 | [email protected] | 40 | [email protected] |
41 | [email protected] "T" | 41 | [email protected] "for" |
42 | [email protected] ">" | 42 | [email protected] |
43 | [email protected] | 43 | [email protected] "<" |
44 | [email protected] "(" | 44 | [email protected] |
45 | [email protected] | 45 | [email protected] "\'a" |
46 | [email protected] | 46 | [email protected] ">" |
47 | [email protected] | 47 | [email protected] " " |
48 | [email protected] "_t" | 48 | [email protected] |
49 | [email protected] ":" | 49 | [email protected] "unsafe" |
50 | [email protected] " " | 50 | [email protected] " " |
51 | [email protected] | 51 | [email protected] |
52 | [email protected] "&" | 52 | [email protected] "extern" |
53 | [email protected] | 53 | [email protected] " " |
54 | [email protected] | 54 | [email protected] "\"C\"" |
55 | [email protected] | 55 | [email protected] " " |
56 | [email protected] | 56 | [email protected] "fn" |
57 | [email protected] "T" | 57 | [email protected] |
58 | [email protected] ")" | 58 | [email protected] "(" |
59 | [email protected] " " | 59 | [email protected] |
60 | [email protected] | 60 | [email protected] |
61 | [email protected] "where" | 61 | [email protected] "&" |
62 | [email protected] " " | 62 | [email protected] "\'a" |
63 | [email protected] | 63 | [email protected] " " |
64 | [email protected] | 64 | [email protected] |
65 | [email protected] "for" | 65 | [email protected] "(" |
66 | [email protected] | 66 | [email protected] ")" |
67 | [email protected] "<" | 67 | [email protected] ")" |
68 | [email protected] | 68 | [email protected] " " |
69 | [email protected] "\'a" | 69 | [email protected] |
70 | [email protected] ">" | 70 | [email protected] "->" |
71 | [email protected] " " | 71 | [email protected] " " |
72 | [email protected] | 72 | [email protected] |
73 | [email protected] "&" | 73 | [email protected] "(" |
74 | [email protected] "\'a" | 74 | [email protected] ")" |
75 | [email protected] " " | 75 | [email protected] ";" |
76 | [email protected] | 76 | [email protected] "\n" |
77 | [email protected] | ||
78 | [email protected] | ||
79 | [email protected] | ||
80 | [email protected] "T" | ||
81 | [email protected] ":" | ||
82 | [email protected] " " | ||
83 | [email protected] | ||
84 | [email protected] | ||
85 | [email protected] | ||
86 | [email protected] | ||
87 | [email protected] | ||
88 | [email protected] | ||
89 | [email protected] "Iterator" | ||
90 | [email protected] " " | ||
91 | [email protected] | ||
92 | [email protected] "{" | ||
93 | [email protected] "}" | ||
94 | [email protected] "\n" | ||
95 | [email protected] | ||
96 | [email protected] "fn" | ||
97 | [email protected] " " | ||
98 | [email protected] | ||
99 | [email protected] "bar" | ||
100 | [email protected] | ||
101 | [email protected] "<" | ||
102 | [email protected] | ||
103 | [email protected] | ||
104 | [email protected] "T" | ||
105 | [email protected] ">" | ||
106 | [email protected] | ||
107 | [email protected] "(" | ||
108 | [email protected] | ||
109 | [email protected] | ||
110 | [email protected] | ||
111 | [email protected] "_t" | ||
112 | [email protected] ":" | ||
113 | [email protected] " " | ||
114 | [email protected] | ||
115 | [email protected] "&" | ||
116 | [email protected] | ||
117 | [email protected] | ||
118 | [email protected] | ||
119 | [email protected] | ||
120 | [email protected] "T" | ||
121 | [email protected] ")" | ||
122 | [email protected] " " | ||
123 | [email protected] | ||
124 | [email protected] "where" | ||
125 | [email protected] " " | ||
126 | [email protected] | ||
127 | [email protected] | ||
128 | [email protected] "for" | ||
129 | [email protected] | ||
130 | [email protected] "<" | ||
131 | [email protected] | ||
132 | [email protected] "\'a" | ||
133 | [email protected] ">" | ||
134 | [email protected] " " | ||
135 | [email protected] | ||
136 | [email protected] "&" | ||
137 | [email protected] "\'a" | ||
138 | [email protected] " " | ||
139 | [email protected] "mut" | ||
140 | [email protected] " " | ||
141 | [email protected] | ||
142 | [email protected] | ||
143 | [email protected] | ||
144 | [email protected] | ||
145 | [email protected] "T" | ||
146 | [email protected] ":" | ||
147 | [email protected] " " | ||
148 | [email protected] | ||
149 | [email protected] | ||
150 | [email protected] | ||
151 | [email protected] | ||
152 | [email protected] | ||
153 | [email protected] | ||
154 | [email protected] "Iterator" | ||
155 | [email protected] " " | ||
156 | [email protected] | ||
157 | [email protected] "{" | ||
158 | [email protected] "}" | ||
159 | [email protected] "\n" | ||
160 | [email protected] | ||
161 | [email protected] "fn" | ||
162 | [email protected] " " | ||
163 | [email protected] | ||
164 | [email protected] "baz" | ||
165 | [email protected] | ||
166 | [email protected] "<" | ||
167 | [email protected] | ||
168 | [email protected] | ||
169 | [email protected] "T" | ||
170 | [email protected] ">" | ||
171 | [email protected] | ||
172 | [email protected] "(" | ||
173 | [email protected] | ||
174 | [email protected] | ||
175 | [email protected] | ||
176 | [email protected] "_t" | ||
177 | [email protected] ":" | ||
178 | [email protected] " " | ||
179 | [email protected] | ||
180 | [email protected] "&" | ||
181 | [email protected] | ||
182 | [email protected] | ||
183 | [email protected] | ||
184 | [email protected] | ||
185 | [email protected] "T" | ||
186 | [email protected] ")" | ||
187 | [email protected] " " | ||
188 | [email protected] | ||
189 | [email protected] "where" | ||
190 | [email protected] " " | ||
191 | [email protected] | ||
192 | [email protected] | ||
193 | [email protected] "for" | ||
194 | [email protected] | ||
195 | [email protected] "<" | ||
196 | [email protected] | ||
197 | [email protected] "\'a" | ||
198 | [email protected] ">" | ||
199 | [email protected] " " | ||
200 | [email protected] | ||
201 | [email protected] | ||
202 | [email protected] | ||
203 | [email protected] | ||
204 | [email protected] "<" | ||
205 | [email protected] | ||
206 | [email protected] "&" | ||
207 | [email protected] "\'a" | ||
208 | [email protected] " " | ||
209 | [email protected] | ||
210 | [email protected] | ||
211 | [email protected] | ||
212 | [email protected] | ||
213 | [email protected] "T" | ||
214 | [email protected] " " | ||
215 | [email protected] "as" | ||
216 | [email protected] " " | ||
217 | [email protected] | ||
218 | [email protected] | ||
219 | [email protected] | ||
220 | [email protected] | ||
221 | [email protected] "Baz" | ||
222 | [email protected] ">" | ||
223 | [email protected] "::" | ||
224 | [email protected] | ||
225 | [email protected] | ||
226 | [email protected] "Foo" | ||
227 | [email protected] ":" | ||
228 | [email protected] " " | ||
229 | [email protected] | ||
230 | [email protected] | ||
231 | [email protected] | ||
232 | [email protected] | ||
233 | [email protected] | ||
234 | [email protected] | ||
235 | [email protected] "Iterator" | ||
236 | [email protected] " " | ||
237 | [email protected] | ||
238 | [email protected] "{" | ||
239 | [email protected] "}" | ||
240 | [email protected] "\n" | ||
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 d6774d438..457e8744f 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,4 +1,2 @@ | |||
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 | type B = for<'a> unsafe extern "C" fn(&'a ()) -> (); |
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/xtask/src/ast_src.rs b/xtask/src/ast_src.rs index f60f0fb16..392648d71 100644 --- a/xtask/src/ast_src.rs +++ b/xtask/src/ast_src.rs | |||
@@ -1707,7 +1707,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc { | |||
1707 | /// ``` | 1707 | /// ``` |
1708 | /// | 1708 | /// |
1709 | /// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses) | 1709 | /// [Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses) |
1710 | struct WherePred: TypeBoundsOwner { T![lifetime], TypeRef } | 1710 | struct WherePred: TypeBoundsOwner { T![for], TypeParamList, T![lifetime], TypeRef } |
1711 | 1711 | ||
1712 | /// Where clause. | 1712 | /// Where clause. |
1713 | /// | 1713 | /// |