diff --git a/src/chain.rs b/src/chain.rs index 7a66383..369ff7d 100644 --- a/src/chain.rs +++ b/src/chain.rs @@ -44,6 +44,7 @@ pub(crate) enum ChainState<'a> { } impl<'a> Chain<'a> { + #[cold] pub(crate) fn new(head: &'a (dyn StdError + 'static)) -> Self { Chain { state: ChainState::Linked { next: Some(head) }, diff --git a/src/eyreish/error.rs b/src/eyreish/error.rs index 2ecab03..13c71c3 100644 --- a/src/eyreish/error.rs +++ b/src/eyreish/error.rs @@ -21,6 +21,7 @@ impl Report { /// If the error type does not provide a backtrace, a backtrace will be /// created here to ensure that a backtrace exists. #[cfg_attr(track_caller, track_caller)] + #[cold] pub fn new(error: E) -> Self where E: Diagnostic + Send + Sync + 'static, @@ -66,6 +67,7 @@ impl Report { /// } /// ``` #[cfg_attr(track_caller, track_caller)] + #[cold] pub fn msg(message: M) -> Self where M: Display + Debug + Send + Sync + 'static, @@ -86,6 +88,7 @@ impl Report { } #[cfg_attr(track_caller, track_caller)] + #[cold] pub(crate) fn from_std(error: E) -> Self where E: Diagnostic + Send + Sync + 'static, @@ -107,6 +110,7 @@ impl Report { } #[cfg_attr(track_caller, track_caller)] + #[cold] pub(crate) fn from_adhoc(message: M) -> Self where M: Display + Debug + Send + Sync + 'static, @@ -131,6 +135,7 @@ impl Report { } #[cfg_attr(track_caller, track_caller)] + #[cold] pub(crate) fn from_msg(msg: D, error: E) -> Self where D: Display + Send + Sync + 'static, @@ -155,6 +160,7 @@ impl Report { } #[cfg_attr(track_caller, track_caller)] + #[cold] pub(crate) fn from_boxed(error: Box) -> Self { use super::wrapper::BoxedError; let error = BoxedError(error); @@ -180,6 +186,7 @@ impl Report { // // Unsafe because the given vtable must have sensible behavior on the error // value of type E. + #[cold] unsafe fn construct( error: E, vtable: &'static ErrorVTable, @@ -262,6 +269,7 @@ impl Report { /// None /// } /// ``` + #[cold] pub fn chain(&self) -> Chain<'_> { unsafe { ErrorImpl::chain(self.inner.by_ref()) } } @@ -424,6 +432,7 @@ where E: Diagnostic + Send + Sync + 'static, { #[cfg_attr(track_caller, track_caller)] + #[cold] fn from(error: E) -> Self { Report::from_std(error) } @@ -711,6 +720,7 @@ impl ErasedErrorImpl { .deref_mut() } + #[cold] pub(crate) unsafe fn chain(this: Ref<'_, Self>) -> Chain<'_> { Chain::new(Self::error(this)) } @@ -746,6 +756,7 @@ where } impl From for Box { + #[cold] fn from(error: Report) -> Self { let outer = ManuallyDrop::new(error); unsafe { @@ -757,6 +768,7 @@ impl From for Box { } impl From for Box { + #[cold] fn from(error: Report) -> Self { let outer = ManuallyDrop::new(error); unsafe { @@ -768,12 +780,14 @@ impl From for Box { } impl From for Box { + #[cold] fn from(error: Report) -> Self { Box::::from(error) } } impl From for Box { + #[cold] fn from(error: Report) -> Self { Box::::from(error) } diff --git a/src/eyreish/kind.rs b/src/eyreish/kind.rs index ce60b50..6b0f5ec 100644 --- a/src/eyreish/kind.rs +++ b/src/eyreish/kind.rs @@ -63,6 +63,7 @@ impl AdhocKind for &T where T: ?Sized + Display + Debug + Send + Sync + 'stat impl Adhoc { #[cfg_attr(track_caller, track_caller)] + #[cold] pub fn new(self, message: M) -> Report where M: Display + Debug + Send + Sync + 'static, @@ -84,6 +85,7 @@ impl TraitKind for E where E: Into {} impl Trait { #[cfg_attr(track_caller, track_caller)] + #[cold] pub fn new(self, error: E) -> Report where E: Into, @@ -105,6 +107,7 @@ impl BoxedKind for Box {} impl Boxed { #[cfg_attr(track_caller, track_caller)] + #[cold] pub fn new(self, error: Box) -> Report { Report::from_boxed(error) } diff --git a/src/eyreish/mod.rs b/src/eyreish/mod.rs index acc2ea3..2dfbf71 100644 --- a/src/eyreish/mod.rs +++ b/src/eyreish/mod.rs @@ -475,6 +475,7 @@ pub mod private { } #[cfg_attr(track_caller, track_caller)] + #[cold] pub fn new_adhoc(message: M) -> Report where M: Display + Debug + Send + Sync + 'static,