rust-lang-deprecated / failure

Error management
https://rust-lang-nursery.github.io/failure/
Apache License 2.0
1.43k stars 140 forks source link

Having a field of type Backtrace causes #[derive(Fail)] to fail #291

Open dflemstr opened 5 years ago

dflemstr commented 5 years ago

Test case to reproduce:

#[derive(Debug)]
struct Backtrace;

#[derive(Debug, Fail)]
#[fail(display = "error")]
struct Error {
    backtrace: Backtrace,
}

I suppose this is a common case of unhygienic procedural macros :)

theduke commented 5 years ago

The derive assumes a backtrace field to hold a failure::Backtrace. The only sees tokens, so it can't check that the type of the field is something other than that.

I reckon there could be something like a #[fail(ignore)] attribute to enable this.