Update std::thread::Result
and std::panic::catch_unwind
documentation to recommend std::panic::resume_unwind
instead of unwrap
#79950
Labels
A-docs
Area: documentation for any part of the project, including the compiler, standard library, and tools
A-runtime
Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
The current version of the
std::thread::Result
documentation recommends unwrapping aResult<T, Box<dyn Any + ...>>
in order to re-start propagation of a caught panic. This recommendation will not simply resume the panic as it was originally. Once the error type has been erased and Boxed the panic can no longer be downcast directly back to the actual payload type. Instead you have to also try downcasting twice.std::panic::catch_unwind
on the other hand has no references toresume_unwind
or how to repropagate caught panics at all, which ends up pushing users into thestd::thread::Result
if they're trying to figure out how to handle theErr
variant ofcatch_unwind
.These docs should reference
resume_unwind
as the recommended way for re-propagating type erased panic payloads.The text was updated successfully, but these errors were encountered: