From 3dc0b804f1a50871d2a5187492ba92421727799c Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Mon, 9 Nov 2015 13:23:19 +1300 Subject: [PATCH] Don't strip semi-colons from expressions with non-void type since it can change semantics --- src/visitor.rs | 6 +----- tests/target/expr.rs | 4 ++-- tests/target/match.rs | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/visitor.rs b/src/visitor.rs index 534b2c877fd..6114dfff077 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -507,12 +507,8 @@ fn semicolon_for_stmt(stmt: &ast::Stmt) -> bool { match expr.node { ast::Expr_::ExprWhile(..) | ast::Expr_::ExprWhileLet(..) | - ast::Expr_::ExprIf(..) | - ast::Expr_::ExprIfLet(..) | - ast::Expr_::ExprBlock(..) | ast::Expr_::ExprLoop(..) | - ast::Expr_::ExprForLoop(..) | - ast::Expr_::ExprMatch(..) => false, + ast::Expr_::ExprForLoop(..) => false, _ => true, } } diff --git a/tests/target/expr.rs b/tests/target/expr.rs index 4b4afaa99e5..3bda26e745f 100644 --- a/tests/target/expr.rs +++ b/tests/target/expr.rs @@ -40,7 +40,7 @@ fn foo() -> bool { result } else { 4 - } + }; if let Some(x) = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa { // Nothing @@ -253,5 +253,5 @@ fn repeats() { fn blocks() { if 1 + 1 == 2 { println!("yay arithmetix!"); - } + }; } diff --git a/tests/target/match.rs b/tests/target/match.rs index 4df098eb4d1..1d6842d358a 100644 --- a/tests/target/match.rs +++ b/tests/target/match.rs @@ -228,7 +228,7 @@ fn issue383() { match resolution.last_private { LastImport{..} => false, _ => true, - } + }; } fn issue507() {