aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/grammar/items
diff options
context:
space:
mode:
authorJeremy A. Kolb <[email protected]>2018-10-15 22:44:23 +0100
committerJeremy A. Kolb <[email protected]>2018-10-16 14:41:10 +0100
commit61f3a438d3a729a6be941bca1ff4c6a97a33f221 (patch)
tree6551967cc8c6e921b66071453ad7888a9121d326 /crates/ra_syntax/src/grammar/items
parent39cb6c6d3f78b193f5873c3492e530bbd24d5dd2 (diff)
Cargo Format
Run `cargo fmt` and ignore generated files
Diffstat (limited to 'crates/ra_syntax/src/grammar/items')
-rw-r--r--crates/ra_syntax/src/grammar/items/mod.rs45
-rw-r--r--crates/ra_syntax/src/grammar/items/traits.rs1
2 files changed, 24 insertions, 22 deletions
diff --git a/crates/ra_syntax/src/grammar/items/mod.rs b/crates/ra_syntax/src/grammar/items/mod.rs
index 2567313ab..dc4742bce 100644
--- a/crates/ra_syntax/src/grammar/items/mod.rs
+++ b/crates/ra_syntax/src/grammar/items/mod.rs
@@ -1,16 +1,15 @@
1
2mod consts; 1mod consts;
3mod nominal; 2mod nominal;
4mod traits; 3mod traits;
5mod use_item; 4mod use_item;
6 5
7use super::*;
8pub(crate) use self::{ 6pub(crate) use self::{
9 expressions::{named_field_list, match_arm_list}, 7 expressions::{match_arm_list, named_field_list},
10 nominal::{enum_variant_list, named_field_def_list}, 8 nominal::{enum_variant_list, named_field_def_list},
11 traits::{trait_item_list, impl_item_list}, 9 traits::{impl_item_list, trait_item_list},
12 use_item::use_tree_list, 10 use_item::use_tree_list,
13}; 11};
12use super::*;
14 13
15// test mod_contents 14// test mod_contents
16// fn foo() {} 15// fn foo() {}
@@ -26,12 +25,14 @@ pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) {
26} 25}
27 26
28pub(super) enum ItemFlavor { 27pub(super) enum ItemFlavor {
29 Mod, Trait 28 Mod,
29 Trait,
30} 30}
31 31
32const ITEM_RECOVERY_SET: TokenSet = 32const ITEM_RECOVERY_SET: TokenSet = token_set![
33 token_set![FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, 33 FN_KW, STRUCT_KW, ENUM_KW, IMPL_KW, TRAIT_KW, CONST_KW, STATIC_KW, LET_KW, MOD_KW, PUB_KW,
34 MOD_KW, PUB_KW, CRATE_KW]; 34 CRATE_KW
35];
35 36
36pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemFlavor) { 37pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemFlavor) {
37 let m = p.start(); 38 let m = p.start();
@@ -153,10 +154,12 @@ pub(super) fn maybe_item(p: &mut Parser, flavor: ItemFlavor) -> MaybeItem {
153 traits::impl_item(p); 154 traits::impl_item(p);
154 IMPL_ITEM 155 IMPL_ITEM
155 } 156 }
156 _ => return if has_mods { 157 _ => {
157 MaybeItem::Modifiers 158 return if has_mods {
158 } else { 159 MaybeItem::Modifiers
159 MaybeItem::None 160 } else {
161 MaybeItem::None
162 }
160 } 163 }
161 }; 164 };
162 165
@@ -194,7 +197,7 @@ fn items_without_modifiers(p: &mut Parser) -> Option<SyntaxKind> {
194 if p.at(SEMI) { 197 if p.at(SEMI) {
195 p.err_and_bump( 198 p.err_and_bump(
196 "expected item, found `;`\n\ 199 "expected item, found `;`\n\
197 consider removing this semicolon" 200 consider removing this semicolon",
198 ); 201 );
199 } 202 }
200 STRUCT_DEF 203 STRUCT_DEF
@@ -227,7 +230,9 @@ fn items_without_modifiers(p: &mut Parser) -> Option<SyntaxKind> {
227 } 230 }
228 // test extern_block 231 // test extern_block
229 // extern {} 232 // extern {}
230 EXTERN_KW if la == L_CURLY || ((la == STRING || la == RAW_STRING) && p.nth(2) == L_CURLY) => { 233 EXTERN_KW
234 if la == L_CURLY || ((la == STRING || la == RAW_STRING) && p.nth(2) == L_CURLY) =>
235 {
231 abi(p); 236 abi(p);
232 extern_item_list(p); 237 extern_item_list(p);
233 EXTERN_BLOCK 238 EXTERN_BLOCK
@@ -267,10 +272,8 @@ fn fn_def(p: &mut Parser, flavor: ItemFlavor) {
267 272
268 if p.at(L_PAREN) { 273 if p.at(L_PAREN) {
269 match flavor { 274 match flavor {
270 ItemFlavor::Mod => 275 ItemFlavor::Mod => params::param_list(p),
271 params::param_list(p), 276 ItemFlavor::Trait => params::param_list_opt_patterns(p),
272 ItemFlavor::Trait =>
273 params::param_list_opt_patterns(p),
274 } 277 }
275 } else { 278 } else {
276 p.error("expected function arguments"); 279 p.error("expected function arguments");
@@ -361,7 +364,7 @@ pub(super) fn macro_call_after_excl(p: &mut Parser) -> BlockLike {
361 _ => { 364 _ => {
362 p.error("expected `{`, `[`, `(`"); 365 p.error("expected `{`, `[`, `(`");
363 BlockLike::NotBlock 366 BlockLike::NotBlock
364 }, 367 }
365 }; 368 };
366 369
367 flavor 370 flavor
@@ -385,9 +388,9 @@ pub(crate) fn token_tree(p: &mut Parser) {
385 return; 388 return;
386 } 389 }
387 R_PAREN | R_BRACK => p.err_and_bump("unmatched brace"), 390 R_PAREN | R_BRACK => p.err_and_bump("unmatched brace"),
388 _ => p.bump() 391 _ => p.bump(),
389 } 392 }
390 }; 393 }
391 p.expect(closing_paren_kind); 394 p.expect(closing_paren_kind);
392 m.complete(p, TOKEN_TREE); 395 m.complete(p, TOKEN_TREE);
393} 396}
diff --git a/crates/ra_syntax/src/grammar/items/traits.rs b/crates/ra_syntax/src/grammar/items/traits.rs
index 5dfdb470c..31258c253 100644
--- a/crates/ra_syntax/src/grammar/items/traits.rs
+++ b/crates/ra_syntax/src/grammar/items/traits.rs
@@ -128,4 +128,3 @@ pub(crate) fn impl_type(p: &mut Parser) {
128 } 128 }
129 types::type_(p); 129 types::type_(p);
130} 130}
131