-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Hi there,
Upon rewriting some of my binrw-using code with lifetimes, I stumbled upon some interesting issue with what the macro generates about Vec and lifetimes, mainly that they seem incompatible, while the same struct without the Vec seems to compile fine.
I managed to make a minimal reproduction of the issue.
So considering a struct Zoo<'bar>, defined as such:
#[binrw]
struct Zoo<'bar>(std::marker::PhantomData<&'bar ()>);This snippet compiles fine, even with the 'bar lifetime.
#[binrw]
struct Foo<'bar> {
zoo: Zoo<'bar>,
}But this one fails.
#[binrw]
struct Foo<'bar> {
#[br(count = 1)]
zoos: Vec<Zoo<'bar>>,
}Here is the compiling error:
error: lifetime may not live long enough
|
249 | #[binrw]
| ^^^^^^^^ requires that `'bar` must outlive `'static`
250 | struct Foo<'bar> {
| ---- lifetime `'bar` defined here
|
= note: this error originates in the attribute macro `binrw` (in Nightly builds, run with -Z macro-backtrace for more info)
I started investigating the macro expansion, but unfortunately was unable to pinpoint an exact cause for this.
Let me know if you need any more context or help !
Thanks =)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working