Skip to content

Commit dab8aa0

Browse files
committed
[rebase]: don't require rust_try exported
1 parent 9d69659 commit dab8aa0

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/libstd/rt/unwind/mod.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,17 @@ pub unsafe fn try<F: FnOnce()>(f: F) -> Result<(), Box<Any + Send>> {
129129
let mut f = Some(f);
130130
return inner_try(try_fn::<F>, &mut f as *mut _ as *mut c_void);
131131

132-
// We use an inner non-generic function here to avoid the requirement that
133-
// the `rust_try` symbol needs to be exposed from the standard library. On
134-
// MSVC this requires the symbol to be tagged with `dllexport`, but it's
135-
// easier to not have conditional `src/rt/rust_try.ll` files and instead
136-
// just have this non-generic shim the compiler can take care of exposing
137-
// correctly.
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.
138143
unsafe fn inner_try(f: extern fn(*mut c_void), data: *mut c_void)
139144
-> Result<(), Box<Any + Send>> {
140145
let prev = PANICKING.with(|s| s.get());

0 commit comments

Comments
 (0)