Rust-clippy: Unable to compile my project with clippy

Created on 28 Apr 2018  路  7Comments  路  Source: rust-lang/rust-clippy

Preparation

Hi! I'm trying to compile my project with clippy, but it does not work. In order to make my project use clippy, I've

  • added clippy = { version = "*", optional = true } to my [dependencies] section of my Cargo.toml
  • added these lines to my lib.rs
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]
  • made sure that I'm using the latest nightly version of everything, for example
% rustc --version
rustc 1.27.0-nightly (686d0ae13 2018-04-27)

Problem

But when I'm trying to compile my project using

cargo +nightly build --features "clippy"

I'm these rather lengthy compile errors.

Is there anything I can do or am I using clippy wrong?

L-bug

Most helpful comment

I'm arguing that this should be the official way to install clippy. Realeasing crates.io versions is just a lot of effort for little gain and unnecessarily delays the time until ppl can use clippy on the bottleneck of us publishing. Master is usually fixed pretty quickly, the publish can take a few days, especially if a weekend comes in between

All 7 comments

Clippy appears to be broken on the latest nightly :(

+1 for compile failed馃槩

Thanks, the past few nightlies have broken clippy every time, unfortunately. Going to take a look at it now.

Nevermind, this should be fixed with the next clippy release. It's already fixed on master.
You can try installing clippy from master via:

cargo install clippy --git https://github.com/rust-lang-nursery/rust-clippy.git

I'm arguing that this should be the official way to install clippy. Realeasing crates.io versions is just a lot of effort for little gain and unnecessarily delays the time until ppl can use clippy on the bottleneck of us publishing. Master is usually fixed pretty quickly, the publish can take a few days, especially if a weekend comes in between

If you're building on CI, you should probably also pin the version of rust and clippy so that they don't change without choice from the repository.

For example, what I'm now running on Travis:

env:
matrix:
  include:
  # Clippy/Format
  - rust: nightly-2018-04-28
    env: CLIPPY_VERSION="1742229ebb7843a65c05ee495d8de5366fcc5567"
    install:
    - rustup component add rustfmt-preview || true
    - cargo install clippy --git https://github.com/rust-lang-nursery/rust-clippy.git --rev $CLIPPY_VERSION || true
    script:
    - cargo clippy --all-targets --tests -- -D clippy
    - cargo fmt -- --write-mode=diff

This keeps your build reproducible and outside changes from breaking your build.

Going to close this issue as Clippy is now available via rustup only.

Was this page helpful?
0 / 5 - 0 ratings