Skip to content

Commit 91fdfcc

Browse files
committed
glib: Only implement Send an JoinHandle if the result is Send
1 parent 9266ddd commit 91fdfcc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

glib/src/main_context_futures.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,10 @@ impl<T: 'static> futures_core::FusedFuture for JoinHandle<T> {
355355
}
356356
}
357357

358-
unsafe impl<T> Send for JoinHandle<T> {}
358+
/// Safety: We can't rely on the auto implementation because we are retrieving
359+
/// the result as a `Box<dyn Any + 'static>` from the [`Source`]. We need to
360+
/// rely on type erasure here, so we have to manually assert the Send bound too.
361+
unsafe impl<T: Send> Send for JoinHandle<T> {}
359362

360363
// rustdoc-stripper-ignore-next
361364
/// Variant of [`JoinHandle`] that is returned from [`MainContext::spawn_from_within`].

0 commit comments

Comments
 (0)