From 585199398961fb1d2847985f719c169f31b6252f Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Fri, 17 Jan 2025 19:50:11 -0800 Subject: [PATCH] Fix test and clippy --- crates/bevy_ecs/src/relationship/mod.rs | 2 +- crates/bevy_transform/src/systems.rs | 25 +++++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/crates/bevy_ecs/src/relationship/mod.rs b/crates/bevy_ecs/src/relationship/mod.rs index cd4e22b369fbd..93e8508710095 100644 --- a/crates/bevy_ecs/src/relationship/mod.rs +++ b/crates/bevy_ecs/src/relationship/mod.rs @@ -118,7 +118,7 @@ pub trait Relationship: Component + Sized { entity.queue(|mut entity: EntityWorldMut| { if entity .get::() - .map_or(false, |t| t.is_empty()) + .is_some_and(RelationshipTarget::is_empty) { entity.remove::(); } diff --git a/crates/bevy_transform/src/systems.rs b/crates/bevy_transform/src/systems.rs index 6257f2cfcb1ed..898befe2963a4 100644 --- a/crates/bevy_transform/src/systems.rs +++ b/crates/bevy_transform/src/systems.rs @@ -453,14 +453,23 @@ mod test { app.world_mut() .spawn(Transform::IDENTITY) .add_children(&[child]); - let grandchild_parent = app.world().entity(grandchild).get::().unwrap().0; - let child_parent = app.world().entity(child).get::().unwrap().0; - app.world_mut() - .entity_mut(child) - .insert(Parent(grandchild_parent)); - app.world_mut() - .entity_mut(grandchild) - .insert(Parent(child_parent)); + core::mem::swap( + #[allow(unsafe_code)] + unsafe { + &mut *app + .world_mut() + .entity_mut(child) + .get_mut_assume_mutable::() + .unwrap() + }, + #[allow(unsafe_code)] + unsafe { + &mut *temp + .entity_mut(grandchild) + .get_mut_assume_mutable::() + .unwrap() + }, + ); app.update(); }