Mercurial > public > mercurial-scm > hg
comparison rust/hg-cpython/src/filepatterns.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 | 9609430d3625 |
children | 0247601869ba |
comparison
equal
deleted
inserted
replaced
42608:717686c5e461 | 42609:326fdce22fb2 |
---|---|
8 | 8 |
9 //! Bindings for the `hg::filepatterns` module provided by the | 9 //! Bindings for the `hg::filepatterns` module provided by the |
10 //! `hg-core` crate. From Python, this will be seen as `rustext.filepatterns` | 10 //! `hg-core` crate. From Python, this will be seen as `rustext.filepatterns` |
11 //! and can be used as replacement for the the pure `filepatterns` Python module. | 11 //! and can be used as replacement for the the pure `filepatterns` Python module. |
12 //! | 12 //! |
13 use crate::exceptions::{PatternError, PatternFileError}; | |
13 use cpython::{ | 14 use cpython::{ |
14 PyBytes, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, ToPyObject, | 15 PyBytes, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, ToPyObject, |
15 }; | 16 }; |
16 use exceptions::{PatternError, PatternFileError}; | |
17 use hg::{build_single_regex, read_pattern_file, LineNumber, PatternTuple}; | 17 use hg::{build_single_regex, read_pattern_file, LineNumber, PatternTuple}; |
18 | 18 |
19 /// Rust does not like functions with different return signatures. | 19 /// Rust does not like functions with different return signatures. |
20 /// The 3-tuple version is always returned by the hg-core function, | 20 /// The 3-tuple version is always returned by the hg-core function, |
21 /// the (potential) conversion is handled at this level since it is not likely | 21 /// the (potential) conversion is handled at this level since it is not likely |