Skip to content

Commit

Permalink
Improve panic report with reentrant SlotMap use (zed-industries#22667)
Browse files Browse the repository at this point in the history
`double_lease_panic` already does what we want, just extend it to the
indexing operation as well.

Release Notes:

- N/A
  • Loading branch information
cole-miller authored Jan 4, 2025
1 parent 8151dc7 commit de08e47
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/gpui/src/app/entity_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}

Expand Down

0 comments on commit de08e47

Please sign in to comment.