šŸ“Ž 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.

1 Like

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.

1 Like

@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

1 Like

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?

1 Like

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
clippy-preview-x86_64-apple-darwin

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

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.