From de08e47e5bc94afdee81fd99f838100fc577a98c Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Sat, 4 Jan 2025 15:37:40 -0500 Subject: [PATCH] Improve panic report with reentrant SlotMap use (#22667) `double_lease_panic` already does what we want, just extend it to the indexing operation as well. Release Notes: - N/A --- crates/gpui/src/app/entity_map.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/app/entity_map.rs b/crates/gpui/src/app/entity_map.rs index 07aa466295..8bf9c67269 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(&self, model: &Model) -> &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::("read")) }