allow accessing attributes and methods in #[fail(display=)] string interpolation
In error-chain, I had stuff like:
ItemAlreadyExists(iid: ItemID) {
description("An Item already exists.")
display("The Item {} already exists", iid.0)
}
but it appears that accessing attributes like this is illegal in failure_derive:
#[fail(display="The Item {} already exists", _0.0)]
ItemAlreadyExists(ItemID),
leads to
error: expected one of `(`, `,`, or `=`, found `.`
--> pandt\src\types.rs:747:52
|
747 | #[fail(display="The Item {} already exists", _0.0)]
| ^ expected one of `(`, `,`, or `=` here
actually, I made a mistake, that's not the right error. I'm just getting a general "Failed to parse input" error, but I haven't figured out if this is exactly what's causing the parsing error...
This is an unfortunate limitation of the rustc attribute syntax; once attributes are more flexible, I intend to make this work more like how you would expect it to (self.0 instead of _0, support methods and so on).
I was working on a PR to make rustc accept more syntax here, but I dropped the ball on it: https://github.com/rust-lang/rust/pull/45244