Skip to content

Update std::thread::Result and std::panic::catch_unwind documentation to recommend std::panic::resume_unwind instead of unwrap #79950

Description

@yaahc

The current version of the std::thread::Result documentation recommends unwrapping a Result<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 to resume_unwind or how to repropagate caught panics at all, which ends up pushing users into the std::thread::Result if they're trying to figure out how to handle the Err variant of catch_unwind.

These docs should reference resume_unwind as the recommended way for re-propagating type erased panic payloads.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsT-libs-api[DEPRECATED; DO NOT USE]

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions