diff options
Diffstat (limited to 'crates/parser/src/grammar/items.rs')
-rw-r--r-- | crates/parser/src/grammar/items.rs | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/crates/parser/src/grammar/items.rs b/crates/parser/src/grammar/items.rs index d091b0fbb..b2f7cc21f 100644 --- a/crates/parser/src/grammar/items.rs +++ b/crates/parser/src/grammar/items.rs | |||
@@ -6,9 +6,9 @@ mod traits; | |||
6 | mod use_item; | 6 | mod use_item; |
7 | 7 | ||
8 | pub(crate) use self::{ | 8 | pub(crate) use self::{ |
9 | adt::{enum_variant_list, record_field_def_list}, | 9 | adt::{record_field_list, variant_list}, |
10 | expressions::{match_arm_list, record_field_list}, | 10 | expressions::{match_arm_list, record_expr_field_list}, |
11 | traits::{impl_item_list, trait_item_list}, | 11 | traits::assoc_item_list, |
12 | use_item::use_tree_list, | 12 | use_item::use_tree_list, |
13 | }; | 13 | }; |
14 | use super::*; | 14 | use super::*; |
@@ -20,7 +20,7 @@ use super::*; | |||
20 | // super::baz! {} | 20 | // super::baz! {} |
21 | // struct S; | 21 | // struct S; |
22 | pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { | 22 | pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { |
23 | attributes::inner_attributes(p); | 23 | attributes::inner_attrs(p); |
24 | while !(stop_on_r_curly && p.at(T!['}']) || p.at(EOF)) { | 24 | while !(stop_on_r_curly && p.at(T!['}']) || p.at(EOF)) { |
25 | item_or_macro(p, stop_on_r_curly) | 25 | item_or_macro(p, stop_on_r_curly) |
26 | } | 26 | } |
@@ -33,7 +33,7 @@ pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![ | |||
33 | 33 | ||
34 | pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) { | 34 | pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool) { |
35 | let m = p.start(); | 35 | let m = p.start(); |
36 | attributes::outer_attributes(p); | 36 | attributes::outer_attrs(p); |
37 | let m = match maybe_item(p, m) { | 37 | let m = match maybe_item(p, m) { |
38 | Ok(()) => { | 38 | Ok(()) => { |
39 | if p.at(T![;]) { | 39 | if p.at(T![;]) { |
@@ -144,30 +144,30 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker) -> Result<(), Marker> { | |||
144 | // test fn | 144 | // test fn |
145 | // fn foo() {} | 145 | // fn foo() {} |
146 | T![fn] => { | 146 | T![fn] => { |
147 | fn_def(p); | 147 | fn_(p); |
148 | m.complete(p, FN); | 148 | m.complete(p, FN); |
149 | } | 149 | } |
150 | 150 | ||
151 | // test trait | 151 | // test trait |
152 | // trait T {} | 152 | // trait T {} |
153 | T![trait] => { | 153 | T![trait] => { |
154 | traits::trait_def(p); | 154 | traits::trait_(p); |
155 | m.complete(p, TRAIT); | 155 | m.complete(p, TRAIT); |
156 | } | 156 | } |
157 | 157 | ||
158 | T![const] => { | 158 | T![const] => { |
159 | consts::const_def(p, m); | 159 | consts::konst(p, m); |
160 | } | 160 | } |
161 | 161 | ||
162 | // test impl | 162 | // test impl |
163 | // impl T for S {} | 163 | // impl T for S {} |
164 | T![impl] => { | 164 | T![impl] => { |
165 | traits::impl_def(p); | 165 | traits::impl_(p); |
166 | m.complete(p, IMPL); | 166 | m.complete(p, IMPL); |
167 | } | 167 | } |
168 | 168 | ||
169 | T![type] => { | 169 | T![type] => { |
170 | type_def(p, m); | 170 | type_alias(p, m); |
171 | } | 171 | } |
172 | _ => { | 172 | _ => { |
173 | if !has_visibility && !has_mods { | 173 | if !has_visibility && !has_mods { |
@@ -190,9 +190,9 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> { | |||
190 | match p.current() { | 190 | match p.current() { |
191 | // test extern_crate | 191 | // test extern_crate |
192 | // extern crate foo; | 192 | // extern crate foo; |
193 | T![extern] if la == T![crate] => extern_crate_item(p, m), | 193 | T![extern] if la == T![crate] => extern_crate(p, m), |
194 | T![type] => { | 194 | T![type] => { |
195 | type_def(p, m); | 195 | type_alias(p, m); |
196 | } | 196 | } |
197 | T![mod] => mod_item(p, m), | 197 | T![mod] => mod_item(p, m), |
198 | T![struct] => { | 198 | T![struct] => { |
@@ -205,7 +205,7 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> { | |||
205 | // a: i32, | 205 | // a: i32, |
206 | // b: f32, | 206 | // b: f32, |
207 | // } | 207 | // } |
208 | adt::struct_def(p, m); | 208 | adt::strukt(p, m); |
209 | } | 209 | } |
210 | // test pub_macro_def | 210 | // test pub_macro_def |
211 | // pub macro m($:ident) {} | 211 | // pub macro m($:ident) {} |
@@ -219,12 +219,12 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> { | |||
219 | // a: i32, | 219 | // a: i32, |
220 | // b: f32, | 220 | // b: f32, |
221 | // } | 221 | // } |
222 | adt::union_def(p, m); | 222 | adt::union(p, m); |
223 | } | 223 | } |
224 | T![enum] => adt::enum_def(p, m), | 224 | T![enum] => adt::enum_(p, m), |
225 | T![use] => use_item::use_item(p, m), | 225 | T![use] => use_item::use_(p, m), |
226 | T![const] if (la == IDENT || la == T![_] || la == T![mut]) => consts::const_def(p, m), | 226 | T![const] if (la == IDENT || la == T![_] || la == T![mut]) => consts::konst(p, m), |
227 | T![static] => consts::static_def(p, m), | 227 | T![static] => consts::static_(p, m), |
228 | // test extern_block | 228 | // test extern_block |
229 | // extern {} | 229 | // extern {} |
230 | T![extern] | 230 | T![extern] |
@@ -239,7 +239,7 @@ fn items_without_modifiers(p: &mut Parser, m: Marker) -> Result<(), Marker> { | |||
239 | Ok(()) | 239 | Ok(()) |
240 | } | 240 | } |
241 | 241 | ||
242 | fn extern_crate_item(p: &mut Parser, m: Marker) { | 242 | fn extern_crate(p: &mut Parser, m: Marker) { |
243 | assert!(p.at(T![extern])); | 243 | assert!(p.at(T![extern])); |
244 | p.bump(T![extern]); | 244 | p.bump(T![extern]); |
245 | assert!(p.at(T![crate])); | 245 | assert!(p.at(T![crate])); |
@@ -251,7 +251,7 @@ fn extern_crate_item(p: &mut Parser, m: Marker) { | |||
251 | name_ref(p); | 251 | name_ref(p); |
252 | } | 252 | } |
253 | 253 | ||
254 | opt_alias(p); | 254 | opt_rename(p); |
255 | p.expect(T![;]); | 255 | p.expect(T![;]); |
256 | m.complete(p, EXTERN_CRATE); | 256 | m.complete(p, EXTERN_CRATE); |
257 | } | 257 | } |
@@ -265,14 +265,14 @@ pub(crate) fn extern_item_list(p: &mut Parser) { | |||
265 | m.complete(p, EXTERN_ITEM_LIST); | 265 | m.complete(p, EXTERN_ITEM_LIST); |
266 | } | 266 | } |
267 | 267 | ||
268 | fn fn_def(p: &mut Parser) { | 268 | fn fn_(p: &mut Parser) { |
269 | assert!(p.at(T![fn])); | 269 | assert!(p.at(T![fn])); |
270 | p.bump(T![fn]); | 270 | p.bump(T![fn]); |
271 | 271 | ||
272 | name_r(p, ITEM_RECOVERY_SET); | 272 | name_r(p, ITEM_RECOVERY_SET); |
273 | // test function_type_params | 273 | // test function_type_params |
274 | // fn foo<T: Clone + Copy>(){} | 274 | // fn foo<T: Clone + Copy>(){} |
275 | type_params::opt_type_param_list(p); | 275 | type_params::opt_generic_param_list(p); |
276 | 276 | ||
277 | if p.at(T!['(']) { | 277 | if p.at(T!['(']) { |
278 | params::param_list_fn_def(p); | 278 | params::param_list_fn_def(p); |
@@ -282,7 +282,7 @@ fn fn_def(p: &mut Parser) { | |||
282 | // test function_ret_type | 282 | // test function_ret_type |
283 | // fn foo() {} | 283 | // fn foo() {} |
284 | // fn bar() -> () {} | 284 | // fn bar() -> () {} |
285 | opt_fn_ret_type(p); | 285 | opt_ret_type(p); |
286 | 286 | ||
287 | // test function_where_clause | 287 | // test function_where_clause |
288 | // fn foo<T>() where T: Copy {} | 288 | // fn foo<T>() where T: Copy {} |
@@ -299,7 +299,7 @@ fn fn_def(p: &mut Parser) { | |||
299 | 299 | ||
300 | // test type_item | 300 | // test type_item |
301 | // type Foo = Bar; | 301 | // type Foo = Bar; |
302 | fn type_def(p: &mut Parser, m: Marker) { | 302 | fn type_alias(p: &mut Parser, m: Marker) { |
303 | assert!(p.at(T![type])); | 303 | assert!(p.at(T![type])); |
304 | p.bump(T![type]); | 304 | p.bump(T![type]); |
305 | 305 | ||
@@ -307,7 +307,7 @@ fn type_def(p: &mut Parser, m: Marker) { | |||
307 | 307 | ||
308 | // test type_item_type_params | 308 | // test type_item_type_params |
309 | // type Result<T> = (); | 309 | // type Result<T> = (); |
310 | type_params::opt_type_param_list(p); | 310 | type_params::opt_generic_param_list(p); |
311 | 311 | ||
312 | if p.at(T![:]) { | 312 | if p.at(T![:]) { |
313 | type_params::bounds(p); | 313 | type_params::bounds(p); |
@@ -329,14 +329,14 @@ pub(crate) fn mod_item(p: &mut Parser, m: Marker) { | |||
329 | 329 | ||
330 | name(p); | 330 | name(p); |
331 | if p.at(T!['{']) { | 331 | if p.at(T!['{']) { |
332 | mod_item_list(p); | 332 | item_list(p); |
333 | } else if !p.eat(T![;]) { | 333 | } else if !p.eat(T![;]) { |
334 | p.error("expected `;` or `{`"); | 334 | p.error("expected `;` or `{`"); |
335 | } | 335 | } |
336 | m.complete(p, MODULE); | 336 | m.complete(p, MODULE); |
337 | } | 337 | } |
338 | 338 | ||
339 | pub(crate) fn mod_item_list(p: &mut Parser) { | 339 | pub(crate) fn item_list(p: &mut Parser) { |
340 | assert!(p.at(T!['{'])); | 340 | assert!(p.at(T!['{'])); |
341 | let m = p.start(); | 341 | let m = p.start(); |
342 | p.bump(T!['{']); | 342 | p.bump(T!['{']); |