Skip to content

Commit de08e47

Browse files
authored
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
1 parent 8151dc7 commit de08e47

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

crates/gpui/src/app/entity_map.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ impl EntityMap {
117117

118118
pub fn read<T: 'static>(&self, model: &Model<T>) -> &T {
119119
self.assert_valid_context(model);
120-
self.entities[model.entity_id]
121-
.downcast_ref()
120+
self.entities
121+
.get(model.entity_id)
122+
.and_then(|entity| entity.downcast_ref())
122123
.unwrap_or_else(|| double_lease_panic::<T>("read"))
123124
}
124125

0 commit comments

Comments
 (0)