From dc842556c97ef770c65538956005015b7876e459 Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Wed, 14 May 2025 14:15:25 -0700 Subject: [PATCH] Document how to use `rust-toolchain.toml` to avoid breaking changes in CI I've had Clippy suddenly start to fail in GitHub Actions for me in multiple ways. If Clippy was still a crate, I'd just pin it as a dependency and run https://crates.io/crates/cargo-run-bin/1.7.2 However, that's unfortunately not possible and I found it far from obvious what to do instead. My understanding is that pinning it using `rust-toolchain.toml` like this is the "correct" way to avoid breaking changes in CI. This took me some time and research (and personal help from a Rust expert) to figure out and I'd like to save others the trouble by documenting it. --- book/src/installation.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/book/src/installation.md b/book/src/installation.md index d54fff9deba1..2b3f9cacd106 100644 --- a/book/src/installation.md +++ b/book/src/installation.md @@ -15,6 +15,22 @@ If Clippy was not installed for a toolchain, it can be installed with $ rustup component add clippy [--toolchain=] ``` +### Use a specific version of Clippy + +Clippy may introduce new warnings and errors between associated Rust versions. +This may be desirable if you want to learn about newly detectable issues in your +codebase over time, but it can cause [continuous integration](./continuous_integration/index.md) +to fail even if you haven't touched your Rust code. If you'd like to keep Clippy's +behaviour stable for your project, use +[`rust-toolchain.toml`](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) +to pin your entire Rust toolchain. For example: + +```toml +[toolchain] +channel = "1.83.0" +components = ["clippy"] +``` + ## From Source Take a look at the [Basics] chapter in the Clippy developer guide to find step-by-step