rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.87k stars 12.67k forks source link

False positives for dev-dependencies with unused_crate_dependencies lint #72686

Closed svartalf closed 4 years ago

svartalf commented 4 years ago

unused_crate_dependencies lint introduced in https://github.com/rust-lang/rust/pull/72342 causes false positives for [dev-dependencies].

To reproduce:

$ cargo new --lib unused
     Created library `unused` package

$ cd unused

$ echo '#![deny(unused)]' > src/lib.rs

$ echo '[dev-dependencies]
version-sync = "0.9"' >> Cargo.toml

$ mkdir tests

$ echo '#[test]
fn test_html_root_url() {
    version_sync::assert_html_root_url_updated!("src/lib.rs");
}' > tests/version.rs

I expected to execute cargo +nightly test correctly.

Instead, this happened:

$ cargo +nightly test
   Compiling unused v0.1.0 (/tmp/unused)
error: external crate `version_sync` unused in `unused`: remove the dependency or add `use version_sync as _;`
  |
note: the lint level is defined here
 --> src/lib.rs:1:9
  |
1 | #![deny(unused)]
  |         ^^^^^^
  = note: `#[deny(unused_crate_dependencies)]` implied by `#[deny(unused)]`

error: aborting due to previous error

error: could not compile `unused`.

To learn more, run the command again with --verbose.

I expect dev-dependencies to be ignored by this lint, because they are in fact used in tests/ modules. "remove the dependency or add use version_sync as _;" help message is also unhelpful, because it will cause unresolved imports for cargo build and similar commands.

Meta

rustc --version --verbose:

rustup run nightly rustc --version --verbose
rustc 1.45.0-nightly (664fcd3f0 2020-05-27)
binary: rustc
commit-hash: 664fcd3f046e2a6824602da0fad81e3e2bb0d409
commit-date: 2020-05-27
host: x86_64-unknown-linux-gnu
release: 1.45.0-nightly
LLVM version: 10.0
Full verbose build log

