aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/grammar/params.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-24 18:50:37 +0100
committerAleksey Kladov <[email protected]>2018-08-24 18:50:37 +0100
commitf104458d45e30024f8a4a02c1ad4101ed74b08f9 (patch)
tree4317dc4c504a90ea0876c862b049eee6d6513e98 /crates/libsyntax2/src/grammar/params.rs
parentb0aac1ca98280efee9587897d86ef447933004dd (diff)
parameter parsing does not destroy blocks
Diffstat (limited to 'crates/libsyntax2/src/grammar/params.rs')
-rw-r--r--crates/libsyntax2/src/grammar/params.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/libsyntax2/src/grammar/params.rs b/crates/libsyntax2/src/grammar/params.rs
index 5b1322b3a..bc0cb44ba 100644
--- a/crates/libsyntax2/src/grammar/params.rs
+++ b/crates/libsyntax2/src/grammar/params.rs
@@ -48,6 +48,10 @@ fn list_(p: &mut Parser, flavor: Flavor) {
48 opt_self_param(p); 48 opt_self_param(p);
49 } 49 }
50 while !p.at(EOF) && !p.at(ket) { 50 while !p.at(EOF) && !p.at(ket) {
51 if !VALUE_PARAMETER_FIRST.contains(p.current()) {
52 p.error("expected value parameter");
53 break;
54 }
51 value_parameter(p, flavor); 55 value_parameter(p, flavor);
52 if !p.at(ket) { 56 if !p.at(ket) {
53 p.expect(COMMA); 57 p.expect(COMMA);
@@ -57,6 +61,13 @@ fn list_(p: &mut Parser, flavor: Flavor) {
57 m.complete(p, PARAM_LIST); 61 m.complete(p, PARAM_LIST);
58} 62}
59 63
64
65const VALUE_PARAMETER_FIRST: TokenSet =
66 token_set_union![
67 patterns::PATTERN_FIRST,
68 types::TYPE_FIRST,
69 ];
70
60fn value_parameter(p: &mut Parser, flavor: Flavor) { 71fn value_parameter(p: &mut Parser, flavor: Flavor) {
61 let m = p.start(); 72 let m = p.start();
62 match flavor { 73 match flavor {