From 81db6ec70af12f3064f29938da7c258077d4417d Mon Sep 17 00:00:00 2001 From: aecsocket <43144841+aecsocket@users.noreply.github.com> Date: Tue, 19 Nov 2024 01:28:42 +0000 Subject: [PATCH] Fix `bevy_hierarchy` failing to compile without `reflect` feature (#16428) # Objective Run this without this PR: `cargo build -p bevy_hierarchy --no-default-features` You'll get: ``` error[E0432]: unresolved import `bevy_reflect` --> crates/bevy_hierarchy/src/events.rs:2:5 | 2 | use bevy_reflect::Reflect; | ^^^^^^^^^^^^ use of undeclared crate or module `bevy_reflect` For more information about this error, try `rustc --explain E0432`. error: could not compile `bevy_hierarchy` (lib) due to 1 previous error warning: build failed, waiting for other jobs to finish... ``` Because of this line: ```rs use bevy_reflect::Reflect; #[derive(Event, Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "reflect", derive(Reflect), reflect(Debug, PartialEq))] pub enum HierarchyEvent { .. } ``` ## Solution use FQN: `derive(bevy_reflect::Reflect)` ## Testing `cargo build -p bevy_hierarchy --no-default-features` --- crates/bevy_hierarchy/src/events.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bevy_hierarchy/src/events.rs b/crates/bevy_hierarchy/src/events.rs index c397488c08..5a667fef77 100644 --- a/crates/bevy_hierarchy/src/events.rs +++ b/crates/bevy_hierarchy/src/events.rs @@ -1,4 +1,5 @@ use bevy_ecs::{event::Event, prelude::Entity}; +#[cfg(feature = "reflect")] use bevy_reflect::Reflect; /// An [`Event`] that is fired whenever there is a change in the world's hierarchy.