diff --git a/vm/src/types/slot.rs b/vm/src/types/slot.rs index 4ce18e15d4..ea5a1449c3 100644 --- a/vm/src/types/slot.rs +++ b/vm/src/types/slot.rs @@ -486,8 +486,8 @@ pub trait Hashable: PyValue { #[inline] #[pymethod] - fn __hash__(zelf: PyRef, vm: &VirtualMachine) -> PyResult { - Self::hash(&zelf, vm) + fn __hash__(zelf: PyObjectRef, vm: &VirtualMachine) -> PyResult { + Self::slot_hash(&zelf, vm) } fn hash(zelf: &PyRef, vm: &VirtualMachine) -> PyResult; @@ -499,8 +499,11 @@ impl Hashable for T where T: Unhashable, { - fn hash(_zelf: &PyRef, vm: &VirtualMachine) -> PyResult { - Err(vm.new_type_error(format!("unhashable type: '{}'", _zelf.class().name()))) + fn slot_hash(zelf: &PyObjectRef, vm: &VirtualMachine) -> PyResult { + Err(vm.new_type_error(format!("unhashable type: '{}'", zelf.class().name()))) + } + fn hash(_zelf: &PyRef, _vm: &VirtualMachine) -> PyResult { + unreachable!("slot_hash is implemented for unhashable types"); } }