From 9638adaa40d22adcf9b4002d95a13977c0f1436f Mon Sep 17 00:00:00 2001 From: Geoffry Song Date: Wed, 2 Oct 2019 23:38:03 -0700 Subject: Fix parsing of block expressions in "forbid_structs" contexts. Forbidding block expressions entirely is too strict; instead, we should only forbid them in contexts where we are parsing an optional RHS (i.e. the RHS of a range expression). --- crates/ra_parser/src/grammar/expressions/atom.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_parser/src/grammar/expressions') diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index a52bdb3ea..7454005c4 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs @@ -121,11 +121,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMar // break; // } // } - if r.forbid_structs { - return None; - } else { - block_expr(p, None) - } + block_expr(p, None) } T![return] => return_expr(p), T![continue] => continue_expr(p), @@ -261,6 +257,7 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker { // if true {} else {}; // if true {} else if false {} else {}; // if S {}; +// if { true } { } else { }; // } fn if_expr(p: &mut Parser) -> CompletedMarker { assert!(p.at(T![if])); @@ -309,6 +306,7 @@ fn loop_expr(p: &mut Parser, m: Option) -> CompletedMarker { // fn foo() { // while true {}; // while let Some(x) = it.next() {}; +// while { true } {}; // } fn while_expr(p: &mut Parser, m: Option) -> CompletedMarker { assert!(p.at(T![while])); @@ -356,6 +354,8 @@ fn cond(p: &mut Parser) { // fn foo() { // match () { }; // match S {}; +// match { } { _ => () }; +// match { S {} } {}; // } fn match_expr(p: &mut Parser) -> CompletedMarker { assert!(p.at(T![match])); -- cgit v1.2.3