diff options
Diffstat (limited to 'crates/ra_syntax/src/grammar/type_params.rs')
-rw-r--r-- | crates/ra_syntax/src/grammar/type_params.rs | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/crates/ra_syntax/src/grammar/type_params.rs b/crates/ra_syntax/src/grammar/type_params.rs index f33ec10f5..a7eacf97a 100644 --- a/crates/ra_syntax/src/grammar/type_params.rs +++ b/crates/ra_syntax/src/grammar/type_params.rs | |||
@@ -105,27 +105,31 @@ pub(super) fn opt_where_clause(p: &mut Parser) { | |||
105 | let m = p.start(); | 105 | let m = p.start(); |
106 | p.bump(); | 106 | p.bump(); |
107 | 107 | ||
108 | if is_where_clause_end(p) { | 108 | while is_where_predicate(p) { |
109 | // Empty where clause | 109 | where_predicate(p); |
110 | } else { | ||
111 | loop { | ||
112 | where_predicate(p); | ||
113 | 110 | ||
114 | let comma = p.eat(COMMA); | 111 | let comma = p.eat(COMMA); |
115 | 112 | ||
116 | if is_where_clause_end(p) { | 113 | if is_where_clause_end(p) { |
117 | break; | 114 | break; |
118 | } | 115 | } |
119 | 116 | ||
120 | if !comma { | 117 | if !comma { |
121 | p.error("expected comma"); | 118 | p.error("expected comma"); |
122 | } | ||
123 | } | 119 | } |
124 | } | 120 | } |
125 | 121 | ||
126 | m.complete(p, WHERE_CLAUSE); | 122 | m.complete(p, WHERE_CLAUSE); |
127 | } | 123 | } |
128 | 124 | ||
125 | fn is_where_predicate(p: &mut Parser) -> bool { | ||
126 | match p.current() { | ||
127 | LIFETIME => true, | ||
128 | IMPL_KW => false, | ||
129 | _ => types::is_type_start(p), | ||
130 | } | ||
131 | } | ||
132 | |||
129 | fn is_where_clause_end(p: &mut Parser) -> bool { | 133 | fn is_where_clause_end(p: &mut Parser) -> bool { |
130 | p.current() == L_CURLY || p.current() == SEMI || p.current() == EQ | 134 | p.current() == L_CURLY || p.current() == SEMI || p.current() == EQ |
131 | } | 135 | } |