# HG changeset patch # User Yuya Nishihara <y...@tcha.org> # Date 1570953495 -32400 # Sun Oct 13 16:58:15 2019 +0900 # Node ID 46a5d47e23a43c12115de6707fe727e52a8a5f74 # Parent 083f70b7b5899755bb28ce16d6fc45eee46e84e4 rust-cpython: mark capsule function as unsafe
diff --git a/rust/hg-cpython/src/dirstate.rs b/rust/hg-cpython/src/dirstate.rs --- a/rust/hg-cpython/src/dirstate.rs +++ b/rust/hg-cpython/src/dirstate.rs @@ -36,7 +36,7 @@ use std::mem::transmute; /// 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 @@ pub fn make_dirstate_tuple( // because Into<u8> 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<StateMap, PyErr> { _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel