Any way for Rust to realise I won't drop something from a ! method...?

we think rust (std) should make the following 2 changes:

  1. encourage catch_unwind to be used as ManuallyDrop::new(catch_unwind). this prevents the error type from dropping on an extra panic.
  2. as such, having a built-in way to turn ManuallyDrop<Result<...>> into Result<ManuallyDrop<...>> would be good, probably?

but uh anyway we're probably overthinking this

See also Never allow unwinding from Drop impls · Issue #97 · rust-lang/lang-team · GitHub for discussion around the pitfalls of panicking in drop. (The best-effort solution would likely be to forget(catch_unwind(|| drop(panic_payload))): drop it if it plays nice, but don't unwind if it doesn't.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.