Doesn't work correctly with new Rust inline formatting
Nowadays Rust supports inline formatting for variables like format!("Expected {a} to be {b}").
This syntax works correctly in format!, format_args!, anyhow! and a lot of other contexts.
However, in eyre, somewhat surprisingly, it treats the string as a literal and prints without interpolation, even though eyre itself has support for formatting when arguments are passed explicitly. It seems this stems from all macros (ensure!, bail!, eyre!) having a separate branch that catches string literal with no following arguments in a special way:
macro_rules! eyre {
($msg:literal $(,)?) => { ... };
($err:expr $(,)?) => { ... };
($fmt:expr, $($arg:tt)*) => { ... };
}
Seems like an easy fix - should i submit a PR?
Ah, turns out its already been fixed, but has not been released yet. Thx for all the hard work updating it. Can't wait for the new release!
Oh, it was? Where did you see that?
https://github.com/eyre-rs/eyre/blob/master/eyre/build.rs#L63-L69
TBH, the implementation seems a bit convoluted, but I might simply not know enough about it. Most implementations I have seen simply rely on format_args! like so:
macro_rules! foo {
($($arg:tt)+) => {
format_args!($($arg)+)
};
}
I don't understand how the referenced lines are related to feature in question.
They are used https://github.com/eyre-rs/eyre/blob/0b24ae558f4779afccb1dfc4640c57d9922ff70e/eyre/src/lib.rs#L1231-L1234 and in a test https://github.com/eyre-rs/eyre/blob/0b24ae558f4779afccb1dfc4640c57d9922ff70e/eyre/tests/test_macros.rs#L78-L85
Looks like this was released, so closing.