我有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
做点什么吗?