{"record":{"id":"2c91a61cad1e5903","repo":"bevyengine/bevy","slug":"entity","errorCode":null,"errorMessage":"Entity {} {}","messagePattern":"Entity (.+?) (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/src/world/entity_access/world_mut.rs","lineNumber":65,"sourceCode":"/// You can check this via [`is_despawned`](Self::is_despawned).\n/// Using an [`EntityWorldMut`] of a despawned entity may panic in some contexts, so read method documentation carefully.\n///\n/// Unless you have strong reason to assume these invariants, you should generally avoid keeping an [`EntityWorldMut`] to an entity that is potentially not spawned.\n/// For example, when inserting a component, that component insert may trigger an observer that despawns the entity.\n/// So, when you don't have full knowledge of what commands may interact with this entity,\n/// do not further use this value without first checking [`is_despawned`](Self::is_despawned).\npub struct EntityWorldMut<'w> {\n    world: &'w mut World,\n    entity: Entity,\n    location: Option<EntityLocation>,\n}\n\nimpl<'w> EntityWorldMut<'w> {\n    #[track_caller]\n    #[inline(never)]\n    #[cold]\n    fn panic_despawned(&self) -> ! {\n        panic!(\n            \"Entity {} {}\",\n            self.entity,\n            self.world.entities().get_spawned(self.entity).unwrap_err()\n        );\n    }\n\n    #[inline(always)]\n    #[track_caller]\n    pub(crate) fn assert_not_despawned(&self) {\n        if self.location.is_none() {\n            self.panic_despawned()\n        }\n    }\n\n    #[inline(always)]\n    fn as_unsafe_entity_cell_readonly(&self) -> UnsafeEntityCell<'_> {\n        let location = self.location();\n        let last_change_tick = self.world.last_change_tick;","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/src/world/entity_access/world_mut.rs#L47-L83","documentation":"Generic panic helper (panic_despawned) on EntityWorldMut: the entity has already been despawned, so further use of this handle is invalid. Callers like assert_not_despawned, location, and archetype forward their own context into this message.","triggerScenarios":"Thrown at crates/bevy_ecs/src/world/entity_access/world_mut.rs:65 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check is_despawned() before continuing to use the handle","Avoid using an EntityWorldMut after operations that may despawn the entity (e.g. component inserts that trigger observers)","Re-fetch the entity via world.get_entity_mut(id) if it may have been despawned"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}