diff --git a/src/libstd/sys/common/unwind/mod.rs b/src/libstd/sys/common/unwind/mod.rs index 738681c3cfe..8899d1b04d8 100644 --- a/src/libstd/sys/common/unwind/mod.rs +++ b/src/libstd/sys/common/unwind/mod.rs @@ -148,15 +148,17 @@ pub unsafe fn try(f: F) -> Result<(), Box> { // care of exposing correctly. unsafe fn inner_try(f: fn(*mut u8), data: *mut u8) -> Result<(), Box> { - let prev = PANICKING.with(|s| s.get()); - PANICKING.with(|s| s.set(false)); - let ep = intrinsics::try(f, data); - PANICKING.with(|s| s.set(prev)); - if ep.is_null() { - Ok(()) - } else { - Err(imp::cleanup(ep)) - } + PANICKING.with(|s| { + let prev = s.get(); + s.set(false); + let ep = intrinsics::try(f, data); + s.set(prev); + if ep.is_null() { + Ok(()) + } else { + Err(imp::cleanup(ep)) + } + }) } fn try_fn(opt_closure: *mut u8) {