Skip to content

Commit 42912a3

Browse files
committed
No downcast for unhashable
1 parent 97623b4 commit 42912a3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

vm/src/types/slot.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,11 @@ impl<T> Hashable for T
499499
where
500500
T: Unhashable,
501501
{
502-
fn hash(_zelf: &PyRef<Self>, vm: &VirtualMachine) -> PyResult<PyHash> {
503-
Err(vm.new_type_error(format!("unhashable type: '{}'", _zelf.class().name())))
502+
fn slot_hash(zelf: &PyObjectRef, vm: &VirtualMachine) -> PyResult<PyHash> {
503+
Err(vm.new_type_error(format!("unhashable type: '{}'", zelf.class().name())))
504+
}
505+
fn hash(_zelf: &PyRef<Self>, _vm: &VirtualMachine) -> PyResult<PyHash> {
506+
unreachable!("slot_hash is implemented for unhashable types");
504507
}
505508
}
506509

0 commit comments

Comments
 (0)