Skip to content

Commit dbdc983

Browse files
committed
---
yaml --- r: 214555 b: refs/heads/beta c: 74f4f39 h: refs/heads/master i: 214553: 87650d0 214551: c8c0860 v: v3
1 parent 2a6c1fd commit dbdc983

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 3d32cf5d9afdd8c375935ac875b2a20f24159e52
26+
refs/heads/beta: 74f4f395aefd1054b8d8974a128007d0671e9d78
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 8c0aa6d64ebab528f7eb182812007155d6044972
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/libstd/rt/unwind/mod.rs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,31 @@ extern {}
127127
/// run.
128128
pub unsafe fn try<F: FnOnce()>(f: F) -> Result<(), Box<Any + Send>> {
129129
let mut f = Some(f);
130+
return inner_try(try_fn::<F>, &mut f as *mut _ as *mut c_void);
130131

131-
let prev = PANICKING.with(|s| s.get());
132-
PANICKING.with(|s| s.set(false));
133-
let ep = rust_try(try_fn::<F>, &mut f as *mut _ as *mut c_void);
134-
PANICKING.with(|s| s.set(prev));
135-
return if ep.is_null() {
136-
Ok(())
137-
} else {
138-
Err(imp::cleanup(ep))
139-
};
132+
// If an inner function were not used here, then this generic function `try`
133+
// uses the native symbol `rust_try`, for which the code is statically
134+
// linked into the standard library. This means that the DLL for the
135+
// standard library must have `rust_try` as an exposed symbol that
136+
// downstream crates can link against (because monomorphizations of `try` in
137+
// downstream crates will have a reference to the `rust_try` symbol).
138+
//
139+
// On MSVC this requires the symbol `rust_try` to be tagged with
140+
// `dllexport`, but it's easier to not have conditional `src/rt/rust_try.ll`
141+
// files and instead just have this non-generic shim the compiler can take
142+
// care of exposing correctly.
143+
unsafe fn inner_try(f: extern fn(*mut c_void), data: *mut c_void)
144+
-> Result<(), Box<Any + Send>> {
145+
let prev = PANICKING.with(|s| s.get());
146+
PANICKING.with(|s| s.set(false));
147+
let ep = rust_try(f, data);
148+
PANICKING.with(|s| s.set(prev));
149+
if ep.is_null() {
150+
Ok(())
151+
} else {
152+
Err(imp::cleanup(ep))
153+
}
154+
}
140155

141156
extern fn try_fn<F: FnOnce()>(opt_closure: *mut c_void) {
142157
let opt_closure = opt_closure as *mut Option<F>;

0 commit comments

Comments
 (0)