0

我有struct一个非'static生命周期,sruct然后使用enum它代表我的错误:

#[derive(Debug, Fail)]
pub enum ParserError<'a> {
    #[fail(display = "Unexpected [{}] got {}", _1, _0)]
    ExpectedAGotB(Token<'a>, TokenKindExpectedOptions<'a>),
}

由于failure' 的'static生命周期要求,#[derive(Failre)]我收到此错误:

error[E0478]: lifetime bound not satisfied
  --> src/lib/ra_parser/src/errors.rs:18:17
   |
18 | #[derive(Debug, Fail)]
   |                 ^^^^
   |
note: lifetime parameter instantiated with the lifetime `'a` as defined on the impl at 19:22
  --> src/lib/ra_parser/src/errors.rs:19:22
   |
19 | pub enum ParserError<'a> {
   |                      ^^
   = note: but lifetime parameter must outlive the static lifetime
   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)

我解决这个问题的策略是什么?有没有办法制作Token<'static>,也许没有。我应该自己impl做点什么吗?

4

0 回答 0