From ac7e5e74d4a20aac83a9acc9df3477b4c10f3d3b Mon Sep 17 00:00:00 2001 From: Daniel Fox Franke Date: Mon, 29 Jul 2024 11:21:55 -0400 Subject: [PATCH] Make `Generic` `UnwindSafe` even if its error type isn't `std::io::Error` does not implement `UnwindSafe` on account of its ability to wrap a `Box`. This infects `Generic` which in turn infects `Channel`, which is inconvenient because it means you can't construct a channel pair, pass the receiver side to a child thread, and then handles panics in the child. But this is silly, because the error parameter to `Generic` is just a phantom. We aren't really wrapping an error at all, let alone downcasting it to a mutable reference and mucking with the referent. This patch changes the `PhantomData` to `PhantomData>` so that `Generic` can be `UnwindSafe` as long as `F` is. --- src/sources/generic.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sources/generic.rs b/src/sources/generic.rs index 4a76051f..9f98fead 100644 --- a/src/sources/generic.rs +++ b/src/sources/generic.rs @@ -42,7 +42,7 @@ //! [`EventSource`](crate::EventSource) implementation to them. use polling::Poller; -use std::{borrow, marker::PhantomData, ops, sync::Arc}; +use std::{borrow, marker::PhantomData, ops, panic::AssertUnwindSafe, sync::Arc}; #[cfg(unix)] use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd}; @@ -180,7 +180,7 @@ pub struct Generic { token: Option, // This allows us to make the associated error and return types generic. - _error_type: PhantomData, + _error_type: PhantomData>, } impl Generic {