aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar/type_params.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src/grammar/type_params.rs')
-rw-r--r--crates/ra_parser/src/grammar/type_params.rs43
1 files changed, 30 insertions, 13 deletions
diff --git a/crates/ra_parser/src/grammar/type_params.rs b/crates/ra_parser/src/grammar/type_params.rs
index 40f998682..42763fc87 100644
--- a/crates/ra_parser/src/grammar/type_params.rs
+++ b/crates/ra_parser/src/grammar/type_params.rs
@@ -79,23 +79,40 @@ fn lifetime_bounds(p: &mut Parser) {
79 } 79 }
80} 80}
81 81
82pub(super) fn bounds_without_colon(p: &mut Parser) { 82pub(super) fn bounds_without_colon_m(p: &mut Parser, marker: Marker) -> CompletedMarker {
83 loop { 83 while type_bound(p) {
84 let has_paren = p.eat(L_PAREN);
85 p.eat(QUESTION);
86 match p.current() {
87 LIFETIME => p.bump(),
88 FOR_KW => types::for_type(p),
89 _ if paths::is_path_start(p) => types::path_type(p),
90 _ => break,
91 }
92 if has_paren {
93 p.expect(R_PAREN);
94 }
95 if !p.eat(PLUS) { 84 if !p.eat(PLUS) {
96 break; 85 break;
97 } 86 }
98 } 87 }
88
89 marker.complete(p, TYPE_BOUND_LIST)
90}
91
92pub(super) fn bounds_without_colon(p: &mut Parser) {
93 let m = p.start();
94 bounds_without_colon_m(p, m);
95}
96
97fn type_bound(p: &mut Parser) -> bool {
98 let m = p.start();
99 let has_paren = p.eat(L_PAREN);
100 p.eat(QUESTION);
101 match p.current() {
102 LIFETIME => p.bump(),
103 FOR_KW => types::for_type(p),
104 _ if paths::is_path_start(p) => types::path_type_(p, false),
105 _ => {
106 m.abandon(p);
107 return false;
108 }
109 }
110 if has_paren {
111 p.expect(R_PAREN);
112 }
113 m.complete(p, TYPE_BOUND);
114
115 true
99} 116}
100 117
101// test where_clause 118// test where_clause