diff options
Diffstat (limited to 'crates/ra_syntax/src/grammar')
-rw-r--r-- | crates/ra_syntax/src/grammar/expressions.rs | 15 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/expressions/atom.rs | 9 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/items.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/params.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/patterns.rs | 4 |
5 files changed, 7 insertions, 33 deletions
diff --git a/crates/ra_syntax/src/grammar/expressions.rs b/crates/ra_syntax/src/grammar/expressions.rs index 6b88c5685..28fcb1f7d 100644 --- a/crates/ra_syntax/src/grammar/expressions.rs +++ b/crates/ra_syntax/src/grammar/expressions.rs | |||
@@ -7,26 +7,17 @@ use super::*; | |||
7 | const EXPR_FIRST: TokenSet = LHS_FIRST; | 7 | const EXPR_FIRST: TokenSet = LHS_FIRST; |
8 | 8 | ||
9 | pub(super) fn expr(p: &mut Parser) -> BlockLike { | 9 | pub(super) fn expr(p: &mut Parser) -> BlockLike { |
10 | let r = Restrictions { | 10 | let r = Restrictions { forbid_structs: false, prefer_stmt: false }; |
11 | forbid_structs: false, | ||
12 | prefer_stmt: false, | ||
13 | }; | ||
14 | expr_bp(p, r, 1) | 11 | expr_bp(p, r, 1) |
15 | } | 12 | } |
16 | 13 | ||
17 | pub(super) fn expr_stmt(p: &mut Parser) -> BlockLike { | 14 | pub(super) fn expr_stmt(p: &mut Parser) -> BlockLike { |
18 | let r = Restrictions { | 15 | let r = Restrictions { forbid_structs: false, prefer_stmt: true }; |
19 | forbid_structs: false, | ||
20 | prefer_stmt: true, | ||
21 | }; | ||
22 | expr_bp(p, r, 1) | 16 | expr_bp(p, r, 1) |
23 | } | 17 | } |
24 | 18 | ||
25 | fn expr_no_struct(p: &mut Parser) { | 19 | fn expr_no_struct(p: &mut Parser) { |
26 | let r = Restrictions { | 20 | let r = Restrictions { forbid_structs: true, prefer_stmt: false }; |
27 | forbid_structs: true, | ||
28 | prefer_stmt: false, | ||
29 | }; | ||
30 | expr_bp(p, r, 1); | 21 | expr_bp(p, r, 1); |
31 | } | 22 | } |
32 | 23 | ||
diff --git a/crates/ra_syntax/src/grammar/expressions/atom.rs b/crates/ra_syntax/src/grammar/expressions/atom.rs index 600774afd..27ba87657 100644 --- a/crates/ra_syntax/src/grammar/expressions/atom.rs +++ b/crates/ra_syntax/src/grammar/expressions/atom.rs | |||
@@ -141,14 +141,7 @@ fn tuple_expr(p: &mut Parser) -> CompletedMarker { | |||
141 | } | 141 | } |
142 | } | 142 | } |
143 | p.expect(R_PAREN); | 143 | p.expect(R_PAREN); |
144 | m.complete( | 144 | m.complete(p, if saw_expr && !saw_comma { PAREN_EXPR } else { TUPLE_EXPR }) |
145 | p, | ||
146 | if saw_expr && !saw_comma { | ||
147 | PAREN_EXPR | ||
148 | } else { | ||
149 | TUPLE_EXPR | ||
150 | }, | ||
151 | ) | ||
152 | } | 145 | } |
153 | 146 | ||
154 | // test array_expr | 147 | // test array_expr |
diff --git a/crates/ra_syntax/src/grammar/items.rs b/crates/ra_syntax/src/grammar/items.rs index 84c18a293..a61f260cf 100644 --- a/crates/ra_syntax/src/grammar/items.rs +++ b/crates/ra_syntax/src/grammar/items.rs | |||
@@ -155,11 +155,7 @@ pub(super) fn maybe_item(p: &mut Parser, flavor: ItemFlavor) -> MaybeItem { | |||
155 | IMPL_BLOCK | 155 | IMPL_BLOCK |
156 | } | 156 | } |
157 | _ => { | 157 | _ => { |
158 | return if has_mods { | 158 | return if has_mods { MaybeItem::Modifiers } else { MaybeItem::None }; |
159 | MaybeItem::Modifiers | ||
160 | } else { | ||
161 | MaybeItem::None | ||
162 | }; | ||
163 | } | 159 | } |
164 | }; | 160 | }; |
165 | 161 | ||
diff --git a/crates/ra_syntax/src/grammar/params.rs b/crates/ra_syntax/src/grammar/params.rs index 13158429a..185386569 100644 --- a/crates/ra_syntax/src/grammar/params.rs +++ b/crates/ra_syntax/src/grammar/params.rs | |||
@@ -36,11 +36,7 @@ impl Flavor { | |||
36 | } | 36 | } |
37 | 37 | ||
38 | fn list_(p: &mut Parser, flavor: Flavor) { | 38 | fn list_(p: &mut Parser, flavor: Flavor) { |
39 | let (bra, ket) = if flavor.type_required() { | 39 | let (bra, ket) = if flavor.type_required() { (L_PAREN, R_PAREN) } else { (PIPE, PIPE) }; |
40 | (L_PAREN, R_PAREN) | ||
41 | } else { | ||
42 | (PIPE, PIPE) | ||
43 | }; | ||
44 | assert!(p.at(bra)); | 40 | assert!(p.at(bra)); |
45 | let m = p.start(); | 41 | let m = p.start(); |
46 | p.bump(); | 42 | p.bump(); |
diff --git a/crates/ra_syntax/src/grammar/patterns.rs b/crates/ra_syntax/src/grammar/patterns.rs index 1ac5efdf6..f3f400ae0 100644 --- a/crates/ra_syntax/src/grammar/patterns.rs +++ b/crates/ra_syntax/src/grammar/patterns.rs | |||
@@ -2,9 +2,7 @@ use super::*; | |||
2 | 2 | ||
3 | pub(super) const PATTERN_FIRST: TokenSet = expressions::LITERAL_FIRST | 3 | pub(super) const PATTERN_FIRST: TokenSet = expressions::LITERAL_FIRST |
4 | .union(paths::PATH_FIRST) | 4 | .union(paths::PATH_FIRST) |
5 | .union(token_set![ | 5 | .union(token_set![REF_KW, MUT_KW, L_PAREN, L_BRACK, AMP, UNDERSCORE]); |
6 | REF_KW, MUT_KW, L_PAREN, L_BRACK, AMP, UNDERSCORE | ||
7 | ]); | ||
8 | 6 | ||
9 | pub(super) fn pattern(p: &mut Parser) { | 7 | pub(super) fn pattern(p: &mut Parser) { |
10 | pattern_r(p, PAT_RECOVERY_SET) | 8 | pattern_r(p, PAT_RECOVERY_SET) |