-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
runtime: mark JoinHandle as UnwindSafe (#4414) #4418
Conversation
Fixes: #4414 |
tokio/src/runtime/task/join.rs
Outdated
impl<T: Send> UnwindSafe for JoinHandle<T> {} | ||
impl<T: Send> RefUnwindSafe for JoinHandle<T> {} |
There was a problem hiding this comment.
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
?
tokio/tests/unwindsafe.rs
Outdated
#[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, | ||
{ | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 🙂
It seems like circle CI isn't reporting success :-/ |
There was a problem hiding this 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.
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