diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-18 06:14:39 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-18 06:14:39 +0000 |
commit | b5df9656245079d3dc4457ae326f9710ff58a298 (patch) | |
tree | c67fd94ddc80df9dce459f4cdc526d89e4284e99 /crates/ra_syntax/src/grammar | |
parent | a725dd4f7ac2b88541189f0f726ce86876c36add (diff) | |
parent | 58d14bcaf70662506e1a289494365d976b40fc4e (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.rs | 22 |
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 | ||
29 | fn lifetime_param(p: &mut Parser) { | 39 | fn 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 | ||
39 | fn type_param(p: &mut Parser) { | 48 | fn 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); |