diff options
author | DJMcNab <[email protected]> | 2019-01-26 22:02:23 +0000 |
---|---|---|
committer | DJMcNab <[email protected]> | 2019-01-26 22:02:23 +0000 |
commit | 7055d43c3a1edca16cf5625f1b908643fa0bf21a (patch) | |
tree | 611d0fd1edff7e609b95bdceeeab5622be5eff2d /crates/ra_syntax/src | |
parent | 55a3e21ac4cd24dd7979a44c37cd1e7a3d1b85fd (diff) |
Make attrs be a child of the let statement
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/grammar/expressions.rs | 15 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/items.rs | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/crates/ra_syntax/src/grammar/expressions.rs b/crates/ra_syntax/src/grammar/expressions.rs index 0b2f7b116..8dd9587d0 100644 --- a/crates/ra_syntax/src/grammar/expressions.rs +++ b/crates/ra_syntax/src/grammar/expressions.rs | |||
@@ -45,7 +45,10 @@ pub(crate) fn block(p: &mut Parser) { | |||
45 | 45 | ||
46 | while !p.at(EOF) && !p.at(R_CURLY) { | 46 | while !p.at(EOF) && !p.at(R_CURLY) { |
47 | match p.current() { | 47 | match p.current() { |
48 | LET_KW => let_stmt(p), | 48 | LET_KW => { |
49 | let m = p.start(); | ||
50 | let_stmt(p, m) | ||
51 | } | ||
49 | // test nocontentexpr | 52 | // test nocontentexpr |
50 | // fn foo(){ | 53 | // fn foo(){ |
51 | // ;;;some_expr();;;;{;;;};;;;Ok(()) | 54 | // ;;;some_expr();;;;{;;;};;;;Ok(()) |
@@ -54,8 +57,9 @@ pub(crate) fn block(p: &mut Parser) { | |||
54 | _ => { | 57 | _ => { |
55 | // test block_items | 58 | // test block_items |
56 | // fn a() { fn b() {} } | 59 | // fn a() { fn b() {} } |
57 | let has_attrs = p.at(POUND); | ||
58 | let m = p.start(); | 60 | let m = p.start(); |
61 | let has_attrs = p.at(POUND); | ||
62 | attributes::outer_attributes(p); | ||
59 | match items::maybe_item(p, items::ItemFlavor::Mod) { | 63 | match items::maybe_item(p, items::ItemFlavor::Mod) { |
60 | items::MaybeItem::Item(kind) => { | 64 | items::MaybeItem::Item(kind) => { |
61 | m.complete(p, kind); | 65 | m.complete(p, kind); |
@@ -68,10 +72,10 @@ pub(crate) fn block(p: &mut Parser) { | |||
68 | // fn foo() { pub 92; } //FIXME | 72 | // fn foo() { pub 92; } //FIXME |
69 | items::MaybeItem::None => { | 73 | items::MaybeItem::None => { |
70 | if has_attrs { | 74 | if has_attrs { |
71 | m.abandon(p); | ||
72 | if p.at(LET_KW) { | 75 | if p.at(LET_KW) { |
73 | let_stmt(p); | 76 | let_stmt(p, m); |
74 | } else { | 77 | } else { |
78 | m.abandon(p); | ||
75 | p.error("expected a let statement"); | 79 | p.error("expected a let statement"); |
76 | } | 80 | } |
77 | } else { | 81 | } else { |
@@ -116,9 +120,8 @@ pub(crate) fn block(p: &mut Parser) { | |||
116 | // let c = 92; | 120 | // let c = 92; |
117 | // let d: i32 = 92; | 121 | // let d: i32 = 92; |
118 | // } | 122 | // } |
119 | fn let_stmt(p: &mut Parser) { | 123 | fn let_stmt(p: &mut Parser, m: Marker) { |
120 | assert!(p.at(LET_KW)); | 124 | assert!(p.at(LET_KW)); |
121 | let m = p.start(); | ||
122 | p.bump(); | 125 | p.bump(); |
123 | patterns::pattern(p); | 126 | patterns::pattern(p); |
124 | if p.at(COLON) { | 127 | if p.at(COLON) { |
diff --git a/crates/ra_syntax/src/grammar/items.rs b/crates/ra_syntax/src/grammar/items.rs index 265e84570..18039cd3f 100644 --- a/crates/ra_syntax/src/grammar/items.rs +++ b/crates/ra_syntax/src/grammar/items.rs | |||
@@ -36,6 +36,7 @@ pub(super) const ITEM_RECOVERY_SET: TokenSet = token_set![ | |||
36 | 36 | ||
37 | pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemFlavor) { | 37 | pub(super) fn item_or_macro(p: &mut Parser, stop_on_r_curly: bool, flavor: ItemFlavor) { |
38 | let m = p.start(); | 38 | let m = p.start(); |
39 | attributes::outer_attributes(p); | ||
39 | match maybe_item(p, flavor) { | 40 | match maybe_item(p, flavor) { |
40 | MaybeItem::Item(kind) => { | 41 | MaybeItem::Item(kind) => { |
41 | m.complete(p, kind); | 42 | m.complete(p, kind); |
@@ -79,7 +80,6 @@ pub(super) enum MaybeItem { | |||
79 | } | 80 | } |
80 | 81 | ||
81 | pub(super) fn maybe_item(p: &mut Parser, flavor: ItemFlavor) -> MaybeItem { | 82 | pub(super) fn maybe_item(p: &mut Parser, flavor: ItemFlavor) -> MaybeItem { |
82 | attributes::outer_attributes(p); | ||
83 | opt_visibility(p); | 83 | opt_visibility(p); |
84 | if let Some(kind) = items_without_modifiers(p) { | 84 | if let Some(kind) = items_without_modifiers(p) { |
85 | return MaybeItem::Item(kind); | 85 | return MaybeItem::Item(kind); |