@@ -184,34 +184,14 @@ pub(super) fn opt_item(p: &mut Parser, m: Marker) -> Result<(), Marker> {
184184
185185 // items
186186 match p. current ( ) {
187- // test fn
188- // fn foo() {}
189- T ! [ fn ] => {
190- fn_ ( p) ;
191- m. complete ( p, FN ) ;
192- }
187+ T ! [ fn ] => fn_ ( p, m) ,
193188
194- // test trait
195- // trait T {}
196- T ! [ trait ] => {
197- traits:: trait_ ( p) ;
198- m. complete ( p, TRAIT ) ;
199- }
189+ T ! [ const ] if p. nth ( 1 ) != T ! [ '{' ] => consts:: konst ( p, m) ,
200190
201- T ! [ const ] if p. nth ( 1 ) != T ! [ '{' ] => {
202- consts:: konst ( p, m) ;
203- }
204-
205- // test impl
206- // impl T for S {}
207- T ! [ impl ] => {
208- traits:: impl_ ( p) ;
209- m. complete ( p, IMPL ) ;
210- }
191+ T ! [ trait ] => traits:: trait_ ( p, m) ,
192+ T ! [ impl ] => traits:: impl_ ( p, m) ,
211193
212- T ! [ type ] => {
213- type_alias ( p, m) ;
214- }
194+ T ! [ type ] => type_alias ( p, m) ,
215195
216196 // test extern_block
217197 // unsafe extern "C" {}
@@ -339,38 +319,6 @@ pub(crate) fn extern_item_list(p: &mut Parser) {
339319 m. complete ( p, EXTERN_ITEM_LIST ) ;
340320}
341321
342- fn fn_ ( p : & mut Parser ) {
343- assert ! ( p. at( T ![ fn ] ) ) ;
344- p. bump ( T ! [ fn ] ) ;
345-
346- name_r ( p, ITEM_RECOVERY_SET ) ;
347- // test function_type_params
348- // fn foo<T: Clone + Copy>(){}
349- type_params:: opt_generic_param_list ( p) ;
350-
351- if p. at ( T ! [ '(' ] ) {
352- params:: param_list_fn_def ( p) ;
353- } else {
354- p. error ( "expected function arguments" ) ;
355- }
356- // test function_ret_type
357- // fn foo() {}
358- // fn bar() -> () {}
359- opt_ret_type ( p) ;
360-
361- // test function_where_clause
362- // fn foo<T>() where T: Copy {}
363- type_params:: opt_where_clause ( p) ;
364-
365- // test fn_decl
366- // trait T { fn foo(); }
367- if p. at ( T ! [ ; ] ) {
368- p. bump ( T ! [ ; ] ) ;
369- } else {
370- expressions:: block_expr ( p)
371- }
372- }
373-
374322fn macro_rules ( p : & mut Parser , m : Marker ) {
375323 assert ! ( p. at_contextual_kw( "macro_rules" ) ) ;
376324 p. bump_remap ( T ! [ macro_rules] ) ;
@@ -428,6 +376,40 @@ fn macro_def(p: &mut Parser, m: Marker) {
428376 m. complete ( p, MACRO_DEF ) ;
429377}
430378
379+ // test fn
380+ // fn foo() {}
381+ fn fn_ ( p : & mut Parser , m : Marker ) {
382+ p. bump ( T ! [ fn ] ) ;
383+
384+ name_r ( p, ITEM_RECOVERY_SET ) ;
385+ // test function_type_params
386+ // fn foo<T: Clone + Copy>(){}
387+ type_params:: opt_generic_param_list ( p) ;
388+
389+ if p. at ( T ! [ '(' ] ) {
390+ params:: param_list_fn_def ( p) ;
391+ } else {
392+ p. error ( "expected function arguments" ) ;
393+ }
394+ // test function_ret_type
395+ // fn foo() {}
396+ // fn bar() -> () {}
397+ opt_ret_type ( p) ;
398+
399+ // test function_where_clause
400+ // fn foo<T>() where T: Copy {}
401+ type_params:: opt_where_clause ( p) ;
402+
403+ // test fn_decl
404+ // trait T { fn foo(); }
405+ if p. at ( T ! [ ; ] ) {
406+ p. bump ( T ! [ ; ] ) ;
407+ } else {
408+ expressions:: block_expr ( p)
409+ }
410+ m. complete ( p, FN ) ;
411+ }
412+
431413fn macro_call ( p : & mut Parser ) -> BlockLike {
432414 assert ! ( paths:: is_use_path_start( p) ) ;
433415 paths:: use_path ( p) ;
0 commit comments