aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/grammar/type_params.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/grammar/type_params.rs')
-rw-r--r--crates/ra_syntax/src/grammar/type_params.rs22
1 files changed, 15 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/grammar/type_params.rs b/crates/ra_syntax/src/grammar/type_params.rs
index 1ec813b3e..40f998682 100644
--- a/crates/ra_syntax/src/grammar/type_params.rs
+++ b/crates/ra_syntax/src/grammar/type_params.rs
@@ -13,10 +13,20 @@ fn type_param_list(p: &mut Parser) {
13 p.bump(); 13 p.bump();
14 14
15 while !p.at(EOF) && !p.at(R_ANGLE) { 15 while !p.at(EOF) && !p.at(R_ANGLE) {
16 let m = p.start();
17
18 // test generic_lifetime_type_attribute
19 // fn foo<#[derive(Lifetime)] 'a, #[derive(Type)] T>(_: &'a T) {
20 // }
21 attributes::outer_attributes(p);
22
16 match p.current() { 23 match p.current() {
17 LIFETIME => lifetime_param(p), 24 LIFETIME => lifetime_param(p, m),
18 IDENT => type_param(p), 25 IDENT => type_param(p, m),
19 _ => p.err_and_bump("expected type parameter"), 26 _ => {
27 m.abandon(p);
28 p.err_and_bump("expected type parameter")
29 }
20 } 30 }
21 if !p.at(R_ANGLE) && !p.expect(COMMA) { 31 if !p.at(R_ANGLE) && !p.expect(COMMA) {
22 break; 32 break;
@@ -26,9 +36,8 @@ fn type_param_list(p: &mut Parser) {
26 m.complete(p, TYPE_PARAM_LIST); 36 m.complete(p, TYPE_PARAM_LIST);
27} 37}
28 38
29fn lifetime_param(p: &mut Parser) { 39fn lifetime_param(p: &mut Parser, m: Marker) {
30 assert!(p.at(LIFETIME)); 40 assert!(p.at(LIFETIME));
31 let m = p.start();
32 p.bump(); 41 p.bump();
33 if p.at(COLON) { 42 if p.at(COLON) {
34 lifetime_bounds(p); 43 lifetime_bounds(p);
@@ -36,9 +45,8 @@ fn lifetime_param(p: &mut Parser) {
36 m.complete(p, LIFETIME_PARAM); 45 m.complete(p, LIFETIME_PARAM);
37} 46}
38 47
39fn type_param(p: &mut Parser) { 48fn type_param(p: &mut Parser, m: Marker) {
40 assert!(p.at(IDENT)); 49 assert!(p.at(IDENT));
41 let m = p.start();
42 name(p); 50 name(p);
43 if p.at(COLON) { 51 if p.at(COLON) {
44 bounds(p); 52 bounds(p);