aboutsummaryrefslogtreecommitdiff
path: root/src/grammar/params.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/grammar/params.rs')
-rw-r--r--src/grammar/params.rs32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/grammar/params.rs b/src/grammar/params.rs
index c7f17168b..32e905cb2 100644
--- a/src/grammar/params.rs
+++ b/src/grammar/params.rs
@@ -33,12 +33,6 @@ impl Flavor {
33 _ => true, 33 _ => true,
34 } 34 }
35 } 35 }
36 fn pattern_required(self) -> bool {
37 match self {
38 Flavor::OptionalPattern => false,
39 _ => true,
40 }
41 }
42} 36}
43 37
44fn list_(p: &mut Parser, flavor: Flavor) { 38fn list_(p: &mut Parser, flavor: Flavor) {
@@ -65,9 +59,29 @@ fn list_(p: &mut Parser, flavor: Flavor) {
65 59
66fn value_parameter(p: &mut Parser, flavor: Flavor) { 60fn value_parameter(p: &mut Parser, flavor: Flavor) {
67 let m = p.start(); 61 let m = p.start();
68 patterns::pattern(p); 62 match flavor {
69 if p.at(COLON) || flavor.type_required() { 63 Flavor::OptionalType | Flavor::Normal => {
70 types::ascription(p) 64 patterns::pattern(p);
65 if p.at(COLON) || flavor.type_required() {
66 types::ascription(p)
67 }
68 },
69 // test value_parameters_no_patterns
70 // type F = Box<Fn(a: i32, &b: &i32, &mut c: &i32, ())>;
71 Flavor::OptionalPattern => {
72 let la0 = p.current();
73 let la1 = p.nth(1);
74 let la2 = p.nth(2);
75 let la3 = p.nth(3);
76 if la0 == IDENT && la1 == COLON
77 || la0 == AMP && la1 == IDENT && la2 == COLON
78 || la0 == AMP && la1 == MUT_KW && la2 == IDENT && la3 == COLON {
79 patterns::pattern(p);
80 types::ascription(p);
81 } else {
82 types::type_(p);
83 }
84 },
71 } 85 }
72 m.complete(p, PARAM); 86 m.complete(p, PARAM);
73} 87}