bevy/crates
JoJoJet fe852fd0ad
Fix boxed labels (#8436)
# Objective

Label traits such as `ScheduleLabel` currently have a major footgun: the
trait is implemented for `Box<dyn ScheduleLabel>`, but the
implementation does not function as one would expect since `Box<T>` is
considered to be a distinct type from `T`. This is because the behavior
of the `ScheduleLabel` trait is specified mainly through blanket
implementations, which prevents `Box<dyn ScheduleLabel>` from being
properly special-cased.

## Solution

Replace the blanket-implemented behavior with a series of methods
defined on `ScheduleLabel`. This allows us to fully special-case
`Box<dyn ScheduleLabel>` .

---

## Changelog

Fixed a bug where boxed label types (such as `Box<dyn ScheduleLabel>`)
behaved incorrectly when compared with concretely-typed labels.

## Migration Guide

The `ScheduleLabel` trait has been refactored to no longer depend on the
traits `std::any::Any`, `bevy_utils::DynEq`, and `bevy_utils::DynHash`.
Any manual implementations will need to implement new trait methods in
their stead.

```rust
impl ScheduleLabel for MyType {
    // Before:
    fn dyn_clone(&self) -> Box<dyn ScheduleLabel> { ... }

    // After:
    fn dyn_clone(&self) -> Box<dyn ScheduleLabel> { ... }

    fn as_dyn_eq(&self) -> &dyn DynEq {
        self
    }

    // No, `mut state: &mut` is not a typo.
    fn dyn_hash(&self, mut state: &mut dyn Hasher) {
        self.hash(&mut state);
        // Hashing the TypeId isn't strictly necessary, but it prevents collisions.
        TypeId::of::<Self>().hash(&mut state);
    }
}
```
2023-04-19 02:36:44 +00:00
..
bevy_a11y Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_animation Improved AnimationPlugin declaration. (#8361) 2023-04-12 19:27:38 +00:00
bevy_app Non-breaking change* from UK spellings to US (#8291) 2023-04-08 16:22:46 +00:00
bevy_asset Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_audio Ability to set a Global Volume (#7706) 2023-04-10 14:08:43 +00:00
bevy_core Register some extra types to type registry (#8430) 2023-04-17 20:05:59 +00:00
bevy_core_pipeline Non-breaking change* from UK spellings to US (#8291) 2023-04-08 16:22:46 +00:00
bevy_derive Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_diagnostic Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_dylib Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_dynamic_plugin Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_ecs Fix boxed labels (#8436) 2023-04-19 02:36:44 +00:00
bevy_ecs_compile_fail_tests Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_encase_derive Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_gilrs Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_gizmos do not crash when rendering only one gizmo (#8434) 2023-04-18 16:31:55 +00:00
bevy_gltf Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_hierarchy fix panic when moving child (#8346) 2023-04-17 18:03:47 +00:00
bevy_input Non-breaking change* from UK spellings to US (#8291) 2023-04-08 16:22:46 +00:00
bevy_internal add a feature for memory tracing with tracy (#8272) 2023-04-17 16:04:46 +00:00
bevy_log add a feature for memory tracing with tracy (#8272) 2023-04-17 16:04:46 +00:00
bevy_macro_utils Fix boxed labels (#8436) 2023-04-19 02:36:44 +00:00
bevy_math Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_mikktspace Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_pbr Fix pbr shader breaking on missing UVs (#8412) 2023-04-17 06:22:34 +00:00
bevy_ptr Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_reflect Non-breaking change* from UK spellings to US (#8291) 2023-04-08 16:22:46 +00:00
bevy_reflect_compile_fail_tests bevy_reflect: Fix trailing comma breaking derives (#8014) 2023-03-27 21:47:33 +00:00
bevy_render Fix get_vertex_buffer_data doc (#8400) 2023-04-17 16:12:12 +00:00
bevy_scene Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
bevy_sprite Add Reflection Macros to TextureAtlasSprite (#8428) 2023-04-17 20:24:17 +00:00
bevy_tasks Cleaned up panic messages (#8219) 2023-04-12 18:27:28 +00:00
bevy_text Register some extra types to type registry (#8430) 2023-04-17 20:05:59 +00:00
bevy_time Add a scope API for world schedules (#8387) 2023-04-16 05:09:33 +00:00
bevy_transform Fix transform propagation of orphaned entities (#7264) 2023-04-09 20:53:33 +00:00
bevy_ui Allow bevy_ui crate to compile without the text feature enabled (#8437) 2023-04-18 19:41:02 +00:00
bevy_utils Fix boxed labels (#8436) 2023-04-19 02:36:44 +00:00
bevy_window Non-breaking change* from UK spellings to US (#8291) 2023-04-08 16:22:46 +00:00
bevy_winit Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00