Skip to content

Commit 8b2eb06

Browse files
authored
Merge pull request #3488 from phansch/fix_cargo_lint_bug
Fix wildcard_dependencies false positive
2 parents c00210d + 46ee676 commit 8b2eb06

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
@@ -13,6 +13,7 @@ use crate::syntax::{ast::*, source_map::DUMMY_SP};
1313
use crate::utils::span_lint;
1414

1515
use cargo_metadata;
16+
use if_chain::if_chain;
1617
use semver;
1718

1819
/// **What it does:** Checks for wildcard dependencies in the `Cargo.toml`.
@@ -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)