diff --git a/src/compat/anyhow1.rs b/src/compat/anyhow1.rs index f197be4..e31f2dc 100644 --- a/src/compat/anyhow1.rs +++ b/src/compat/anyhow1.rs @@ -204,15 +204,6 @@ impl IntoRootcause for anyhow::Error { } } -impl IntoRootcause for anyhow::Result { - type Output = Result; - - #[inline(always)] - fn into_rootcause(self) -> Self::Output { - self.map_err(|e| e.into_rootcause()) - } -} - /// A trait for converting rootcause [`Report`]s into [`anyhow::Error`]. /// /// This trait provides the `.into_anyhow()` method for converting rootcause diff --git a/src/compat/boxed_error.rs b/src/compat/boxed_error.rs index 998e478..ddbaf04 100644 --- a/src/compat/boxed_error.rs +++ b/src/compat/boxed_error.rs @@ -372,21 +372,3 @@ impl IntoRootcause for Box { Report::new_local_custom::(self).into_dynamic() } } - -impl IntoRootcause for Result> { - type Output = Result; - - #[inline(always)] - fn into_rootcause(self) -> Self::Output { - self.map_err(|e| e.into_rootcause()) - } -} - -impl IntoRootcause for Result> { - type Output = Result>; - - #[inline(always)] - fn into_rootcause(self) -> Self::Output { - self.map_err(|e| e.into_rootcause()) - } -} diff --git a/src/compat/error_stack08.rs b/src/compat/error_stack08.rs index e5e8d83..317d6a5 100644 --- a/src/compat/error_stack08.rs +++ b/src/compat/error_stack08.rs @@ -214,18 +214,6 @@ where } } -impl IntoRootcause for Result> -where - C: core::error::Error + Send + Sync + 'static, -{ - type Output = Result>>; - - #[inline(always)] - fn into_rootcause(self) -> Self::Output { - self.map_err(|e| e.into_rootcause()) - } -} - /// A trait for converting rootcause [`Report`]s into [`error_stack::Report`]. /// /// This trait provides the `.into_error_stack()` method for converting diff --git a/src/compat/eyre06.rs b/src/compat/eyre06.rs index 373cf01..5bbd356 100644 --- a/src/compat/eyre06.rs +++ b/src/compat/eyre06.rs @@ -204,15 +204,6 @@ impl IntoRootcause for eyre::Report { } } -impl IntoRootcause for eyre::Result { - type Output = Result; - - #[inline(always)] - fn into_rootcause(self) -> Self::Output { - self.map_err(|e| e.into_rootcause()) - } -} - /// A trait for converting rootcause [`Report`]s into [`eyre::Report`]. /// /// This trait provides the `.into_eyre()` method for converting rootcause diff --git a/src/compat/mod.rs b/src/compat/mod.rs index 4db8745..9df1093 100644 --- a/src/compat/mod.rs +++ b/src/compat/mod.rs @@ -155,9 +155,23 @@ pub trait IntoRootcause { /// Box::new(std::io::Error::from(std::io::ErrorKind::NotFound)); /// let report: rootcause::Report = boxed.into_rootcause(); /// ``` + #[track_caller] fn into_rootcause(self) -> Self::Output; } +impl IntoRootcause for Result { + type Output = Result; + + #[inline] + fn into_rootcause(self) -> Self::Output { + // map_err doesn't work well with #[track_caller] + match self { + Self::Ok(t) => Ok(t), + Self::Err(e) => Err(e.into_rootcause()), + } + } +} + pub mod boxed_error; #[cfg(feature = "compat-anyhow1")] @@ -276,6 +290,7 @@ impl From> for ReportAsErr pub struct MainReport(Report); impl> From for MainReport { + #[track_caller] fn from(value: E) -> Self { Self(value.into_report().into_dynamic().into_cloneable()) }