# HG changeset patch # User Yuya Nishihara <y...@tcha.org> # Date 1568534390 -32400 # Sun Sep 15 16:59:50 2019 +0900 # Node ID 953b7a8bc0052899b7fc96ff14feac09d55876be # Parent 9ac0e8fd9a78a68f5af74f739fbcec15d0434190 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<DirsMultisetKeysIterator> { - 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<DirstateMapKeysIterator> { - 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<DirstateMapItemsIterator> { - 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<DirstateMapKeysIterator> { - 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<CopyMapKeysIterator> { - 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<CopyMapItemsIterator> { - 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 @@ -304,14 +304,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() - } } }; } @@ -381,7 +373,8 @@ impl Drop for PyLeakedRef { /// data inner: PySharedRefCell<MyStruct>; /// /// def __iter__(&self) -> PyResult<MyTypeItemsIterator> { -/// 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, _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel