aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/grammar
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-02-18 06:14:39 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-02-18 06:14:39 +0000
commitb5df9656245079d3dc4457ae326f9710ff58a298 (patch)
treec67fd94ddc80df9dce459f4cdc526d89e4284e99 /crates/ra_syntax/src/grammar
parenta725dd4f7ac2b88541189f0f726ce86876c36add (diff)
parent58d14bcaf70662506e1a289494365d976b40fc4e (diff)
Merge #851
851: Enable parsing attributes for generic lifetimes and type parameters r=matklad a=vipentti Co-authored-by: Ville Penttinen <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/grammar')
-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);