Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Improve panic report with reentrant SlotMap use (#22667)

Cole Millerde08e47e5bc9
diff --git a/crates/gpui/src/app/entity_map.rs b/crates/gpui/src/app/entity_map.rs
index 07aa466295a..8bf9c67269a 100644
--- a/crates/gpui/src/app/entity_map.rs
+++ b/crates/gpui/src/app/entity_map.rs
@@ -117,8 +117,9 @@ impl EntityMap {
pub fn read<T: 'static>(&self, model: &Model<T>) -> &T {
self.assert_valid_context(model);
- self.entities[model.entity_id]
- .downcast_ref()
+ self.entities
+ .get(model.entity_id)
+ .and_then(|entity| entity.downcast_ref())
.unwrap_or_else(|| double_lease_panic::<T>("read"))
}