build: add rust-toolchain.toml

Follow-up from discussion at https://discord.com/channels/968932220549103686/1288926971719323762

I don't think we achieved consensus in that thread. We could use `stable` or `nightly` here instead if we prefer. Note that user `rustup` overrides are still respected in the presence of a `rust-toolchain.toml`.
This commit is contained in:
Waleed Khan 2024-12-07 23:02:11 +02:00
parent db5e7dd70c
commit 89d57ffb29
3 changed files with 17 additions and 3 deletions

View file

@ -7,7 +7,7 @@ members = ["cli", "lib", "lib/gen-protos", "lib/proc-macros", "lib/testutils"]
[workspace.package]
version = "0.24.0"
license = "Apache-2.0"
rust-version = "1.76" # NOTE: remember to update CI, contributing.md, changelog.md, install-and-setup.md, and flake.nix
rust-version = "1.76" # NOTE: remember to update CI, rust-toolchain.toml, contributing.md, changelog.md, install-and-setup.md, and flake.nix
edition = "2021"
readme = "README.md"
homepage = "https://github.com/martinvonz/jj"

View file

@ -133,7 +133,6 @@ recommended steps.
One-time setup:
rustup toolchain add nightly # wanted for 'rustfmt'
rustup toolchain add 1.76 # also specified in Cargo.toml
cargo install cargo-insta
cargo install cargo-watch
cargo install cargo-nextest
@ -142,7 +141,7 @@ During development (adapt according to your preference):
cargo watch --ignore '.jj/**' -s \
'cargo clippy --workspace --all-targets \
&& cargo +1.76 check --workspace --all-targets'
&& cargo check --workspace --all-targets'
cargo +nightly fmt # Occasionally
cargo nextest run --workspace # Occasionally
cargo insta test --workspace --test-runner nextest # Occasionally
@ -189,6 +188,17 @@ These are listed roughly in order of decreasing importance.
On Linux, you may be able to speed up `nextest` even further by using
the `mold` linker, as explained below.
### Using an alternative Rust compiler version
To use a different version of the Rust compiler/toolchain for development, you
can run:
rustup override set 1.80 # or any other version
Or manually set it in individual `cargo` commands:
cargo +1.80 clippy --workspace --all-targets # or any other version
### Using `mold` for faster tests on Linux
On a machine with a multi-core CPU, one way to speed up

4
rust-toolchain.toml Normal file
View file

@ -0,0 +1,4 @@
[toolchain]
channel = "1.76"
profile = "default"
components = ["rust-analyzer"]