Mercurial > hg
changeset 43209:8b355cbef16d
rust-cpython: mark capsule function as unsafe
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 13 Oct 2019 16:58:15 +0900 |
parents | 1ca3823aeefd |
children | 3fec5244aff1 |
files | rust/hg-cpython/src/dirstate.rs |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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<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> {