Skip to content

duplicate warnings #48640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matthiaskrgr opened this issue Mar 1, 2018 · 3 comments
Closed

duplicate warnings #48640

matthiaskrgr opened this issue Mar 1, 2018 · 3 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-cargo Relevant to the cargo team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Mar 1, 2018

For some reason cargo prints the same warnings on the same pieces of code multiple times.

git clone https://github.com/matthiaskrgr/cargo-cache
git checkout origin/warn_twice
cargo build

=>

   Compiling same-file v1.0.2
   Compiling walkdir v2.1.4
   Compiling cargo-cache v0.1.0 (file:///tmp/cargo-cache)
warning: unused import: `std::fs`
 --> src/lib.rs:4:5
  |
4 | use std::fs;
  |     ^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

warning: unused variable: `file2`
  --> src/lib.rs:20:6
   |
20 |     let file2 = WalkDir::new(format!("{}", dir.display()));
   |         ^^^^^ help: consider using `_file2` instead
   |
   = note: #[warn(unused_variables)] on by default

warning: unused import: `std::fs`
 --> src/lib.rs:4:5
  |
4 | use std::fs;
  |     ^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

warning: unused import: `lib::*`
 --> src/main.rs:6:5
  |
6 | use lib::*;
  |     ^^^^^^

warning: unused variable: `file2`
  --> src/lib.rs:20:6
   |
20 |     let file2 = WalkDir::new(format!("{}", dir.display()));
   |         ^^^^^ help: consider using `_file2` instead
   |
   = note: #[warn(unused_variables)] on by default

warning: function is never used: `cumulative_dir_size`
  --> src/lib.rs:11:1
   |
11 | pub fn cumulative_dir_size(dir: &PathBuf) -> u64 {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(dead_code)] on by default

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

meta:

rustc 1.26.0-nightly (0ff9872b2 2018-02-28)
cargo 0.26.0-nightly (1d6dfea44 2018-01-26)
@matthiaskrgr
Copy link
Member Author

Hmm, these seem to actually originate from separate calls of the compiler as --verbose shows:

   Compiling cargo-cache v0.1.0 (file:///tmp/cargo-cache)
     Running `rustc --crate-name cargo_cache src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=ff07950104b4651d -C extra-filename=-ff07950104b4651d --out-dir /tmp/cargo-cache/target/debug/deps -C incremental=/tmp/cargo-cache/target/debug/incremental -L dependency=/tmp/cargo-cache/target/debug/deps --extern walkdir=/tmp/cargo-cache/target/debug/deps/libwalkdir-5b91a5fbb37b0cac.rlib`
warning: unused import: `std::fs`
 --> src/lib.rs:4:5
  |
4 | use std::fs;
  |     ^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

warning: unused variable: `file2`
  --> src/lib.rs:20:6
   |
20 |     let file2 = WalkDir::new(format!("{}", dir.display()));
   |         ^^^^^ help: consider using `_file2` instead
   |
   = note: #[warn(unused_variables)] on by default

     Running `rustc --crate-name cargo_cache src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=e7b6b24911fa6523 -C extra-filename=-e7b6b24911fa6523 --out-dir /tmp/cargo-cache/target/debug/deps -C incremental=/tmp/cargo-cache/target/debug/incremental -L dependency=/tmp/cargo-cache/target/debug/deps --extern walkdir=/tmp/cargo-cache/target/debug/deps/libwalkdir-5b91a5fbb37b0cac.rlib --extern cargo_cache=/tmp/cargo-cache/target/debug/deps/libcargo_cache-ff07950104b4651d.rlib`
warning: unused import: `std::fs`
 --> src/lib.rs:4:5
  |
4 | use std::fs;
  |     ^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

warning: unused import: `lib::*`
 --> src/main.rs:6:5
  |
6 | use lib::*;
  |     ^^^^^^

warning: unused variable: `file2`
  --> src/lib.rs:20:6
   |
20 |     let file2 = WalkDir::new(format!("{}", dir.display()));
   |         ^^^^^ help: consider using `_file2` instead
   |
   = note: #[warn(unused_variables)] on by default

warning: function is never used: `cumulative_dir_size`
  --> src/lib.rs:11:1
   |
11 | pub fn cumulative_dir_size(dir: &PathBuf) -> u64 {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(dead_code)] on by default

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

@estebank
Copy link
Contributor

estebank commented Mar 1, 2018

I feel this is more of a cargo issue, I wonder if there could be an easy way for cargo to perform the deduplication on its end...

@pietroalbini pietroalbini added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-cargo Relevant to the cargo team, which will review and decide on the PR/issue. labels Mar 2, 2018
@Mark-Simulacrum
Copy link
Member

Closing as the compiler seems to be doing things correctly here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-cargo Relevant to the cargo team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants