From 35f2fe52c2d4c55236446ebdac11ba44cc3704cd Mon Sep 17 00:00:00 2001 From: Aaron Keen Date: Mon, 14 Dec 2015 21:32:16 +0100 Subject: Corrects issue #28777 by removing, once a binary operator is found, the RESTRICTION_STMT_EXPR restriction to allow subsequent expressions to contain braces. https://github.com/rust-lang/rust/issues/28777 --- src/libsyntax/parse/parser.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/libsyntax/parse/parser.rs') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7502a8cbc35..6cbdd9f3411 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2813,16 +2813,25 @@ impl<'a> Parser<'a> { let rhs = try!(match op.fixity() { - Fixity::Right => self.with_res(restrictions, |this|{ - this.parse_assoc_expr_with(op.precedence(), LhsExpr::NotYetParsed) + Fixity::Right => self.with_res( + restrictions & !Restrictions::RESTRICTION_STMT_EXPR, + |this|{ + this.parse_assoc_expr_with(op.precedence(), + LhsExpr::NotYetParsed) }), - Fixity::Left => self.with_res(restrictions, |this|{ - this.parse_assoc_expr_with(op.precedence() + 1, LhsExpr::NotYetParsed) + Fixity::Left => self.with_res( + restrictions & !Restrictions::RESTRICTION_STMT_EXPR, + |this|{ + this.parse_assoc_expr_with(op.precedence() + 1, + LhsExpr::NotYetParsed) }), // We currently have no non-associative operators that are not handled above by // the special cases. The code is here only for future convenience. - Fixity::None => self.with_res(restrictions, |this|{ - this.parse_assoc_expr_with(op.precedence() + 1, LhsExpr::NotYetParsed) + Fixity::None => self.with_res( + restrictions & !Restrictions::RESTRICTION_STMT_EXPR, + |this|{ + this.parse_assoc_expr_with(op.precedence() + 1, + LhsExpr::NotYetParsed) }), }); -- cgit 1.4.1-3-g733a5 From 41cc365af92ff3ed5c165fb575a74428e2608a6e Mon Sep 17 00:00:00 2001 From: Aaron Keen Date: Wed, 16 Dec 2015 11:53:36 +0100 Subject: Corrected formatting mistakes. Changed bit manipulation to use supported - (set difference) instead of explicit '& !'. --- src/libsyntax/parse/parser.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/libsyntax/parse/parser.rs') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6cbdd9f3411..4f4a78e8760 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2814,22 +2814,22 @@ impl<'a> Parser<'a> { let rhs = try!(match op.fixity() { Fixity::Right => self.with_res( - restrictions & !Restrictions::RESTRICTION_STMT_EXPR, - |this|{ + restrictions - Restrictions::RESTRICTION_STMT_EXPR, + |this| { this.parse_assoc_expr_with(op.precedence(), - LhsExpr::NotYetParsed) + LhsExpr::NotYetParsed) }), Fixity::Left => self.with_res( - restrictions & !Restrictions::RESTRICTION_STMT_EXPR, - |this|{ + restrictions - Restrictions::RESTRICTION_STMT_EXPR, + |this| { this.parse_assoc_expr_with(op.precedence() + 1, LhsExpr::NotYetParsed) }), // We currently have no non-associative operators that are not handled above by // the special cases. The code is here only for future convenience. Fixity::None => self.with_res( - restrictions & !Restrictions::RESTRICTION_STMT_EXPR, - |this|{ + restrictions - Restrictions::RESTRICTION_STMT_EXPR, + |this| { this.parse_assoc_expr_with(op.precedence() + 1, LhsExpr::NotYetParsed) }), -- cgit 1.4.1-3-g733a5