diff options
author | Kevin DeLorey <[email protected]> | 2020-02-09 16:25:47 +0000 |
---|---|---|
committer | Kevin DeLorey <[email protected]> | 2020-02-09 16:37:43 +0000 |
commit | a957c473fdb79880c39b73dc9e0c923093cf16ac (patch) | |
tree | f998b548f530ce604651e0e6af314ed2ec74b3b5 /crates/ra_parser/src/grammar/items.rs | |
parent | 22caf982b99c54058e2e9200aeea0e61cada284a (diff) | |
parent | 1b9b13b4b4a75b5531c3f046ce6bf72d681f2732 (diff) |
Merge branch 'master' into kdelorey/complete-trait-impl
Diffstat (limited to 'crates/ra_parser/src/grammar/items.rs')
-rw-r--r-- | crates/ra_parser/src/grammar/items.rs | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/crates/ra_parser/src/grammar/items.rs b/crates/ra_parser/src/grammar/items.rs index 6e23d9b72..54284c933 100644 --- a/crates/ra_parser/src/grammar/items.rs +++ b/crates/ra_parser/src/grammar/items.rs | |||
@@ -91,13 +91,6 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul | |||
91 | // modifiers | 91 | // modifiers |
92 | has_mods |= p.eat(T![const]); | 92 | has_mods |= p.eat(T![const]); |
93 | 93 | ||
94 | // test_err unsafe_block_in_mod | ||
95 | // fn foo(){} unsafe { } fn bar(){} | ||
96 | if p.at(T![unsafe]) && p.nth(1) != T!['{'] { | ||
97 | p.eat(T![unsafe]); | ||
98 | has_mods = true; | ||
99 | } | ||
100 | |||
101 | // test_err async_without_semicolon | 94 | // test_err async_without_semicolon |
102 | // fn foo() { let _ = async {} } | 95 | // fn foo() { let _ = async {} } |
103 | if p.at(T![async]) && p.nth(1) != T!['{'] && p.nth(1) != T![move] && p.nth(1) != T![|] { | 96 | if p.at(T![async]) && p.nth(1) != T!['{'] && p.nth(1) != T![move] && p.nth(1) != T![|] { |
@@ -105,6 +98,13 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul | |||
105 | has_mods = true; | 98 | has_mods = true; |
106 | } | 99 | } |
107 | 100 | ||
101 | // test_err unsafe_block_in_mod | ||
102 | // fn foo(){} unsafe { } fn bar(){} | ||
103 | if p.at(T![unsafe]) && p.nth(1) != T!['{'] { | ||
104 | p.eat(T![unsafe]); | ||
105 | has_mods = true; | ||
106 | } | ||
107 | |||
108 | if p.at(T![extern]) { | 108 | if p.at(T![extern]) { |
109 | has_mods = true; | 109 | has_mods = true; |
110 | abi(p); | 110 | abi(p); |
@@ -157,14 +157,14 @@ pub(super) fn maybe_item(p: &mut Parser, m: Marker, flavor: ItemFlavor) -> Resul | |||
157 | // unsafe fn foo() {} | 157 | // unsafe fn foo() {} |
158 | 158 | ||
159 | // test combined_fns | 159 | // test combined_fns |
160 | // unsafe async fn foo() {} | 160 | // async unsafe fn foo() {} |
161 | // const unsafe fn bar() {} | 161 | // const unsafe fn bar() {} |
162 | 162 | ||
163 | // test_err wrong_order_fns | 163 | // test_err wrong_order_fns |
164 | // async unsafe fn foo() {} | 164 | // unsafe async fn foo() {} |
165 | // unsafe const fn bar() {} | 165 | // unsafe const fn bar() {} |
166 | T![fn] => { | 166 | T![fn] => { |
167 | fn_def(p, flavor); | 167 | fn_def(p); |
168 | m.complete(p, FN_DEF); | 168 | m.complete(p, FN_DEF); |
169 | } | 169 | } |
170 | 170 | ||
@@ -301,7 +301,7 @@ pub(crate) fn extern_item_list(p: &mut Parser) { | |||
301 | m.complete(p, EXTERN_ITEM_LIST); | 301 | m.complete(p, EXTERN_ITEM_LIST); |
302 | } | 302 | } |
303 | 303 | ||
304 | fn fn_def(p: &mut Parser, flavor: ItemFlavor) { | 304 | fn fn_def(p: &mut Parser) { |
305 | assert!(p.at(T![fn])); | 305 | assert!(p.at(T![fn])); |
306 | p.bump(T![fn]); | 306 | p.bump(T![fn]); |
307 | 307 | ||
@@ -311,10 +311,7 @@ fn fn_def(p: &mut Parser, flavor: ItemFlavor) { | |||
311 | type_params::opt_type_param_list(p); | 311 | type_params::opt_type_param_list(p); |
312 | 312 | ||
313 | if p.at(T!['(']) { | 313 | if p.at(T!['(']) { |
314 | match flavor { | 314 | params::param_list_fn_def(p); |
315 | ItemFlavor::Mod => params::param_list(p), | ||
316 | ItemFlavor::Trait => params::param_list_opt_patterns(p), | ||
317 | } | ||
318 | } else { | 315 | } else { |
319 | p.error("expected function arguments"); | 316 | p.error("expected function arguments"); |
320 | } | 317 | } |