Merge pull request #2172 from topecongiro/issue-2171
Do not squash unsafe block on closure body
This commit is contained in:
commit
b4378a1919
3 changed files with 23 additions and 1 deletions
|
@ -256,7 +256,9 @@ pub fn rewrite_last_closure(
|
|||
) -> Option<String> {
|
||||
if let ast::ExprKind::Closure(capture, ref fn_decl, ref body, _) = expr.node {
|
||||
let body = match body.node {
|
||||
ast::ExprKind::Block(ref block) if is_simple_block(block, context.codemap) => {
|
||||
ast::ExprKind::Block(ref block)
|
||||
if !is_unsafe_block(block) && is_simple_block(block, context.codemap) =>
|
||||
{
|
||||
stmt_expr(&block.stmts[0]).unwrap_or(body)
|
||||
}
|
||||
_ => body,
|
||||
|
|
|
@ -188,3 +188,13 @@ fn issue1524() {
|
|||
let f = |x| {x};
|
||||
let f = |x| x;
|
||||
}
|
||||
|
||||
fn issue2171() {
|
||||
foo(|| unsafe {
|
||||
if PERIPHERALS {
|
||||
loop {}
|
||||
} else {
|
||||
PERIPHERALS = true;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -220,3 +220,13 @@ fn issue1524() {
|
|||
let f = |x| x;
|
||||
let f = |x| x;
|
||||
}
|
||||
|
||||
fn issue2171() {
|
||||
foo(|| unsafe {
|
||||
if PERIPHERALS {
|
||||
loop {}
|
||||
} else {
|
||||
PERIPHERALS = true;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue