Skip to content

Commit 8057092

Browse files
Remove UnwindSafe bound from pgrx_extern_c_guard (#1732)
Our invariants are so complicated and need such special handling that once they are take care of, `UnwindSafe` adds nothing. The particular example that motivated this: `&mut T` isn't `UnwindSafe` because it's *easy* to witness a broken invariant, not that you will. See rust-lang/rfcs#3260 for further rationale.
1 parent 43e68d2 commit 8057092

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pgrx-pg-sys/src/submodules/panic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::cell::Cell;
1616
use std::fmt::{Display, Formatter};
1717
use std::hint::unreachable_unchecked;
1818
use std::panic::{
19-
catch_unwind, panic_any, resume_unwind, Location, PanicInfo, RefUnwindSafe, UnwindSafe,
19+
catch_unwind, panic_any, resume_unwind, AssertUnwindSafe, Location, PanicInfo, UnwindSafe,
2020
};
2121

2222
use crate::elog::PgLogLevel;
@@ -381,9 +381,9 @@ enum GuardAction<R> {
381381
// what we really want is a bound of R: !Drop, but negative bounds don't exist yet
382382
pub unsafe fn pgrx_extern_c_guard<Func, R>(f: Func) -> R
383383
where
384-
Func: FnOnce() -> R + UnwindSafe + RefUnwindSafe,
384+
Func: FnOnce() -> R,
385385
{
386-
match unsafe { run_guarded(f) } {
386+
match unsafe { run_guarded(AssertUnwindSafe(f)) } {
387387
GuardAction::Return(r) => r,
388388
GuardAction::ReThrow => {
389389
extern "C" /* "C-unwind" */ {
@@ -405,7 +405,7 @@ where
405405
#[inline(never)]
406406
unsafe fn run_guarded<F, R>(f: F) -> GuardAction<R>
407407
where
408-
F: FnOnce() -> R + UnwindSafe + RefUnwindSafe,
408+
F: FnOnce() -> R + UnwindSafe,
409409
{
410410
match catch_unwind(f) {
411411
Ok(v) => GuardAction::Return(v),

0 commit comments

Comments
 (0)