📎 clippy is available as a rustup component


Before the change to clippy I ran cargo test to build (with clippy lints) and run my tests in one step. Likewise for cargo run, cargo build --release, etc. Maybe I’m missing the obvious, but I don’t see it documented–how do we do incorporate clippy lints into the desired build activity now?


I believe that the expected workflow is that cargo clippy replace cargo check in the edit-check cycle, and then you cargo test when that check cycle has reached a warningless testable state. You can include a clippy run in CI if enforcing it is desired.

Since clippy-as-cargo-command existed, clippy-as-rustc-plugin was not the recommended way of using clippy. Note that #[allow(clippy::lint)] is very close to working, so you won’t need to cfg your clippy-as-cargo-command attributes.


Thanks, CAD97.

If true, this is definitely a step backward in workflow, IMHO. As a TDD developer, I just want to run my tests, and see all errors, warnings, failures in a single step. I believe the edit/compile/debug cycle should be as simple, tight and fast as possible. Allowing clippy to simply augment the strictness of the compile cycle was important–surprised at this regression. :frowning: The two-step process also means that cargo test step generates dozens of unknown lint warnings.


There is a way, but it’s very experimental and we do not want to stabilize right now it by making it easy to use.

You can set RUSTC_WRAPPER=~/.rustup/toolchains/beta/bin/clippy-driver and that should theoretically allow you to run cargo test with all lints available. Note that this is buggy right now, but should mostly work.


@oli-obk No problem with this as a workaround while clippy stabilizes.

Unfortunately RUSTC_WRAPPER=~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/clippy-driver cargo test (my ~/.rustup/toolchains folder does not contain a beta folder) does not appear to change behavior–I do get a build, but with dozens of unknown lint warnings.

rustc --version => rustc 1.30.0-nightly (33b923fd4 2018-08-18)

cargo-clippy --version => 0.0.212

Any ideas?


I just checked the code. The hackery is strong with this one. You also need CLIPPY_TESTS=true set in your environment. Note that clippy will then also lint your dependencies, which should be fine since their lints get capped


Thanks, @oli-obk–that fixed it. Much appreciated!


I am getting that this morning:

$ rustup update
info: syncing channel updates for 'nightly-x86_64-apple-darwin'
info: latest update on 2018-08-29, rust version 1.30.0-nightly (7061b2775 2018-08-28)
warning: component 'clippy-preview' is not available anymore on target 'x86_64-apple-darwin'

So, is that intentional? Has clippy gone?


Also getting that error.

Edit: looks like the last toolchain that works is nightly-2018-08-02


No, it was ok yesterday.

$ rustup component list --toolchain nightly-2018-08-28 | grep clippy


I believe that issue is currently tracked here: https://github.com/rust-lang-nursery/rustup.rs/issues/1486