diff --git a/src/expr.rs b/src/expr.rs index c61e12fcb8b..1f82c5e10a3 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -280,7 +280,9 @@ fn rewrite_closure(capture: ast::CaptureClause, // All closure bodies are blocks in the eyes of the AST, but we may not // want to unwrap them when they only contain a single expression. let inner_expr = match expr.node { - ast::Expr_::ExprBlock(ref inner) if inner.stmts.is_empty() && inner.expr.is_some() => { + ast::Expr_::ExprBlock(ref inner) if inner.stmts.is_empty() && inner.expr.is_some() && + inner.rules == + ast::BlockCheckMode::DefaultBlock => { inner.expr.as_ref().unwrap() } _ => expr, diff --git a/tests/target/fn.rs b/tests/target/fn.rs index f48e8eaddc6..f9ea3f0c0c5 100644 --- a/tests/target/fn.rs +++ b/tests/target/fn.rs @@ -82,4 +82,5 @@ fn homura>(_: T) { fn main() { let _ = function(move || 5); let _ = move || 42; + let _ = || unsafe { abort() }; }