]> git.lizzy.rs Git - rust.git/commit
rollup merge of #23651: alexcrichton/unwind-try
authorAlex Crichton <alex@alexcrichton.com>
Fri, 27 Mar 2015 17:07:42 +0000 (10:07 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 27 Mar 2015 17:07:42 +0000 (10:07 -0700)
commit6968ccfd7a9a8f568959defe7408532d8607a0bb
tree04730e89c1500c8a28bf98480df68e2a35be5dce
parentb79fbe0dae488513e4fead02a7da84102d932749
parent4c2ddb33ad9e2dbfc3713438472ca85cb5aefd07
rollup merge of #23651: alexcrichton/unwind-try

This commit provides a safe, but unstable interface for the `try` functionality
of running a closure and determining whether it panicked or not.

There are two primary reasons that this function was previously marked `unsafe`:

1. A vanilla version of this function exposes the problem of exception safety by
   allowing a bare try/catch in the language. It is not clear whether this
   concern should be directly tied to `unsafe` in Rust at the API level. At this
   time, however, the bounds on `ffi::try` require the closure to be both
   `'static` and `Send` (mirroring those of `thread::spawn`). It may be possible
   to relax the bounds in the future, but for now it's the level of safety that
   we're willing to commit to.

2. Panicking while panicking will leak resources by not running destructors.
   Because panicking is still controlled by the standard library, safeguards
   remain in place to prevent this from happening.

The new API is now called `catch_panic` and is marked as `#[unstable]` for now.
src/libstd/thread/mod.rs