Mercurial > hg
annotate rust/README.rst @ 50936:6408777c8fa4
branching: merge stable into default
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Wed, 06 Sep 2023 18:12:27 +0200 |
parents | b88e9c707c95 |
children | 541292a02e09 |
rev | line source |
---|---|
35569
964212780daf
rust: implementation of `hg`
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 =================== |
964212780daf
rust: implementation of `hg`
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 Mercurial Rust Code |
964212780daf
rust: implementation of `hg`
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 =================== |
964212780daf
rust: implementation of `hg`
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 |
964212780daf
rust: implementation of `hg`
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 This directory contains various Rust code for the Mercurial project. |
44115
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
6 Rust is not required to use (or build) Mercurial, but using it |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
7 improves performance in some areas. |
35569
964212780daf
rust: implementation of `hg`
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 |
48535
799fdf4cca80
docs: update Rust readme with a mention of `rhg`
Raphaël Gomès <rgomes@octobus.net>
parents:
48296
diff
changeset
|
9 There are currently four independent Rust projects: |
50420
5d20fc23e265
rust-readme: rst fixes
Georges Racinet <georges.racinet@octobus.net>
parents:
49629
diff
changeset
|
10 |
48535
799fdf4cca80
docs: update Rust readme with a mention of `rhg`
Raphaël Gomès <rgomes@octobus.net>
parents:
48296
diff
changeset
|
11 - chg. An implementation of chg, in Rust instead of C. |
799fdf4cca80
docs: update Rust readme with a mention of `rhg`
Raphaël Gomès <rgomes@octobus.net>
parents:
48296
diff
changeset
|
12 - hgcli. A project that provides a (mostly) self-contained "hg" binary, |
44903
69d3ce00df99
rust: update the mention of hgcli in rust/README.rst
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44885
diff
changeset
|
13 for ease of deployment and a bit of speed, using PyOxidizer. See |
50420
5d20fc23e265
rust-readme: rst fixes
Georges Racinet <georges.racinet@octobus.net>
parents:
49629
diff
changeset
|
14 ``hgcli/README.md``. |
44549
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
15 - hg-core (and hg-cpython): implementation of some |
48535
799fdf4cca80
docs: update Rust readme with a mention of `rhg`
Raphaël Gomès <rgomes@octobus.net>
parents:
48296
diff
changeset
|
16 functionality of mercurial in Rust, e.g. ancestry computations in |
44549
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
17 revision graphs, status or pull discovery. The top-level ``Cargo.toml`` file |
44115
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
18 defines a workspace containing these crates. |
48535
799fdf4cca80
docs: update Rust readme with a mention of `rhg`
Raphaël Gomès <rgomes@octobus.net>
parents:
48296
diff
changeset
|
19 - rhg: a pure Rust implementation of Mercurial, with a fallback mechanism for |
50420
5d20fc23e265
rust-readme: rst fixes
Georges Racinet <georges.racinet@octobus.net>
parents:
49629
diff
changeset
|
20 unsupported invocations. It reuses the logic ``hg-core`` but |
5d20fc23e265
rust-readme: rst fixes
Georges Racinet <georges.racinet@octobus.net>
parents:
49629
diff
changeset
|
21 completely forgoes interaction with Python. See |
5d20fc23e265
rust-readme: rst fixes
Georges Racinet <georges.racinet@octobus.net>
parents:
49629
diff
changeset
|
22 ``rust/rhg/README.md`` for more details. |
44115
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
23 |
44549
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
24 Using Rust code |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
25 =============== |
35569
964212780daf
rust: implementation of `hg`
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
26 |
44115
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
27 Local use (you need to clean previous build artifacts if you have |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
28 built without rust previously):: |
35569
964212780daf
rust: implementation of `hg`
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
29 |
44549
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
30 $ make PURE=--rust local # to use ./hg |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
31 $ ./tests/run-tests.py --rust # to run all tests |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
32 $ ./hg debuginstall | grep -i rust # to validate rust is in use |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
33 checking Rust extensions (installed) |
44115
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
34 checking module policy (rust+c-allow) |
44549
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
35 |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
36 If the environment variable ``HGWITHRUSTEXT=cpython`` is set, the Rust |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
37 extension will be used by default unless ``--no-rust``. |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
38 |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
39 One day we may use this environment variable to switch to new experimental |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
40 binding crates like a hypothetical ``HGWITHRUSTEXT=hpy``. |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
41 |
45609
e604a3c03ab9
rust: introduce `dirstate-tree` cargo feature
Raphaël Gomès <rgomes@octobus.net>
parents:
44904
diff
changeset
|
42 Special features |
e604a3c03ab9
rust: introduce `dirstate-tree` cargo feature
Raphaël Gomès <rgomes@octobus.net>
parents:
44904
diff
changeset
|
43 ================ |
e604a3c03ab9
rust: introduce `dirstate-tree` cargo feature
Raphaël Gomès <rgomes@octobus.net>
parents:
44904
diff
changeset
|
44 |
48842
649ff7f86f96
rust: enable Python 3 support unconditionally
Simon Sapin <simon.sapin@octobus.net>
parents:
48535
diff
changeset
|
45 In the future, compile-time opt-ins may be added |
50420
5d20fc23e265
rust-readme: rst fixes
Georges Racinet <georges.racinet@octobus.net>
parents:
49629
diff
changeset
|
46 to the ``features`` section in ``hg-cpython/Cargo.toml``. |
45609
e604a3c03ab9
rust: introduce `dirstate-tree` cargo feature
Raphaël Gomès <rgomes@octobus.net>
parents:
44904
diff
changeset
|
47 |
50420
5d20fc23e265
rust-readme: rst fixes
Georges Racinet <georges.racinet@octobus.net>
parents:
49629
diff
changeset
|
48 To use features from the Makefile, use the ``HG_RUST_FEATURES`` environment |
5d20fc23e265
rust-readme: rst fixes
Georges Racinet <georges.racinet@octobus.net>
parents:
49629
diff
changeset
|
49 variable: for instance ``HG_RUST_FEATURES="some-feature other-feature"``. |
45609
e604a3c03ab9
rust: introduce `dirstate-tree` cargo feature
Raphaël Gomès <rgomes@octobus.net>
parents:
44904
diff
changeset
|
50 |
44904
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
51 Profiling |
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
52 ========= |
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
53 |
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
54 Setting the environment variable ``RUST_LOG=trace`` will make hg print |
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
55 a few high level rust-related performance numbers. It can also |
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
56 indicate why the rust code cannot be used (say, using lookarounds in |
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
57 hgignore). |
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
58 |
46140
ec14c37958ec
rust: document how to enable debug information in optimized builds
Simon Sapin <simon.sapin@octobus.net>
parents:
45614
diff
changeset
|
59 Creating a ``.cargo/config`` file with the following content enables |
ec14c37958ec
rust: document how to enable debug information in optimized builds
Simon Sapin <simon.sapin@octobus.net>
parents:
45614
diff
changeset
|
60 debug information in optimized builds. This make profiles more informative |
ec14c37958ec
rust: document how to enable debug information in optimized builds
Simon Sapin <simon.sapin@octobus.net>
parents:
45614
diff
changeset
|
61 with source file name and line number for Rust stack frames and |
50420
5d20fc23e265
rust-readme: rst fixes
Georges Racinet <georges.racinet@octobus.net>
parents:
49629
diff
changeset
|
62 (in some cases) stack frames for Rust functions that have been inlined:: |
46140
ec14c37958ec
rust: document how to enable debug information in optimized builds
Simon Sapin <simon.sapin@octobus.net>
parents:
45614
diff
changeset
|
63 |
ec14c37958ec
rust: document how to enable debug information in optimized builds
Simon Sapin <simon.sapin@octobus.net>
parents:
45614
diff
changeset
|
64 [profile.release] |
ec14c37958ec
rust: document how to enable debug information in optimized builds
Simon Sapin <simon.sapin@octobus.net>
parents:
45614
diff
changeset
|
65 debug = true |
ec14c37958ec
rust: document how to enable debug information in optimized builds
Simon Sapin <simon.sapin@octobus.net>
parents:
45614
diff
changeset
|
66 |
44904
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
67 ``py-spy`` (https://github.com/benfred/py-spy) can be used to |
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
68 construct a single profile with rust functions and python functions |
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
69 (as opposed to ``hg --profile``, which attributes time spent in rust |
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
70 to some unlucky python code running shortly after the rust code, and |
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
71 as opposed to tools for native code like ``perf``, which attribute |
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
72 time to the python interpreter instead of python functions). |
7ca1d635e4a6
rust: add a pointer for profiling to the README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44903
diff
changeset
|
73 |
50420
5d20fc23e265
rust-readme: rst fixes
Georges Racinet <georges.racinet@octobus.net>
parents:
49629
diff
changeset
|
74 Example usage:: |
46140
ec14c37958ec
rust: document how to enable debug information in optimized builds
Simon Sapin <simon.sapin@octobus.net>
parents:
45614
diff
changeset
|
75 |
ec14c37958ec
rust: document how to enable debug information in optimized builds
Simon Sapin <simon.sapin@octobus.net>
parents:
45614
diff
changeset
|
76 $ make PURE=--rust local # Don't forget to recompile after a code change |
ec14c37958ec
rust: document how to enable debug information in optimized builds
Simon Sapin <simon.sapin@octobus.net>
parents:
45614
diff
changeset
|
77 $ py-spy record --native --output /tmp/profile.svg -- ./hg ... |
ec14c37958ec
rust: document how to enable debug information in optimized builds
Simon Sapin <simon.sapin@octobus.net>
parents:
45614
diff
changeset
|
78 |
44549
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
79 Developing Rust |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
80 =============== |
35569
964212780daf
rust: implementation of `hg`
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
81 |
50423
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
82 Minimum Supported Rust Version |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
83 ------------------------------ |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
84 |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
85 The minimum supported rust version (MSRV) is specified in the `Clippy`_ |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
86 configuration file at ``rust/clippy.toml``. It is set to be ``1.61.0`` as of |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
87 this writing, but keep in mind that the authoritative value is the one |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
88 from the configuration file. |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
89 |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
90 We bump it from time to time, with the general rule being that our |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
91 MSRV should not be greater that the version of the Rust toolchain |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
92 shipping with Debian testing, so that the Rust enhanced Mercurial can |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
93 be eventually packaged in Debian. |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
94 |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
95 To ensure that you are not depending on features introduced in later |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
96 versions, you can issue ``rustup override set x.y.z`` at the root of |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
97 the repository. |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
98 |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
99 Build and development |
b88e9c707c95
rust: configure MSRV in Clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50422
diff
changeset
|
100 --------------------- |
44549
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
101 |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
102 Go to the ``hg-cpython`` folder:: |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
103 |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
104 $ cd rust/hg-cpython |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
105 |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
106 Or, only the ``hg-core`` folder. Be careful not to break compatibility:: |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
107 |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
108 $ cd rust/hg-core |
44115
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
109 |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
110 Simply run:: |
35569
964212780daf
rust: implementation of `hg`
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
111 |
964212780daf
rust: implementation of `hg`
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
112 $ cargo build --release |
44115
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
113 |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
114 It is possible to build without ``--release``, but it is not |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
115 recommended if performance is of any interest: there can be an order |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
116 of magnitude of degradation when removing ``--release``. |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
117 |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
118 For faster builds, you may want to skip code generation:: |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
119 |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
120 $ cargo check |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
121 |
44549
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
122 For even faster typing:: |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
123 |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
124 $ cargo c |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
125 |
44115
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
126 You can run only the rust-specific tests (as opposed to tests of |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
127 mercurial as a whole) with:: |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
128 |
e1b8b4e4f496
rust: add a README
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
44114
diff
changeset
|
129 $ cargo test --all |
44549
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
130 |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
131 Formatting the code |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
132 ------------------- |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
133 |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
134 We use ``rustfmt`` to keep the code formatted at all times. For now, we are |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
135 using the nightly version because it has been stable enough and provides |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
136 comment folding. |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
137 |
50422
498155b0ba41
rust-readme: mentioned that format check is enforced by CI
Georges Racinet <georges.racinet@octobus.net>
parents:
50421
diff
changeset
|
138 Our CI enforces that the code does not need reformatting. Before |
498155b0ba41
rust-readme: mentioned that format check is enforced by CI
Georges Racinet <georges.racinet@octobus.net>
parents:
50421
diff
changeset
|
139 submitting your changes, please format the entire Rust workspace by running:: |
498155b0ba41
rust-readme: mentioned that format check is enforced by CI
Georges Racinet <georges.racinet@octobus.net>
parents:
50421
diff
changeset
|
140 |
44549
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
141 |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
142 $ cargo +nightly fmt |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
143 |
47f8c741df0f
rust: update the README with more up-to-date and thorough information
Raphaël Gomès <rgomes@octobus.net>
parents:
44115
diff
changeset
|
144 This requires you to have the nightly toolchain installed. |
50421
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
145 |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
146 Linting: code sanity |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
147 -------------------- |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
148 |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
149 We're using `Clippy`_, the standard code diagnosis tool of the Rust |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
150 community. |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
151 |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
152 Our CI enforces that the code is free of Clippy warnings, so you might |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
153 want to run it on your side before submitting your changes. Simply do:: |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
154 |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
155 % cargo clippy |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
156 |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
157 from the top of the Rust workspace. Clippy is part of the default |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
158 ``rustup`` install, so it should work right away. In case it would |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
159 not, you can install it with ``rustup component add``. |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
160 |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
161 |
53f039ed6f20
rust-readme: mentioning clippy
Georges Racinet <georges.racinet@octobus.net>
parents:
50420
diff
changeset
|
162 .. _Clippy: https://doc.rust-lang.org/stable/clippy/ |