Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: mark JoinHandle as UnwindSafe (#4414) #4418

Merged
merged 2 commits into from Jan 24, 2022

Conversation

Hodkinson
Copy link
Contributor

Marking JoinHandle as UnwindSafe allows for more ergonomic panic handling resolving this example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=77e8b4432bd28f50080cbae9eb26b8ae

Motivation

Solution

@github-actions github-actions bot added the R-loom Run loom tests on this PR label Jan 23, 2022
@Hodkinson
Copy link
Contributor Author

Fixes: #4414

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-task Module: tokio/task labels Jan 23, 2022
Comment on lines 154 to 155
impl<T: Send> UnwindSafe for JoinHandle<T> {}
impl<T: Send> RefUnwindSafe for JoinHandle<T> {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should it not be unwind safe when T isn't Send?

Comment on lines 7 to 20
#[tokio::test]
async fn futures_are_unwind_safe() {
unwind_safe_future(|| async {
let _ = spawn_blocking(|| {}).await;
})
.await
}

async fn unwind_safe_future<F, Fut>(_: F)
where
F: FnOnce() -> Fut,
Fut: std::future::Future<Output = ()> + std::panic::UnwindSafe,
{
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a pretty convoluted way to test this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I altered it to test the actual change 🙂

@carllerche
Copy link
Member

It seems like circle CI isn't reporting success :-/

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-task Module: tokio/task R-loom Run loom tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants