Cannot compile my project due to dependence on clippy

I am using stable version of rustc 1.15.1. I have a project that I have been working on for quite a while, and it compiled fine before (always with a stable rust compiler). Somehow I cleared Cargo.lock for my project today. So when I run 'cargo build', it tries to update registry, and recompiles all the dependencies. I got an error like this:

error[E0554]: #[feature] may not be used on the stable release channel
 --> /Users/qinsoon/.cargo/registry/src/github.com-1ecc6299db9ec823/clippy_lints-0.0.112/src/lib.rs:3:1
  |
3 | #![feature(box_syntax)]
  | ^^^^^^^^^^^^^^^^^^^^^^^

I do not have any dependency on clippy directly in my project. However, I suspect some crates I use may depend on clippy. I tried to use cargo list to show all the dependencies of my project (including transitive dependencies), and I didn't find clippy there as well.

As building my project always tries to compile clippy v0.0.112 (v0.0.114 is the lastest version), I am pretty sure somehow my project depends on clippy. (I have tried to delete and reinstall cargo, including its cache and registry for dependencies. I have pulled my project from repo, and build freshly -- still failing)

I am wondering:

  1. since compiling clippy should always require a nightly compiler, how is it possible that my project can compile before? The possible answer is that
  2. do I have to switch to beta/nightly compiler for dependency on clippy?

Thanks a lot.

What is the contents of your Cargo.toml and Cargo.lock?

I have a dependency on doubly, which depends on clippy. I think this is the reason.

This is from Cargo.lock

[[package]]
name = "doubly"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "clippy 0.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "clippy"
version = "0.0.112"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "cargo_metadata 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
 "clippy_lints 0.0.112 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "clippy_lints"
version = "0.0.112"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
 "matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
 "quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
 "regex-syntax 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
 "toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
 "unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]

Ah, yes, this is actually a bug in the doubly crate.

Per the Good practices for Writing Rust Libraries page, you'll see that a crate author should specify a dependency on clippy like this:

[dependencies]
clippy = {version = "0.0.21", optional = true}

[features]
default = []
dev = ["clippy"]

You should consider filing an issue on the doubly project's GitHub page and ask them to please consider making clippy optional per the page I linked above.

2 Likes

Thank you very much. This helps a lot. I'll file an issue for doubly.