aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar
diff options
context:
space:
mode:
authorVille Penttinen <[email protected]>2019-03-30 15:11:21 +0000
committerVille Penttinen <[email protected]>2019-03-30 15:11:21 +0000
commit23fdc562bf06bd001ec728d63a8f5b945bd96700 (patch)
treeace25468b177e1fa5899ca18daee48cc420372ed /crates/ra_parser/src/grammar
parent9ebd14a14e20aebc8e176a8dcb22376eb3a4d73e (diff)
Add new TYPE_BOUND_LIST and TYPE_BOUND syntax kinds
These are now used when parsing type bounds. In addition parsing paths inside a bound now does not recursively parse paths, rather they are treated as separate bounds, separated by +.
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r--crates/ra_parser/src/grammar/items/traits.rs1
-rw-r--r--crates/ra_parser/src/grammar/type_params.rs11
2 files changed, 10 insertions, 2 deletions
diff --git a/crates/ra_parser/src/grammar/items/traits.rs b/crates/ra_parser/src/grammar/items/traits.rs
index f49615f6b..d03a6be0d 100644
--- a/crates/ra_parser/src/grammar/items/traits.rs
+++ b/crates/ra_parser/src/grammar/items/traits.rs
@@ -2,6 +2,7 @@ use super::*;
2 2
3// test trait_item 3// test trait_item
4// trait T<U>: Hash + Clone where U: Copy {} 4// trait T<U>: Hash + Clone where U: Copy {}
5// trait X<U: Debug + Display>: Hash + Clone where U: Copy {}
5pub(super) fn trait_def(p: &mut Parser) { 6pub(super) fn trait_def(p: &mut Parser) {
6 assert!(p.at(TRAIT_KW)); 7 assert!(p.at(TRAIT_KW));
7 p.bump(); 8 p.bump();
diff --git a/crates/ra_parser/src/grammar/type_params.rs b/crates/ra_parser/src/grammar/type_params.rs
index 40f998682..e28c124cd 100644
--- a/crates/ra_parser/src/grammar/type_params.rs
+++ b/crates/ra_parser/src/grammar/type_params.rs
@@ -80,22 +80,29 @@ fn lifetime_bounds(p: &mut Parser) {
80} 80}
81 81
82pub(super) fn bounds_without_colon(p: &mut Parser) { 82pub(super) fn bounds_without_colon(p: &mut Parser) {
83 let outer = p.start();
83 loop { 84 loop {
85 let inner = p.start();
84 let has_paren = p.eat(L_PAREN); 86 let has_paren = p.eat(L_PAREN);
85 p.eat(QUESTION); 87 p.eat(QUESTION);
86 match p.current() { 88 match p.current() {
87 LIFETIME => p.bump(), 89 LIFETIME => p.bump(),
88 FOR_KW => types::for_type(p), 90 FOR_KW => types::for_type(p),
89 _ if paths::is_path_start(p) => types::path_type(p), 91 _ if paths::is_path_start(p) => types::path_type_(p, false),
90 _ => break, 92 _ => {
93 inner.abandon(p);
94 break;
95 }
91 } 96 }
92 if has_paren { 97 if has_paren {
93 p.expect(R_PAREN); 98 p.expect(R_PAREN);
94 } 99 }
100 inner.complete(p, TYPE_BOUND);
95 if !p.eat(PLUS) { 101 if !p.eat(PLUS) {
96 break; 102 break;
97 } 103 }
98 } 104 }
105 outer.complete(p, TYPE_BOUND_LIST);
99} 106}
100 107
101// test where_clause 108// test where_clause