-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad error when AssetServer::load is called on &str from event reader (possibly flawed lifetimes?) #14080
Comments
Since AssetServer::load takes
since you already use owned String. |
@bugsweeper i should clarify: i know this is the solution. i'm not asking for that. i'm reporting a error message which is quite confusing, as the error somehow points to the wrong line. this may be a rustc issue, but i lack the knowledge of EventReade and AssetServer internals to reproduce it without bevy. |
Oh, I see, the reason of this issue is not
Is this acceptable to you? |
I think you still misunderstand: The code is not the issue i am reporting. I'm not asking for a solution. I know it. The error message is what i'm reporting, as the error is confusing. I have no idea if bevy can improve this error message in any way, but its definitely something worth reporting. |
This error is rust lifetime error. In this circumstances bevy knows nothing about what happens. I think the best what we can do is to add to AssetServer::load (as more viewed than AssetPath::from) docs mention of such case. @laundmo Would someone else you was helping with bevy look at it? @alice-i-cecile do you agree with me? |
Docs are unlikely to help much. A usage example doc test for this would be good though. IMO we should file an issue on the Rust repo linking this one. |
Bevy version
Bevy 0.13
What you did
Used a EventReader which includes a String, and passed a &str based on this to AssetServer::load
This is a minimal reproduction.
What went wrong
The resulting error message was very unclear, pointing at the events.read() call as "
events
escapes the function body here" which is highly confusing when it happens.Additional information
This error was not encountered directly by me, but someone else I was helping with bevy. They're pretty new to Rust which is why cloning the String instead was not immediately obvious, causing some headaches.
I believe the fact that this error message is this wrong, could point towards some badly specified or unclear lifetimes in AssetServer::load or EvenrReader::read. I was unable to reproduce a similar error with only Rust stdlib, but I may be wrong here.
The text was updated successfully, but these errors were encountered: