derive_more
derive_more copied to clipboard
Invalid syntax in Display fmt fails silently
trafficstars
Consider this code:
use derive_more::Display;
#[derive(Display)]
#[display(fmt = "Stuff({})", .bar)]
pub struct Foo {
bar: String
}
fn main() {
println!("{}", Foo { bar: "test".into() });
}
This prints just test. Similarly, if you do this, it still prints test:
#[derive(Display)]
#[display(fmt = "Stuff({})", .barrrrrrr)]
pub struct Foo {
bar: String
}
The correct syntax here would be to use just bar in the format, but that's not super obvious since no error is raised.
Perhaps this could be fixed to inform the user that the format is just wrong?
Thanks!
cc @ilslv
@tyranron should we add trybuild to test invalid inputs?
@ilslv seems reasonable.