Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refer to format macro by absolute path #177

Merged
merged 1 commit into from Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)*))
};
}