-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Change HandleUntyped::typed to not panic #2536
Conversation
Fixes #2534 Introduces a new FIXME: Naughty pipeline handle should be typed for a strange pattern encountered in internal uses of `typed`.
bors try |
tryBuild failed: |
@cart do you have insight on this? Will the new renderer changes alter this? |
Hmm seems I done a silly one and forgot to run |
Actually I forgot to run the whole CI. Still some elbow grease to go on this one! |
@alice-i-cecile With this change, However this raises a further question, how come it wasn't a This feels like a big API change, so should I do the same and output a warning instead of changing the return type of (I didn't notice this earlier since I was being a silly man and forgot to run the CI that showed the actual scope of the change 😅) |
bors try |
tryBuild failed: |
Hmm. I'm genuinely unsure. I know asset loading is deliberately async; maybe it's to avoid propagating results? In any case, I think we should split this work out and create a new issue. The asset pipeline needs some serious design work in general (see #1701, #708) so it's better to tackle that more holistically. |
Actually, upon a bit more careful investigation, currently the error path would never trigger anyways. Anyways, fixed the CI errors and reverted the |
There isn't yet a const way to make a bevy/crates/bevy_asset/src/handle.rs Line 244 in a4e5e27
|
Yeah, you're right, I scratched up this change but it requires It could be revisited once that language feature get stabilized. Regarding the contents of this PR, this should be ready for review. |
Not a fan of the |
How about this?
|
Good for me! Thanks |
Curious, I'm pretty sure handle used to return a |
Could we add unit tests to bind the |
Poking around, it looks like this got changed for 0.3, from https://docs.rs/bevy/0.2.0/bevy/prelude/struct.Handle.html to https://docs.rs/bevy/0.3.0/bevy/asset/struct.HandleUntyped.html#method.typed. Here's the line / commit to blame: c32e637#diff-cffa1459c07909ff31710f4d23192ae34a30938951b42076f162702f04c3f601L79 The PR description has no justification of this change; @cart did you have some Extremely Good Argument against making this return a Result/Option that we've overlooked? I suspect it was just overlooked :) |
No "extremely good argument". Just the argument that the implicit panic is more ergonomic. I'm down to change it, given how uncommon this scenario is. |
Closing this out, as I don't think it's relevant any more after #4794 :) |
Objective
Fixes #2534
Solution
Changed the signature and implementation of
HandleUntyped::typed
to return aResult
instead of panicking.Adjusted a bunch of engine crate code that uses that function, but I sense a code smell. All usages are creating
HandleUntyped
s statically, and converting toHandle<T>
on use. This could be avoided by just creating aHandle<T>
in the first place.I'll open another PR with that change.