diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-01-09 17:44:31 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-01-09 17:44:31 +0000 |
commit | b77a7e29a5b345a5dcdf427a0b332630147bcd5b (patch) | |
tree | db971989f71796845e9e7cd5396d6b49be61a0a9 /crates/ra_parser/src/grammar | |
parent | c2bbfb9a5f614719c9805c7921653c8e4b85b1f1 (diff) | |
parent | aa433c67d85c5e56c1343ac5eb62872502ca8d55 (diff) |
Merge #2779
2779: Parse trait aliases r=matklad a=kiljacken
Implements the needed changes to correctly parse trait aliases.
This is my first change in the parser code, so would appreciate a comment on whether this is the right way to go about it.
Co-authored-by: Emil Lauridsen <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r-- | crates/ra_parser/src/grammar/items/traits.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/ra_parser/src/grammar/items/traits.rs b/crates/ra_parser/src/grammar/items/traits.rs index 964fd3041..03dae3cdb 100644 --- a/crates/ra_parser/src/grammar/items/traits.rs +++ b/crates/ra_parser/src/grammar/items/traits.rs | |||
@@ -10,6 +10,16 @@ pub(super) fn trait_def(p: &mut Parser) { | |||
10 | p.bump(T![trait]); | 10 | p.bump(T![trait]); |
11 | name_r(p, ITEM_RECOVERY_SET); | 11 | name_r(p, ITEM_RECOVERY_SET); |
12 | type_params::opt_type_param_list(p); | 12 | type_params::opt_type_param_list(p); |
13 | // test trait_alias | ||
14 | // trait Z<U> = T<U>; | ||
15 | // trait Z<U> = T<U> where U: Copy; | ||
16 | // trait Z<U> = where Self: T<U>; | ||
17 | if p.eat(T![=]) { | ||
18 | type_params::bounds_without_colon(p); | ||
19 | type_params::opt_where_clause(p); | ||
20 | p.expect(T![;]); | ||
21 | return; | ||
22 | } | ||
13 | if p.at(T![:]) { | 23 | if p.at(T![:]) { |
14 | type_params::bounds(p); | 24 | type_params::bounds(p); |
15 | } | 25 | } |