Skip to content

cargo clippy and cargo check --features="cargo-clippy" have different behavior #2218

@carols10cents

Description

@carols10cents

Rust version: rustc 1.23.0-nightly (ee22861 2017-11-07)
Clippy version: 0.0.169

What happened

I have a project full repo here with this Cargo.toml:

[package]
name = "clippy-weirdness"
version = "0.1.0"
authors = ["Carol (Nichols || Goulding) <[email protected]>"]

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

[features]
cargo-clippy = ["clippy"]

and this src/lib.rs:

pub fn foo() {
    let line = String::from("hello");
    if !line.starts_with("y") {
        return;
    }
}

If I run CLIPPY=YESPLEASE cargo check --features "cargo-clippy", I don't get any warnings:

$ CLIPPY=YESPLEASE cargo check --features "cargo-clippy"
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs

However, if I run cargo clippy (and I have installed clippy using cargo install clippy --force --vers 0.0.169), I do get a warning:

$ cargo clippy
   Compiling clippy-weirdness v0.1.0 (file:///Users/carolnichols/rust/clippy-weirdness)
warning: single-character string constant used as pattern
 --> src/lib.rs:3:26
  |
3 |     if !line.starts_with("y") {
  |         -----------------^^^- help: try using a char instead: `line.starts_with('y')`
  |
  = note: #[warn(single_char_pattern)] on by default
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.169/index.html#single_char_pattern

    Finished dev [unoptimized + debuginfo] target(s) in 0.20 secs

What I expected

I expected cargo clippy and cargo check --features="cargo-clippy" to either both have the same warnings or both not to have any warnings :(

Even curiouser

The above behavior happens if i run cargo clean and then run cargo clippy FIRST. If I run cargo clean, then cargo check --features="cargo-clippy", and THEN cargo clippy, then cargo clippy also does not show any warnings!!

/cc @jtgeibel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions