comparison rust/hg-cpython/src/cindex.rs @ 42609:326fdce22fb2

rust: switch hg-core and hg-cpython to rust 2018 edition Many interesting changes have happened in Rust since the Oxidation Plan was introduced, like the 2018 edition and procedural macros: - Opting in to the 2018 edition is a clear benefit in terms of future proofing, new (nice to have) syntactical sugar notwithstanding. It also has a new non-lexical, non-AST based borrow checker that has fewer bugs(!) and allows us to write correct code that in some cases would have been rejected by the old one. - Procedural macros allow us to use the PyO3 crate which maintainers have expressed the clear goal of compiling on stable, which would help in code maintainability compared to rust-cpython. In this patch are the following changes: - Removing most `extern crate` uses - Updating `use` clauses (`crate` keyword, nested `use`) - Removing `mod.rs` in favor of an aptly named module file Like discussed in the mailing list ( https://www.mercurial-scm.org/pipermail/mercurial-devel/2019-July/132316.html ), until Rust integration in Mercurial is considered to be out of the experimental phase, the maximum version of Rust allowed is whatever the latest version Debian packages. Differential Revision: https://phab.mercurial-scm.org/D6597
author Raphaël Gomès <rgomes@octobus.net>
date Tue, 02 Jul 2019 17:15:03 +0200
parents ab0d762d89ef
children 0246bbe1045d
comparison
equal deleted inserted replaced
42608:717686c5e461 42609:326fdce22fb2
8 //! Bindings to use the Index defined by the parsers C extension 8 //! Bindings to use the Index defined by the parsers C extension
9 //! 9 //!
10 //! Ideally, we should use an Index entirely implemented in Rust, 10 //! Ideally, we should use an Index entirely implemented in Rust,
11 //! but this will take some time to get there. 11 //! but this will take some time to get there.
12 #[cfg(feature = "python27")] 12 #[cfg(feature = "python27")]
13 extern crate python27_sys as python_sys; 13 use python27_sys as python_sys;
14 #[cfg(feature = "python3")] 14 #[cfg(feature = "python3")]
15 extern crate python3_sys as python_sys; 15 use python3_sys as python_sys;
16 16
17 use self::python_sys::PyCapsule_Import;
18 use cpython::{PyClone, PyErr, PyObject, PyResult, Python}; 17 use cpython::{PyClone, PyErr, PyObject, PyResult, Python};
19 use hg::{Graph, GraphError, Revision, WORKING_DIRECTORY_REVISION}; 18 use hg::{Graph, GraphError, Revision, WORKING_DIRECTORY_REVISION};
20 use libc::c_int; 19 use libc::c_int;
20 use python_sys::PyCapsule_Import;
21 use std::ffi::CStr; 21 use std::ffi::CStr;
22 use std::mem::transmute; 22 use std::mem::transmute;
23 23
24 type IndexParentsFn = unsafe extern "C" fn( 24 type IndexParentsFn = unsafe extern "C" fn(
25 index: *mut python_sys::PyObject, 25 index: *mut python_sys::PyObject,