From ff7406e6d8b70884faaff7707c7d917faabe1a53 Mon Sep 17 00:00:00 2001
From: HampusM <hampus@hampusmat.com>
Date: Wed, 2 Apr 2025 13:30:01 +0200
Subject: refactor(ecs): remove unnecessary upgrading of lock lifetimes

---
 ecs/src/relationship.rs | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

(limited to 'ecs/src/relationship.rs')

diff --git a/ecs/src/relationship.rs b/ecs/src/relationship.rs
index 89c64ed..235c21e 100644
--- a/ecs/src/relationship.rs
+++ b/ecs/src/relationship.rs
@@ -62,7 +62,7 @@ where
     Kind: 'static,
     ComponentT: Component,
 {
-    component_storage_lock: ReadGuard<'static, ComponentStorage>,
+    component_storage_lock: ReadGuard<'rel_comp, ComponentStorage>,
     relationship_comp: ComponentRefMut<'rel_comp, Relationship<Kind, ComponentT>>,
 }
 
@@ -91,9 +91,7 @@ where
 
         Ok(Self {
             relationship_comp,
-            // SAFETY: The component lock is not used for longer than the original
-            // lifetime
-            component_storage_lock: unsafe { component_storage_lock.upgrade_lifetime() },
+            component_storage_lock,
         })
     }
 }
@@ -286,7 +284,7 @@ where
     Kind: 'static,
     ComponentT: Component,
 {
-    component_storage_lock: ReadGuard<'static, ComponentStorage>,
+    component_storage_lock: ReadGuard<'rel_comp, ComponentStorage>,
     relationship_comp: ComponentRef<'rel_comp, Relationship<Kind, ComponentT>>,
 }
 
@@ -315,9 +313,7 @@ where
 
         Ok(Self {
             relationship_comp,
-            // SAFETY: The component lock is not used for longer than the original
-            // lifetime
-            component_storage_lock: unsafe { component_storage_lock.upgrade_lifetime() },
+            component_storage_lock,
         })
     }
 }
-- 
cgit v1.2.3-18-g5258