# HG changeset patch # User Yuya Nishihara # Date 2019-09-15 07:59:50 # Node ID 7d6758f2d50c1d54d6266eb2f36d0724152e53c3 # Parent 1b2200bd06b6e34cc1d63e83e8fad46cba739ccd rust-cpython: drop self.leak_immutable() in favor of PySharedRef wrapper diff --git a/rust/hg-cpython/src/dirstate/dirs_multiset.rs b/rust/hg-cpython/src/dirstate/dirs_multiset.rs --- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs +++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs @@ -92,7 +92,8 @@ py_class!(pub class Dirs |py| { }) } def __iter__(&self) -> PyResult { - let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; + let (leak_handle, leaked_ref) = + unsafe { self.inner_shared(py).leak_immutable()? }; DirsMultisetKeysIterator::from_inner( py, leak_handle, diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs b/rust/hg-cpython/src/dirstate/dirstate_map.rs --- a/rust/hg-cpython/src/dirstate/dirstate_map.rs +++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs @@ -319,7 +319,8 @@ py_class!(pub class DirstateMap |py| { } def keys(&self) -> PyResult { - let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; + let (leak_handle, leaked_ref) = + unsafe { self.inner_shared(py).leak_immutable()? }; DirstateMapKeysIterator::from_inner( py, leak_handle, @@ -328,7 +329,8 @@ py_class!(pub class DirstateMap |py| { } def items(&self) -> PyResult { - let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; + let (leak_handle, leaked_ref) = + unsafe { self.inner_shared(py).leak_immutable()? }; DirstateMapItemsIterator::from_inner( py, leak_handle, @@ -337,7 +339,8 @@ py_class!(pub class DirstateMap |py| { } def __iter__(&self) -> PyResult { - let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; + let (leak_handle, leaked_ref) = + unsafe { self.inner_shared(py).leak_immutable()? }; DirstateMapKeysIterator::from_inner( py, leak_handle, @@ -454,7 +457,8 @@ py_class!(pub class DirstateMap |py| { } def copymapiter(&self) -> PyResult { - let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; + let (leak_handle, leaked_ref) = + unsafe { self.inner_shared(py).leak_immutable()? }; CopyMapKeysIterator::from_inner( py, leak_handle, @@ -463,7 +467,8 @@ py_class!(pub class DirstateMap |py| { } def copymapitemsiter(&self) -> PyResult { - let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; + let (leak_handle, leaked_ref) = + unsafe { self.inner_shared(py).leak_immutable()? }; CopyMapItemsIterator::from_inner( py, leak_handle, diff --git a/rust/hg-cpython/src/ref_sharing.rs b/rust/hg-cpython/src/ref_sharing.rs --- a/rust/hg-cpython/src/ref_sharing.rs +++ b/rust/hg-cpython/src/ref_sharing.rs @@ -319,14 +319,6 @@ macro_rules! py_shared_ref { { self.$shared_accessor(py).borrow_mut() } - - // TODO: remove this function in favor of $shared_accessor(py) - unsafe fn leak_immutable<'a>( - &'a self, - py: Python<'a>, - ) -> PyResult<(PyLeakedRef, &'static $inner_struct)> { - self.$shared_accessor(py).leak_immutable() - } } }; } @@ -396,7 +388,8 @@ impl Drop for PyLeakedRef { /// data inner: PySharedRefCell; /// /// def __iter__(&self) -> PyResult { -/// let (leak_handle, leaked_ref) = unsafe { self.leak_immutable(py)? }; +/// let (leak_handle, leaked_ref) = +/// unsafe { self.inner_shared(py).leak_immutable()? }; /// MyTypeItemsIterator::from_inner( /// py, /// leak_handle,