From 5e25dc9966c28f057b33045be9d4967815dcba05 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 1 Apr 2017 11:11:31 +0300 Subject: Unify rules about commas in match arms and semicolons in expressions --- src/libsyntax/parse/classify.rs | 9 +-------- src/libsyntax/parse/parser.rs | 3 +-- 2 files changed, 2 insertions(+), 10 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index 0c6f09ba766..d9f76ce3592 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -12,7 +12,7 @@ // Predicates on exprs and stmts that the pretty-printer and parser use -use ast::{self, BlockCheckMode}; +use ast; /// Does this expression require a semicolon to be treated /// as a statement? The negation of this: 'can this expression @@ -35,13 +35,6 @@ pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool { } } -pub fn expr_is_simple_block(e: &ast::Expr) -> bool { - match e.node { - ast::ExprKind::Block(ref block) => block.rules == BlockCheckMode::Default, - _ => false, - } -} - /// this statement requires a semicolon after it. /// note that in one case (`stmt_semi`), we've already /// seen the semicolon, and thus don't need another. diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 90d9ae383a4..ae3edfcbf32 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3209,8 +3209,7 @@ impl<'a> Parser<'a> { self.expect(&token::FatArrow)?; let expr = self.parse_expr_res(RESTRICTION_STMT_EXPR, None)?; - let require_comma = - !classify::expr_is_simple_block(&expr) + let require_comma = classify::expr_requires_semi_to_be_stmt(&expr) && self.token != token::CloseDelim(token::Brace); if require_comma { -- cgit 1.4.1-3-g733a5