Skip to content
Myr

Merge pull request #185 from dtolnay/fmt

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Use processed format string even on old rust, but as String

authored by David Tolnay · committed by GitHub · parents 861c7a4, d279e40 · Browse files · 2 files+5 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+5 added−7 removed

  • other:+5 added−7 removed

2 files+5 added−7 removed

modified:src/lib.rs+4 added-6 removed
604 unmodified lines
605#[doc(hidden)]606pub mod private {607 use crate::Error;608 use alloc::fmt;609 use core::fmt::{Arguments, Debug, Display};609 use core::fmt::Arguments;610611 pub use alloc::format;612 pub use core::result::Result::Err;613 pub use core::{concat, format_args, stringify};
6 unmodified lines
620 pub use crate::kind::BoxedKind;621 }622623 #[doc(hidden)]624 #[inline]625 #[cold]625 pub fn format_err<M>(_message: M, args: Arguments) -> Error626 where627 M: Display + Debug + Send + Sync + 'static,628 {626 pub fn format_err(args: Arguments) -> Error {627 #[cfg(anyhow_no_fmt_arguments_as_str)]630 let fmt_arguments_as_str = Some(_message);628 let fmt_arguments_as_str = None::<&str>;629 #[cfg(not(anyhow_no_fmt_arguments_as_str))]630 let fmt_arguments_as_str = args.as_str();631632 if let Some(message) = fmt_arguments_as_str {
8 unmodified lines
modified:src/macros.rs+1 added-1 removed
166 unmodified lines
167/// ```168#[macro_export]169macro_rules! anyhow {170 ($msg:literal $(,)?) => ({171 let error = $crate::private::format_err($msg, $crate::private::format_args!($msg));171 let error = $crate::private::format_err($crate::private::format_args!($msg));172 error173 });174 ($err:expr $(,)?) => ({175 use $crate::private::kind::*;
8 unmodified lines