diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs index d0aefc0c84..7a291c716f 100644 --- a/src/client/dispatch.rs +++ b/src/client/dispatch.rs @@ -226,28 +226,31 @@ pub(crate) enum Callback { impl Drop for Callback { fn drop(&mut self) { - // FIXME(nox): What errors do we want here? - let error = crate::Error::new_user_dispatch_gone().with(if std::thread::panicking() { - "user code panicked" - } else { - "runtime dropped the dispatch task" - }); - match self { Callback::Retry(tx) => { if let Some(tx) = tx.take() { - let _ = tx.send(Err((error, None))); + let _ = tx.send(Err((dispatch_gone(), None))); } } Callback::NoRetry(tx) => { if let Some(tx) = tx.take() { - let _ = tx.send(Err(error)); + let _ = tx.send(Err(dispatch_gone())); } } } } } +#[cold] +fn dispatch_gone() -> crate::Error { + // FIXME(nox): What errors do we want here? + crate::Error::new_user_dispatch_gone().with(if std::thread::panicking() { + "user code panicked" + } else { + "runtime dropped the dispatch task" + }) +} + impl Callback { #[cfg(feature = "http2")] pub(crate) fn is_canceled(&self) -> bool {