withoutboats / failure_derive

derive macro for the Fail trait
Apache License 2.0
24 stars 6 forks source link

#[derive(Fail)] panic #5

Open U007D opened 6 years ago

U007D commented 6 years ago

I'm getting:

error: proc-macro derive panicked
 --> chal/src/error.rs:3:10
  |
3 | #[derive(Fail, Debug, PartialEq)]
  |          ^^^^
  |
  = help: message: Couldn't find a field with this name!

I tried using the new #[macro_use] extern crate failure; syntax as well as the older #[macro_use] extern crate failure_derive; syntax. Same result.

I'm on failure 0.1.1, failure_derive 0.1.1 and rustc 1.24.0-nightly (f9b0897c5 2017-12-02) on Ubuntu.

Here is the entire module:

use super::*;

#[derive(Fail, Debug, PartialEq)]
pub enum Error {
    #[fail(display = "{}", MSG_ERR_BRAKE_AMT_RANGE)]
    BrakeAmtRange(#[cause] AdaTypesError),
}

impl From<AdaTypesError> for Error {
    fn from(e: AdaTypesError) -> Self { Error::BrakeAmtRange(e) }
}

Any ideas?

U007D commented 6 years ago

Tried same on Mac OS X 10.12.6 and with today's nightly (rustc 1.24.0-nightly (5a2465e2b 2017-12-06)) on both OSX and Ubuntu: same result.

U007D commented 6 years ago

Only literals are supported in the attribute. I see you have other bug(s) already for that, so I'll close this one out.

withoutboats commented 6 years ago

This is definitely because of the const you're trying to use, I would like to support consts and suspect its possible, I'm re-opening to track investigating consts in the display attribute.