# HG changeset patch # User Yuya Nishihara # Date 1570953495 -32400 # Node ID 8b355cbef16d661792237ba89e7c16e9e123423c # Parent 1ca3823aeefd2fb0e0af4b4e528b34c8fab4cb0f rust-cpython: mark capsule function as unsafe diff -r 1ca3823aeefd -r 8b355cbef16d rust/hg-cpython/src/dirstate.rs --- a/rust/hg-cpython/src/dirstate.rs Sun Oct 13 16:55:17 2019 +0900 +++ b/rust/hg-cpython/src/dirstate.rs Sun Oct 13 16:58:15 2019 +0900 @@ -36,7 +36,7 @@ /// would be a good idea in the near future to remove it entirely to allow /// for a pure Python tuple of the same effective structure to be used, /// rendering this type and the capsule below useless. -type MakeDirstateTupleFn = extern "C" fn( +type MakeDirstateTupleFn = unsafe extern "C" fn( state: c_char, mode: c_int, size: c_int, @@ -75,7 +75,11 @@ // because Into has a specific implementation while `as c_char` would // just do a naive enum cast. let state_code: u8 = state.into(); - Ok(make(state_code as c_char, mode, size, mtime)) + + unsafe { + let ptr = make(state_code as c_char, mode, size, mtime); + Ok(ptr) + } } pub fn extract_dirstate(py: Python, dmap: &PyDict) -> Result {