Skip to content

cargo check recompiles dependencies when checking lib and bin separately #3421

Closed
@crumblingstatue

Description

@crumblingstatue

For this project:

Cargo.toml:

[package]
name = "foo"
version = "0.1.0"
authors = ["Mika Attila <radiantstatue@gmail.com>"]

[dependencies]
rand = "*"

src/lib.rs:

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
    }
}

src/bin/bar.rs: fn main() {}

cargo check does this:

$ cargo check --lib
   Compiling libc v0.2.18
   Compiling rand v0.3.15
   Compiling foo v0.1.0 (file:///tmp/foo)
    Finished debug [unoptimized + debuginfo] target(s) in 4.87 secs
$ cargo check --bin bar
   Compiling libc v0.2.18
   Compiling rand v0.3.15
   Compiling foo v0.1.0 (file:///tmp/foo)
warning: function is never used: `main`, #[warn(dead_code)] on by default
 --> src/bin/bar.rs:1:1
  |
1 | fn main() {}
  | ^^^^^^^^^^^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions