> This is because Rust’s attribute grammar can’t support a callable here.
The grammar of attributes supports it fine, it's just that Serde chooses to not use it. I'm not sure if it's because Serde started before it was allowed or if it's a stylistic preference or what.
For example, my crate SNAFU allows you[1] to use attributes containing types (`Error`) and expressions (`Box::new`):
#[derive(Debug, Snafu)]
#[snafu(source(from(Error, Box::new)))]
struct ApiError(Box<Error>);
[1]: https://docs.rs/snafu/latest/snafu/derive.Snafu.html#transfo...