calloop icon indicating copy to clipboard operation
calloop copied to clipboard

Make `Generic` `UnwindSafe` even if its error type isn't

Open dfoxfranke opened this issue 1 year ago • 1 comments

std::io::Error does not implement UnwindSafe on account of its ability to wrap a Box<dyn Error + Send + Sync>. 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<E> to PhantomData<AssertUnwindSafe<E>> so that Generic<F, E> can be UnwindSafe as long as F is.

dfoxfranke avatar Jul 29 '24 17:07 dfoxfranke

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 86.20%. Comparing base (86c6713) to head (ee61ade).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #204      +/-   ##
==========================================
+ Coverage   85.44%   86.20%   +0.75%     
==========================================
  Files          13       15       +2     
  Lines        1876     2066     +190     
==========================================
+ Hits         1603     1781     +178     
- Misses        273      285      +12     
Flag Coverage Δ
macos-latest 85.47% <ø> (?)
ubuntu-latest 85.80% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 29 '24 19:07 codecov[bot]