Handle::try_apply is not appropriately gated on matching T type
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
> I believe that `Handle::try_apply` is affected too. I tried adding the code below to the test and it fails. If you don't want to fix that in this PR then I'm happy to make a follow up PR.
```rust
let mut assets_b = app.world_mut().resource_mut::>();
let mut handle_b = assets_b.add(B);
assert!(handle_b.try_apply(reflected_handle_a).is_err());
```
_Originally posted by @greeble-dev in https://github.com/bevyengine/bevy/pull/24048#pullrequestreview-4214543263_
I looked into this, and it's non-trivial: we need to somehow modify the generated code for try_apply. Ideally we could have a robust, automatic solution here, rather than relying on special-cased manual impls or more attributes, but I'm not confident on the best design here.
Contributor guide
Research direction
Start at Handle::try_apply and trace the generated code it uses, since the issue identifies that as the affected entry point. Use the shown Assets/Assets test case to verify that applying a handle with a mismatched T returns an error, then confirm the solution avoids special-cased manual implementations or extra attributes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100