Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Auto traits with closures #29

Closed
arora-aman opened this issue Nov 28, 2020 · 4 comments · Fixed by sexxi-goose/rust#52 or rust-lang/rust#84730
Closed

Auto traits with closures #29

arora-aman opened this issue Nov 28, 2020 · 4 comments · Fixed by sexxi-goose/rust#52 or rust-lang/rust#84730
Assignees

Comments

@arora-aman
Copy link
Member

One way to use AssertUnwindSafe is to do something like test/mir_calls_to_shim.

fn assert_panics<F>(f: F) where F: FnOnce() {
    let f = panic::AssertUnwindSafe(f);
    let result = panic::catch_unwind(move || {
        f.0()
    });
    if let Ok(..) = result {
        panic!("diverging function returned");
    }
}

This would not work once capture_disjoint_fields is enabled since f.0 is captured, essentially rendering the wrapper redundant.

@nikomatsakis
Copy link
Contributor

This is quite interesting, and similar to the problem where we capture subfields that are not Clone or entities which themselves are Clone

@arora-aman
Copy link
Member Author

Similar issue with Send and Sync
https://github.com/rust-lang/rust/blob/de88bf148b122b27ce48a4a6679c41c834d33019/compiler/rustc_interface/src/util.rs#L121-L126

Here run.0 isn't Send and Sync anymore.

@arora-aman arora-aman changed the title AssertUnwindSafe with closures Auto traits with closures Feb 17, 2021
@arora-aman
Copy link
Member Author

@arora-aman
Copy link
Member Author

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants