Skip to content

Commit 2a6f6f2

Browse files
committed
Auto merge of #28584 - ranma42:simpler-innertry, r=alexcrichton
This simplifies a little inner_try and avoids multiple accesses to TLS.
2 parents 0c05492 + cf10296 commit 2a6f6f2

File tree

1 file changed

+11
-9
lines changed
  • src/libstd/sys/common/unwind

1 file changed

+11
-9
lines changed

src/libstd/sys/common/unwind/mod.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,17 @@ pub unsafe fn try<F: FnOnce()>(f: F) -> Result<(), Box<Any + Send>> {
148148
// care of exposing correctly.
149149
unsafe fn inner_try(f: fn(*mut u8), data: *mut u8)
150150
-> Result<(), Box<Any + Send>> {
151-
let prev = PANICKING.with(|s| s.get());
152-
PANICKING.with(|s| s.set(false));
153-
let ep = intrinsics::try(f, data);
154-
PANICKING.with(|s| s.set(prev));
155-
if ep.is_null() {
156-
Ok(())
157-
} else {
158-
Err(imp::cleanup(ep))
159-
}
151+
PANICKING.with(|s| {
152+
let prev = s.get();
153+
s.set(false);
154+
let ep = intrinsics::try(f, data);
155+
s.set(prev);
156+
if ep.is_null() {
157+
Ok(())
158+
} else {
159+
Err(imp::cleanup(ep))
160+
}
161+
})
160162
}
161163

162164
fn try_fn<F: FnOnce()>(opt_closure: *mut u8) {

0 commit comments

Comments
 (0)