From 89d57ffb29577c99f0f5187b76bff369f19c5886 Mon Sep 17 00:00:00 2001 From: Waleed Khan Date: Sat, 7 Dec 2024 23:02:11 +0200 Subject: [PATCH] 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`. --- Cargo.toml | 2 +- docs/contributing.md | 14 ++++++++++++-- rust-toolchain.toml | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/Cargo.toml b/Cargo.toml index a29e97cc1..e63a08291 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/docs/contributing.md b/docs/contributing.md index f0a052f54..eee956578 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -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 diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 000000000..876b6bdf3 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "1.76" +profile = "default" +components = ["rust-analyzer"]