@@ -7,14 +7,14 @@ use super::*;
7
7
// fn b(x: i32) {}
8
8
// fn c(x: i32, ) {}
9
9
// fn d(x: i32, y: ()) {}
10
- pub ( super ) fn param_list_fn ( p : & mut Parser ) {
11
- list_ ( p, Flavor :: Function )
10
+ pub ( super ) fn param_list_fn_def ( p : & mut Parser ) {
11
+ list_ ( p, Flavor :: FnDef )
12
12
}
13
13
14
14
// test param_list_opt_patterns
15
15
// fn foo<F: FnMut(&mut Foo<'a>)>(){}
16
- pub ( super ) fn param_list_impl_fn ( p : & mut Parser ) {
17
- list_ ( p, Flavor :: ImplFn )
16
+ pub ( super ) fn param_list_fn_trait ( p : & mut Parser ) {
17
+ list_ ( p, Flavor :: FnTrait )
18
18
}
19
19
20
20
pub ( super ) fn param_list_fn_ptr ( p : & mut Parser ) {
@@ -27,8 +27,8 @@ pub(super) fn param_list_closure(p: &mut Parser) {
27
27
28
28
#[ derive( Debug , Clone , Copy ) ]
29
29
enum Flavor {
30
- Function , // Includes trait fn params; omitted param idents are not supported
31
- ImplFn ,
30
+ FnDef , // Includes trait fn params; omitted param idents are not supported
31
+ FnTrait , // Params for `Fn(...)`/`FnMut(...)`/`FnOnce(...)` annotations
32
32
FnPointer ,
33
33
Closure ,
34
34
}
@@ -38,13 +38,13 @@ fn list_(p: &mut Parser, flavor: Flavor) {
38
38
39
39
let ( bra, ket) = match flavor {
40
40
Closure => ( T ! [ |] , T ! [ |] ) ,
41
- Function | ImplFn | FnPointer => ( T ! [ '(' ] , T ! [ ')' ] ) ,
41
+ FnDef | FnTrait | FnPointer => ( T ! [ '(' ] , T ! [ ')' ] ) ,
42
42
} ;
43
43
44
44
let m = p. start ( ) ;
45
45
p. bump ( bra) ;
46
46
47
- if let Function = flavor {
47
+ if let FnDef = flavor {
48
48
// test self_param_outer_attr
49
49
// fn f(#[must_use] self) {}
50
50
attributes:: outer_attributes ( p) ;
@@ -56,10 +56,11 @@ fn list_(p: &mut Parser, flavor: Flavor) {
56
56
// fn f(#[attr1] pat: Type) {}
57
57
attributes:: outer_attributes ( p) ;
58
58
59
- if let Function | FnPointer = flavor {
60
- if p. at ( T ! [ ...] ) {
61
- break ;
62
- }
59
+ // test param_list_vararg
60
+ // extern "C" { fn printf(format: *const i8, ...) -> i32; }
61
+ match flavor {
62
+ FnDef | FnPointer if p. eat ( T ! [ ...] ) => break ,
63
+ _ => ( ) ,
63
64
}
64
65
65
66
if !p. at_ts ( VALUE_PARAMETER_FIRST ) {
@@ -71,11 +72,7 @@ fn list_(p: &mut Parser, flavor: Flavor) {
71
72
p. expect ( T ! [ , ] ) ;
72
73
}
73
74
}
74
- // test param_list_vararg
75
- // extern "C" { fn printf(format: *const i8, ...) -> i32; }
76
- if let Function | FnPointer = flavor {
77
- p. eat ( T ! [ ...] ) ;
78
- }
75
+
79
76
p. expect ( ket) ;
80
77
m. complete ( p, PARAM_LIST ) ;
81
78
}
@@ -105,13 +102,13 @@ fn value_parameter(p: &mut Parser, flavor: Flavor) {
105
102
// fn f3(NewType(a): NewType) {}
106
103
// fn f4(&&a: &&usize) {}
107
104
// }
108
- Flavor :: Function => {
105
+ Flavor :: FnDef => {
109
106
patterns:: pattern ( p) ;
110
107
types:: ascription ( p) ;
111
108
}
112
109
// test value_parameters_no_patterns
113
110
// type F = Box<Fn(i32, &i32, &i32, ())>;
114
- Flavor :: ImplFn => {
111
+ Flavor :: FnTrait => {
115
112
types:: type_ ( p) ;
116
113
}
117
114
// test fn_pointer_param_ident_path
0 commit comments