diff --git a/src/lib.rs b/src/lib.rs index 9be302b..cd1028d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -606,7 +606,7 @@ pub trait Context: context::private::Sealed { pub mod private { use crate::Error; use alloc::fmt; - use core::fmt::{Arguments, Debug, Display}; + use core::fmt::Arguments; pub use alloc::format; pub use core::result::Result::Err; @@ -621,13 +621,11 @@ pub mod private { } #[doc(hidden)] + #[inline] #[cold] - pub fn format_err(_message: M, args: Arguments) -> Error - where - M: Display + Debug + Send + Sync + 'static, - { + pub fn format_err(args: Arguments) -> Error { #[cfg(anyhow_no_fmt_arguments_as_str)] - let fmt_arguments_as_str = Some(_message); + let fmt_arguments_as_str = None::<&str>; #[cfg(not(anyhow_no_fmt_arguments_as_str))] let fmt_arguments_as_str = args.as_str(); diff --git a/src/macros.rs b/src/macros.rs index ae4e7e9..d8ba5c7 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -168,7 +168,7 @@ macro_rules! ensure { #[macro_export] macro_rules! anyhow { ($msg:literal $(,)?) => ({ - let error = $crate::private::format_err($msg, $crate::private::format_args!($msg)); + let error = $crate::private::format_err($crate::private::format_args!($msg)); error }); ($err:expr $(,)?) => ({