aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-03-11 13:29:36 +0000
committerGitHub <[email protected]>2020-03-11 13:29:36 +0000
commit05b4fc6d79060fc3120f92b01119e3a851c37829 (patch)
treed67482ef3c3c231e4c0a1f9a8641548ddf7974fc /crates/ra_parser
parentbddf6b5266997dd7e017fcb963e54a86b68afbaa (diff)
parent4a745cc8cfab4e9d08a2e513228ce13e33d92a9e (diff)
Merge #3558
3558: Fix parsing of stement-ish binary expressions r=matklad a=matklad closes #3512 bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_parser')
-rw-r--r--crates/ra_parser/src/grammar/expressions.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs
index 4163a2cf5..0c170ac5e 100644
--- a/crates/ra_parser/src/grammar/expressions.rs
+++ b/crates/ra_parser/src/grammar/expressions.rs
@@ -278,7 +278,7 @@ fn current_op(p: &Parser) -> (u8, SyntaxKind) {
278} 278}
279 279
280// Parses expression with binding power of at least bp. 280// Parses expression with binding power of at least bp.
281fn expr_bp(p: &mut Parser, r: Restrictions, bp: u8) -> (Option<CompletedMarker>, BlockLike) { 281fn expr_bp(p: &mut Parser, mut r: Restrictions, bp: u8) -> (Option<CompletedMarker>, BlockLike) {
282 let mut lhs = match lhs(p, r) { 282 let mut lhs = match lhs(p, r) {
283 Some((lhs, blocklike)) => { 283 Some((lhs, blocklike)) => {
284 // test stmt_bin_expr_ambiguity 284 // test stmt_bin_expr_ambiguity
@@ -311,6 +311,12 @@ fn expr_bp(p: &mut Parser, r: Restrictions, bp: u8) -> (Option<CompletedMarker>,
311 let m = lhs.precede(p); 311 let m = lhs.precede(p);
312 p.bump(op); 312 p.bump(op);
313 313
314 // test binop_resets_statementness
315 // fn foo() {
316 // v = {1}&2;
317 // }
318 r = Restrictions { prefer_stmt: false, ..r };
319
314 if is_range { 320 if is_range {
315 // test postfix_range 321 // test postfix_range
316 // fn foo() { 322 // fn foo() {
@@ -327,7 +333,7 @@ fn expr_bp(p: &mut Parser, r: Restrictions, bp: u8) -> (Option<CompletedMarker>,
327 } 333 }
328 } 334 }
329 335
330 expr_bp(p, r, op_bp + 1); 336 expr_bp(p, Restrictions { prefer_stmt: false, ..r }, op_bp + 1);
331 lhs = m.complete(p, if is_range { RANGE_EXPR } else { BIN_EXPR }); 337 lhs = m.complete(p, if is_range { RANGE_EXPR } else { BIN_EXPR });
332 } 338 }
333 (Some(lhs), BlockLike::NotBlock) 339 (Some(lhs), BlockLike::NotBlock)