Skip to content

cargo-check reissues warnings between builds for bin crates, but not for lib #3624

@crumblingstatue

Description

@crumblingstatue

$ cargo new --bin mybin && cd mybin && sed -i '1ifn foo(){}' src/main.rs && cargo check && cargo check:

    Created binary (application) `mybin` project
   Compiling mybin v0.1.0 (file:///tmp/mybin)
warning: function is never used: `foo`, #[warn(dead_code)] on by default
 --> src/main.rs:1:1
  |
1 | fn foo(){}
  | ^^^^^^^^^^

    Finished dev [unoptimized + debuginfo] target(s) in 0.47 secs
   Compiling mybin v0.1.0 (file:///tmp/mybin)
warning: function is never used: `foo`, #[warn(dead_code)] on by default
 --> src/main.rs:1:1
  |
1 | fn foo(){}
  | ^^^^^^^^^^

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

$ cargo new --lib mylib && cd mylib && sed -i '1ifn foo(){}' src/lib.rs && cargo check && cargo check:

     Created library `mylib` project
   Compiling mylib v0.1.0 (file:///tmp/mylib)
warning: function is never used: `foo`, #[warn(dead_code)] on by default
 --> src/lib.rs:1:1
  |
1 | fn foo(){}
  | ^^^^^^^^^^

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

Which one is the intended behavior for cargo-check? I personally believe it is useful to reissue warnings. The user might accidentally close or clear the terminal, and might want to get the warnings back without modifying the code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions