Skip to content

Commit

Permalink
Merge pull request #177 from dtolnay/format
Browse files Browse the repository at this point in the history
Refer to format macro by absolute path
  • Loading branch information
dtolnay committed Nov 2, 2021
2 parents 263257b + 95351e3 commit c50588f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions src/lib.rs
Expand Up @@ -233,7 +233,7 @@

mod alloc {
#[cfg(not(feature = "std"))]
extern crate alloc;
pub extern crate alloc;

#[cfg(not(feature = "std"))]
pub use alloc::boxed::Box;
Expand Down Expand Up @@ -624,10 +624,17 @@ pub mod private {
}

#[cfg(anyhow_no_macro_reexport)]
pub use crate::{__anyhow_concat as concat, __anyhow_stringify as stringify};
pub use crate::{
__anyhow_concat as concat, __anyhow_format as format, __anyhow_stringify as stringify,
};
#[cfg(not(anyhow_no_macro_reexport))]
pub use core::{concat, stringify};

#[cfg(all(not(anyhow_no_macro_reexport), not(feature = "std")))]
pub use crate::alloc::alloc::format;
#[cfg(all(not(anyhow_no_macro_reexport), feature = "std"))]
pub use std::format;

#[cfg(anyhow_no_macro_reexport)]
#[doc(hidden)]
#[macro_export]
Expand All @@ -637,6 +644,15 @@ pub mod private {
};
}

#[cfg(anyhow_no_macro_reexport)]
#[doc(hidden)]
#[macro_export]
macro_rules! __anyhow_format {
($($tt:tt)*) => {
format!($($tt)*)
};
}

#[cfg(anyhow_no_macro_reexport)]
#[doc(hidden)]
#[macro_export]
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Expand Up @@ -179,6 +179,6 @@ macro_rules! anyhow {
}
});
($fmt:expr, $($arg:tt)*) => {
$crate::Error::msg(format!($fmt, $($arg)*))
$crate::Error::msg($crate::private::format!($fmt, $($arg)*))
};
}

0 comments on commit c50588f

Please sign in to comment.