aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src
diff options
context:
space:
mode:
authorAvi Dessauer <[email protected]>2020-06-03 20:21:47 +0100
committerAvi Dessauer <[email protected]>2020-06-04 01:16:38 +0100
commitfb632c747d953d615575850477d4662802be320f (patch)
tree866067cda9582a719d3a139b1d04ad637be463b9 /crates/ra_parser/src
parent65a3cc21edd8acd93b728d094514bafddcb1757a (diff)
Parse default unsafe & default const
Diffstat (limited to 'crates/ra_parser/src')
-rw-r--r--crates/ra_parser/src/grammar/items.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs
index 67a924de5..41f8bb0b6 100644
--- a/crates/ra_parser/src/grammar/items.rs
+++ b/crates/ra_parser/src/grammar/items.rs
@@ -118,7 +118,15 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
118 && p.at_contextual_kw("default") 118 && p.at_contextual_kw("default")
119 && (match p.nth(1) { 119 && (match p.nth(1) {
120 T![impl] => true, 120 T![impl] => true,
121 T![fn] | T![type] => { 121 T![unsafe] => {
122 if T![impl] == p.nth(2) {
123 p.bump_remap(T![default]);
124 p.bump_remap(T![unsafe]);
125 has_mods = true;
126 }
127 false
128 }
129 T![fn] | T![type] | T![const] => {
122 if let ItemFlavor::Mod = flavor { 130 if let ItemFlavor::Mod = flavor {
123 true 131 true
124 } else { 132 } else {
@@ -187,6 +195,9 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
187 // test default_impl 195 // test default_impl
188 // default impl Foo {} 196 // default impl Foo {}
189 197
198 // test default_unsafe_impl
199 // default unsafe impl Foo {}
200
190 // test_err default_fn_type 201 // test_err default_fn_type
191 // trait T { 202 // trait T {
192 // default type T = Bar; 203 // default type T = Bar;
@@ -199,6 +210,19 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul
199 // default fn foo() {} 210 // default fn foo() {}
200 // } 211 // }
201 212
213 // test_err default_const
214 // trait T {
215 // default const f: u8 = 0;
216 // }
217
218 // test default_const
219 // impl T for Foo {
220 // default const f: u8 = 0;
221 // }
222 T![const] => {
223 consts::const_def(p, m);
224 }
225
202 // test unsafe_default_impl 226 // test unsafe_default_impl
203 // unsafe default impl Foo {} 227 // unsafe default impl Foo {}
204 T![impl] => { 228 T![impl] => {