aboutsummaryrefslogtreecommitdiff
path: root/crates
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
parent65a3cc21edd8acd93b728d094514bafddcb1757a (diff)
Parse default unsafe & default const
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_parser/src/grammar/items.rs26
-rw-r--r--crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast34
2 files changed, 45 insertions, 15 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] => {
diff --git a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast b/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast
index 9be441110..53f7ebaf9 100644
--- a/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast
+++ b/crates/ra_syntax/test_data/parser/inline/err/0010_wrong_order_fns.rast
@@ -17,23 +17,29 @@ [email protected]
17 [email protected] "{" 17 [email protected] "{"
18 [email protected] "}" 18 [email protected] "}"
19 [email protected] "\n" 19 [email protected] "\n"
20 ERROR@25..31 20 CONST_DEF@25..46
21 [email protected] "unsafe" 21 [email protected] "unsafe"
22 [email protected] " " 22 [email protected] " "
23 [email protected]
24 [email protected] "const" 23 [email protected] "const"
25 [email protected] " " 24 [email protected] " "
26 [email protected] "fn" 25 [email protected]
26 [email protected] "fn"
27 [email protected] " " 27 [email protected] " "
28 [email protected] 28 [email protected]
29 [email protected] "bar" 29 [email protected]
30 [email protected] 30 [email protected]
31 [email protected] "(" 31 [email protected]
32 [email protected] ")" 32 [email protected] "bar"
33 [email protected] " " 33 [email protected]
34 [email protected] 34 [email protected] "("
35 [email protected] "{" 35 [email protected] ")"
36 [email protected] "}" 36 [email protected] " "
37 [email protected]
38 [email protected] "{"
39 [email protected] "}"
37 [email protected] "\n" 40 [email protected] "\n"
38error 6..6: expected existential, fn, trait or impl 41error 6..6: expected existential, fn, trait or impl
39error 31..31: expected existential, fn, trait or impl 42error 38..38: expected a name
43error 40..40: expected COLON
44error 46..46: expected SEMICOLON
45error 47..47: expected an item