aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/grammar
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-09-26 21:14:28 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-09-26 21:14:28 +0100
commit5e1d109cbb73a66c8bd3282973b8ebeb74894e4e (patch)
treede3bf059782d721efd76b0691020213858784099 /crates/ra_syntax/src/grammar
parent7eb047a105ee42b5dbd8f5cf7d956ca7bdfd551a (diff)
parent8b710e95353d9f840f78645c9593a66adb0636b6 (diff)
Merge #81
81: [WIP] Reject impl keyword inside impl header r=matklad a=csmoe Closes #77 Co-authored-by: csmoe <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/grammar')
-rw-r--r--crates/ra_syntax/src/grammar/items/traits.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/grammar/items/traits.rs b/crates/ra_syntax/src/grammar/items/traits.rs
index c21cfb1a9..5dfdb470c 100644
--- a/crates/ra_syntax/src/grammar/items/traits.rs
+++ b/crates/ra_syntax/src/grammar/items/traits.rs
@@ -55,9 +55,9 @@ pub(super) fn impl_item(p: &mut Parser) {
55 // test impl_item_neg 55 // test impl_item_neg
56 // impl !Send for X {} 56 // impl !Send for X {}
57 p.eat(EXCL); 57 p.eat(EXCL);
58 types::type_(p); 58 impl_type(p);
59 if p.eat(FOR_KW) { 59 if p.eat(FOR_KW) {
60 types::type_(p); 60 impl_type(p);
61 } 61 }
62 type_params::opt_where_clause(p); 62 type_params::opt_where_clause(p);
63 if p.at(L_CURLY) { 63 if p.at(L_CURLY) {
@@ -115,3 +115,17 @@ fn choose_type_params_over_qpath(p: &Parser) -> bool {
115 (p.nth(1) == LIFETIME || p.nth(1) == IDENT) 115 (p.nth(1) == LIFETIME || p.nth(1) == IDENT)
116 && (p.nth(2) == R_ANGLE || p.nth(2) == COMMA || p.nth(2) == COLON || p.nth(2) == EQ) 116 && (p.nth(2) == R_ANGLE || p.nth(2) == COMMA || p.nth(2) == COLON || p.nth(2) == EQ)
117} 117}
118
119// test impl_type
120// impl Type {}
121// impl Trait1 for T {}
122// impl impl NotType {}
123// impl Trait2 for impl NotType {}
124pub(crate) fn impl_type(p: &mut Parser) {
125 if p.at(IMPL_KW) {
126 p.error("expected trait or type");
127 return;
128 }
129 types::type_(p);
130}
131