Skip to content

Commit c43d065

Browse files
committed
Add more alternatives
1 parent 120bb41 commit c43d065

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

text/0000-panic-in-drop.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,16 @@ This mirrors the behavior of C++ where a throwing destructor can be opted into u
275275

276276
Unfortunately this doesn't really fit Rust's safety model: such a type would have to be unsafe to create and use since it would be easy to invoke UB by using this type with an API that doesn't support unwinding drops.
277277

278+
## Allow individual `Drop` impls to opt-out of unwinding
279+
280+
This is a reverse of the previous point: the default behavior of drops could stay as it is, but individual `Drop` impls could opt-in to aborting if an unwind escapes it.
281+
282+
However this doesn't help generic code such as collections which still need to be able to handle user-defined types which do abort on drop.
283+
284+
## Only abort for unwinds out of implicit drops
285+
286+
This would still allow unwinds to escape calls to `drop_in_place`. Abort guards would be generated for implicit drops at the end of a scope.
287+
278288
## Only address the `catch_unwind` issue
279289

280290
Several solutions have been proposed ([disabling unwinding for unwind payloads](https://github.com/rust-lang/rust/pull/99032), [`drop_unwind`](https://github.com/rust-lang/rust/pull/85927), [`catch_unwind_v2`](https://internals.rust-lang.org/t/some-thoughts-on-a-less-slippery-catch-unwind/16902)) to specifically address the [issue](https://github.com/rust-lang/rust/issues/86027) with `catch_unwind`. However these increase API complexity and do not address the remaining issues.

0 commit comments

Comments
 (0)