#cryptic error when trying to derive reflect

35 messages · Page 1 of 1 (latest)

pearl crown
#

my only guess is that it could have something to do with recursive types, since a type of module can contain instances StoredItem
i fixed the initial error about recursion by ignoring that field on the module, but now i get this

odd holly
#

I'm not entirely sure, but I think that Reflect needs static lifetimes, which might be the problem, since I see some lifetime stuff?

pearl crown
#

i think those are for the macro's internals, my structures only contain owned values

worldly jewel
#

Could you share the definitions for the other types in the variants?

#

And if you have the time, running cargo expand and replacing the derive with the output should point to exactly where in the output we’re hitting the error

odd holly
#

If you could show the rest of the relevant code, it would be easier to debug (Only if you want to share it tho :D)

pearl crown
pearl crown
#

expanding it gave me this

odd holly
#

Are you one the main branch?

pearl crown
#

yeah

#

0.14.2

#

sorry 0.14.1

#

and i'm using nightly

odd holly
#

Oohhhh

#

it's not even a bevy error

#

just regular rust

#

The function you are implementing uses &mut self, but you are trying to return the value of self.0, which may not always be valid since &mut self only lasts for the function scope without a lifteime

#

depending on what value is you could maybe just clone it?

pearl crown
#

that's what the macro expands to..

#

that code was not written by me

odd holly
#

ooohh welp

#

I would try to change to stable and if that doesn't work, then maybe open an issue on the bevy github?

pearl crown
#

i'll try updating my toolchain

#

this is my current one

#

if anyone wanna try and debug this, i can share the repo

odd holly
#

If stable doesn't work I think you should open an issue and share a copy of the code. If you want you could also try doing a minimal reproduction project?

pearl crown
#

it compiles juts fine on stable 😓

odd holly
#

Are you using nightly for something specific?

pearl crown
#

not for this project atm
so i guess this issue could be considered resolved

worldly jewel
#

We’re not changing the lifetime at all and it’s taking not actually using *self

#

If you tried manually implementing a method on your enum exactly like that one, does it produce the same error?

pearl crown
#

i just expanded and pasted that in
i could try that tomorrow if you think that would help narrow it down