Skip to content

Commit ef64c76

Browse files
committed
Fix wildcard_dependencies false positive
This now only checks for wildcard_dependencies if the source is a non-git source. I tried adding a compiletest suite for the cargo lints, but I was unable to override the `Cargo.toml` of the original executable. I tested this manually by modifying the main `Cargo.toml`. Fixes #3458
1 parent 6253d45 commit ef64c76

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

clippy_lints/src/wildcard_dependencies.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::rustc::{declare_tool_lint, lint_array};
1212
use crate::syntax::{ast::*, source_map::DUMMY_SP};
1313
use crate::utils::span_lint;
1414

15+
use if_chain::if_chain;
1516
use cargo_metadata;
1617
use semver;
1718

@@ -54,8 +55,12 @@ impl EarlyLintPass for Pass {
5455

5556
for dep in &metadata.packages[0].dependencies {
5657
// VersionReq::any() does not work
57-
if let Ok(wildcard_ver) = semver::VersionReq::parse("*") {
58-
if dep.req == wildcard_ver {
58+
if_chain! {
59+
if let Ok(wildcard_ver) = semver::VersionReq::parse("*");
60+
if let Some(ref source) = dep.source;
61+
if !source.starts_with("git");
62+
if dep.req == wildcard_ver;
63+
then {
5964
span_lint(
6065
cx,
6166
WILDCARD_DEPENDENCIES,

0 commit comments

Comments
 (0)