``` $ cargo +nightly test --verbose Compiling memchr v2.3.3 Compiling version_check v0.9.2 Compiling proc-macro2 v1.0.17 Compiling unicode-xid v0.2.0 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name build_script_build /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-2.3.3/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' --cfg 'feature="use_std"' -C metadata=c7f795a0c7e9979b -C extra-filename=-c7f795a0c7e9979b --out-dir /tmp/unused/target/debug/build/memchr-c7f795a0c7e9979b -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name version_check /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/version_check-0.9.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=82cc027e9ceba674 -C extra-filename=-82cc027e9ceba674 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name build_script_build --edition=2018 /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.17/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="proc-macro"' --cfg 'feature="span-locations"' -C metadata=e23547cdc7db7e81 -C extra-filename=-e23547cdc7db7e81 --out-dir /tmp/unused/target/debug/build/proc-macro2-e23547cdc7db7e81 -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name unicode_xid /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/unicode-xid-0.2.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' -C metadata=78174849e41719c0 -C extra-filename=-78174849e41719c0 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Compiling serde v1.0.110 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name build_script_build /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.110/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=0cc309bc7ba935eb -C extra-filename=-0cc309bc7ba935eb --out-dir /tmp/unused/target/debug/build/serde-0cc309bc7ba935eb -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Compiling smallvec v1.4.0 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name smallvec --edition=2018 /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-1.4.0/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=84f514d64495f7fb -C extra-filename=-84f514d64495f7fb --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Compiling bitflags v1.2.1 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name build_script_build /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/bitflags-1.2.1/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' -C metadata=6de1ffcc56ec72ff -C extra-filename=-6de1ffcc56ec72ff --out-dir /tmp/unused/target/debug/build/bitflags-6de1ffcc56ec72ff -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Compiling matches v0.1.8 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name matches /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/matches-0.1.8/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=346dc0eba02e242b -C extra-filename=-346dc0eba02e242b --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Compiling lazy_static v1.4.0 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name lazy_static /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=5fa5bc44b10bdd8d -C extra-filename=-5fa5bc44b10bdd8d --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Compiling syn v1.0.27 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name build_script_build --edition=2018 /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.27/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="clone-impls"' --cfg 'feature="default"' --cfg 'feature="derive"' --cfg 'feature="full"' --cfg 'feature="parsing"' --cfg 'feature="printing"' --cfg 'feature="proc-macro"' --cfg 'feature="quote"' -C metadata=71a7901023ddb067 -C extra-filename=-71a7901023ddb067 --out-dir /tmp/unused/target/debug/build/syn-71a7901023ddb067 -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Compiling pulldown-cmark v0.7.1 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name build_script_build --edition=2018 /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/pulldown-cmark-0.7.1/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=205bcfdd39cbd395 -C extra-filename=-205bcfdd39cbd395 --out-dir /tmp/unused/target/debug/build/pulldown-cmark-205bcfdd39cbd395 -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Compiling either v1.5.3 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name either /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/either-1.5.3/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=498735f8abeeff51 -C extra-filename=-498735f8abeeff51 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Compiling regex-syntax v0.6.17 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name regex_syntax /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-syntax-0.6.17/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="unicode"' --cfg 'feature="unicode-age"' --cfg 'feature="unicode-bool"' --cfg 'feature="unicode-case"' --cfg 'feature="unicode-gencat"' --cfg 'feature="unicode-perl"' --cfg 'feature="unicode-script"' --cfg 'feature="unicode-segment"' -C metadata=eecb392efa84ae60 -C extra-filename=-eecb392efa84ae60 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Compiling percent-encoding v2.1.0 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name percent_encoding /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/percent-encoding-2.1.0/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=be58b329e394d460 -C extra-filename=-be58b329e394d460 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Compiling semver-parser v0.9.0 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name semver_parser /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/semver-parser-0.9.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=9ae31022f24ccd12 -C extra-filename=-9ae31022f24ccd12 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --cap-lints allow` Compiling unused v0.1.0 (/tmp/unused) Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name unused --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=d0a289a20cd6d031 -C extra-filename=-d0a289a20cd6d031 --out-dir /tmp/unused/target/debug/deps -C incremental=/tmp/unused/target/debug/incremental -L dependency=/tmp/unused/target/debug/deps` Compiling unicase v2.6.0 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name build_script_build /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-2.6.0/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=b7d2e523ca3e437f -C extra-filename=-b7d2e523ca3e437f --out-dir /tmp/unused/target/debug/build/unicase-b7d2e523ca3e437f -L dependency=/tmp/unused/target/debug/deps --extern version_check=/tmp/unused/target/debug/deps/libversion_check-82cc027e9ceba674.rlib --cap-lints allow` Compiling unicode-normalization v0.1.12 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name unicode_normalization /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/unicode-normalization-0.1.12/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=15192e5eeeaa0455 -C extra-filename=-15192e5eeeaa0455 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern smallvec=/tmp/unused/target/debug/deps/libsmallvec-84f514d64495f7fb.rmeta --cap-lints allow` Running `/tmp/unused/target/debug/build/memchr-c7f795a0c7e9979b/build-script-build` Compiling unicode-bidi v0.3.4 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name unicode_bidi /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/unicode-bidi-0.3.4/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' -C metadata=6e8dc3321fee5867 -C extra-filename=-6e8dc3321fee5867 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern matches=/tmp/unused/target/debug/deps/libmatches-346dc0eba02e242b.rmeta --cap-lints allow` Compiling thread_local v1.0.1 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name thread_local /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/thread_local-1.0.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=57a3b23f69080e57 -C extra-filename=-57a3b23f69080e57 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern lazy_static=/tmp/unused/target/debug/deps/liblazy_static-5fa5bc44b10bdd8d.rmeta --cap-lints allow` Running `/tmp/unused/target/debug/build/serde-0cc309bc7ba935eb/build-script-build` Running `/tmp/unused/target/debug/build/proc-macro2-e23547cdc7db7e81/build-script-build` Running `/tmp/unused/target/debug/build/bitflags-6de1ffcc56ec72ff/build-script-build` Compiling itertools v0.9.0 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name itertools --edition=2018 /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/itertools-0.9.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="use_std"' -C metadata=592e37ac98e9c955 -C extra-filename=-592e37ac98e9c955 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern either=/tmp/unused/target/debug/deps/libeither-498735f8abeeff51.rmeta --cap-lints allow` Running `/tmp/unused/target/debug/build/pulldown-cmark-205bcfdd39cbd395/build-script-build` Running `/tmp/unused/target/debug/build/syn-71a7901023ddb067/build-script-build` Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name memchr /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-2.3.3/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' --cfg 'feature="use_std"' -C metadata=7db8e3be84bf03b4 -C extra-filename=-7db8e3be84bf03b4 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --cap-lints allow --cfg memchr_runtime_simd --cfg memchr_runtime_sse2 --cfg memchr_runtime_sse42 --cfg memchr_runtime_avx` Running `/tmp/unused/target/debug/build/unicase-b7d2e523ca3e437f/build-script-build` Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name serde /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.110/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=8c9be886b59d121a -C extra-filename=-8c9be886b59d121a --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --cap-lints allow --cfg ops_bound --cfg core_reverse --cfg de_boxed_c_str --cfg de_boxed_path --cfg de_rc_dst --cfg core_duration --cfg integer128 --cfg range_inclusive --cfg num_nonzero --cfg core_try_from --cfg num_nonzero_signed --cfg std_atomic64 --cfg std_atomic` Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name proc_macro2 --edition=2018 /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.17/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="proc-macro"' --cfg 'feature="span-locations"' -C metadata=ee5ee5acdcf42a09 -C extra-filename=-ee5ee5acdcf42a09 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern unicode_xid=/tmp/unused/target/debug/deps/libunicode_xid-78174849e41719c0.rmeta --cap-lints allow --cfg span_locations --cfg hygiene --cfg use_proc_macro --cfg wrap_proc_macro --cfg proc_macro_span` Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name bitflags /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/bitflags-1.2.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' -C metadata=495057c2a47c9bc0 -C extra-filename=-495057c2a47c9bc0 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --cap-lints allow --cfg bitflags_const_fn` Compiling idna v0.2.0 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name idna /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/idna-0.2.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=68eec88b56a5c01c -C extra-filename=-68eec88b56a5c01c --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern matches=/tmp/unused/target/debug/deps/libmatches-346dc0eba02e242b.rmeta --extern unicode_bidi=/tmp/unused/target/debug/deps/libunicode_bidi-6e8dc3321fee5867.rmeta --extern unicode_normalization=/tmp/unused/target/debug/deps/libunicode_normalization-15192e5eeeaa0455.rmeta --cap-lints allow` Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name unicase /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/unicase-2.6.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=2f1457e7ede0320d -C extra-filename=-2f1457e7ede0320d --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --cap-lints allow --cfg __unicase__iter_cmp --cfg __unicase__default_hasher --cfg __unicase__const_fns --cfg __unicase__core_and_alloc` Compiling aho-corasick v0.7.10 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name aho_corasick /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.7.10/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=15de38d034070f8e -C extra-filename=-15de38d034070f8e --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern memchr=/tmp/unused/target/debug/deps/libmemchr-7db8e3be84bf03b4.rmeta --cap-lints allow` Compiling quote v1.0.6 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name quote --edition=2018 /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/quote-1.0.6/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="proc-macro"' -C metadata=2a477e1967d634e4 -C extra-filename=-2a477e1967d634e4 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern proc_macro2=/tmp/unused/target/debug/deps/libproc_macro2-ee5ee5acdcf42a09.rmeta --cap-lints allow` Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name pulldown_cmark --edition=2018 /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/pulldown-cmark-0.7.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=fc38f16cf4b0e353 -C extra-filename=-fc38f16cf4b0e353 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern bitflags=/tmp/unused/target/debug/deps/libbitflags-495057c2a47c9bc0.rmeta --extern memchr=/tmp/unused/target/debug/deps/libmemchr-7db8e3be84bf03b4.rmeta --extern unicase=/tmp/unused/target/debug/deps/libunicase-2f1457e7ede0320d.rmeta --cap-lints allow` Compiling url v2.1.1 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name url /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/url-2.1.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=3d67c767c538e9bc -C extra-filename=-3d67c767c538e9bc --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern idna=/tmp/unused/target/debug/deps/libidna-68eec88b56a5c01c.rmeta --extern matches=/tmp/unused/target/debug/deps/libmatches-346dc0eba02e242b.rmeta --extern percent_encoding=/tmp/unused/target/debug/deps/libpercent_encoding-be58b329e394d460.rmeta --cap-lints allow` Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name syn --edition=2018 /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.27/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="clone-impls"' --cfg 'feature="default"' --cfg 'feature="derive"' --cfg 'feature="full"' --cfg 'feature="parsing"' --cfg 'feature="printing"' --cfg 'feature="proc-macro"' --cfg 'feature="quote"' -C metadata=cb4b3804c6eed20c -C extra-filename=-cb4b3804c6eed20c --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern proc_macro2=/tmp/unused/target/debug/deps/libproc_macro2-ee5ee5acdcf42a09.rmeta --extern quote=/tmp/unused/target/debug/deps/libquote-2a477e1967d634e4.rmeta --extern unicode_xid=/tmp/unused/target/debug/deps/libunicode_xid-78174849e41719c0.rmeta --cap-lints allow` Compiling regex v1.3.7 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name regex /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-1.3.7/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="aho-corasick"' --cfg 'feature="default"' --cfg 'feature="memchr"' --cfg 'feature="perf"' --cfg 'feature="perf-cache"' --cfg 'feature="perf-dfa"' --cfg 'feature="perf-inline"' --cfg 'feature="perf-literal"' --cfg 'feature="std"' --cfg 'feature="thread_local"' --cfg 'feature="unicode"' --cfg 'feature="unicode-age"' --cfg 'feature="unicode-bool"' --cfg 'feature="unicode-case"' --cfg 'feature="unicode-gencat"' --cfg 'feature="unicode-perl"' --cfg 'feature="unicode-script"' --cfg 'feature="unicode-segment"' -C metadata=939ed0e7d48e5780 -C extra-filename=-939ed0e7d48e5780 --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern aho_corasick=/tmp/unused/target/debug/deps/libaho_corasick-15de38d034070f8e.rmeta --extern memchr=/tmp/unused/target/debug/deps/libmemchr-7db8e3be84bf03b4.rmeta --extern regex_syntax=/tmp/unused/target/debug/deps/libregex_syntax-eecb392efa84ae60.rmeta --extern thread_local=/tmp/unused/target/debug/deps/libthread_local-57a3b23f69080e57.rmeta --cap-lints allow` Compiling toml v0.5.6 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name toml --edition=2018 /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/toml-0.5.6/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' -C metadata=9f5059a41c453e1f -C extra-filename=-9f5059a41c453e1f --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern serde=/tmp/unused/target/debug/deps/libserde-8c9be886b59d121a.rmeta --cap-lints allow` Compiling version-sync v0.9.0 Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name version_sync --edition=2018 /home/svartalf/.cargo/registry/src/github.com-1ecc6299db9ec823/version-sync-0.9.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -Cembed-bitcode=no -C debuginfo=2 -C metadata=63010f3e92cb9d7d -C extra-filename=-63010f3e92cb9d7d --out-dir /tmp/unused/target/debug/deps -L dependency=/tmp/unused/target/debug/deps --extern itertools=/tmp/unused/target/debug/deps/libitertools-592e37ac98e9c955.rmeta --extern proc_macro2=/tmp/unused/target/debug/deps/libproc_macro2-ee5ee5acdcf42a09.rmeta --extern pulldown_cmark=/tmp/unused/target/debug/deps/libpulldown_cmark-fc38f16cf4b0e353.rmeta --extern regex=/tmp/unused/target/debug/deps/libregex-939ed0e7d48e5780.rmeta --extern semver_parser=/tmp/unused/target/debug/deps/libsemver_parser-9ae31022f24ccd12.rmeta --extern syn=/tmp/unused/target/debug/deps/libsyn-cb4b3804c6eed20c.rmeta --extern toml=/tmp/unused/target/debug/deps/libtoml-9f5059a41c453e1f.rmeta --extern url=/tmp/unused/target/debug/deps/liburl-3d67c767c538e9bc.rmeta --cap-lints allow` Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name unused --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 --test -C metadata=75b39d4b3fec8f49 -C extra-filename=-75b39d4b3fec8f49 --out-dir /tmp/unused/target/debug/deps -C incremental=/tmp/unused/target/debug/incremental -L dependency=/tmp/unused/target/debug/deps --extern version_sync=/tmp/unused/target/debug/deps/libversion_sync-63010f3e92cb9d7d.rlib` Running `/home/svartalf/.cargo/bin/sccache rustc --crate-name version --edition=2018 tests/version.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 --test -C metadata=89ad4aa3484f45c0 -C extra-filename=-89ad4aa3484f45c0 --out-dir /tmp/unused/target/debug/deps -C incremental=/tmp/unused/target/debug/incremental -L dependency=/tmp/unused/target/debug/deps --extern unused=/tmp/unused/target/debug/deps/libunused-d0a289a20cd6d031.rlib --extern version_sync=/tmp/unused/target/debug/deps/libversion_sync-63010f3e92cb9d7d.rlib` error: external crate `version_sync` unused in `unused`: remove the dependency or add `use version_sync as _;` | note: the lint level is defined here --> src/lib.rs:1:9 | 1 | #![deny(unused)] | ^^^^^^ = note: `#[deny(unused_crate_dependencies)]` implied by `#[deny(unused)]` error: aborting due to previous error error: could not compile `unused`. Caused by: process didn't exit successfully: `/home/svartalf/.cargo/bin/sccache rustc --crate-name unused --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 --test -C metadata=75b39d4b3fec8f49 -C extra-filename=-75b39d4b3fec8f49 --out-dir /tmp/unused/target/debug/deps -C incremental=/tmp/unused/target/debug/incremental -L dependency=/tmp/unused/target/debug/deps --extern version_sync=/tmp/unused/target/debug/deps/libversion_sync-63010f3e92cb9d7d.rlib` (exit code: 1) warning: build failed, waiting for other jobs to finish... error: build failed ```

petrochenkov commented 4 years ago

cc @jsgf unused_crate_dependencies needs to be removed from the unused lint group, I didn't notice this when reviewing https://github.com/rust-lang/rust/pull/72342. Otherwise it can be enabled in a blanket way without enabling unused_crate_dependencies specifically, which is undesirable given the amount of redundant options passed by Cargo.

petrochenkov commented 4 years ago

Fixed in https://github.com/rust-lang/rust/pull/72702.

jsgf commented 4 years ago

Yeah this is the reason it's not on by default. We still need to work out if/how it can be used with cargo in a reasonable way.

Adding it to unused made sense to me but I didn't think through the fallout.

jsgf commented 4 years ago

@svartalf Though TBH I'm a bit confused - what targets is Cargo passing dev-dependencies to aside from tests? I would have thought your case would be OK.

Hm, I think there may be another bug that -Wunused-crate-dependencies isn't seeing uses in #[test] blocks. At the very least it needs a test for that.

tv42 commented 1 year ago

As far as I can tell, this issue wasn't fixed, unused_crate_dependencies was just removed from the unused group.

The functionality of unused_crate_dependencies is still desirable!

See https://github.com/rust-lang/rust/issues/57274