diff options
| author | Philipp Hansch <dev@phansch.net> | 2018-12-03 08:12:35 +0100 |
|---|---|---|
| committer | Philipp Hansch <dev@phansch.net> | 2018-12-03 08:12:35 +0100 |
| commit | ef64c762d24d763886d79d11f0e4d76446858ee5 (patch) | |
| tree | 0f960da3d01759abb1251374fde5bc4d7f345c83 | |
| parent | 6253d457e1c558d5580bdd6dfd35cccead31f3ac (diff) | |
| download | rust-ef64c762d24d763886d79d11f0e4d76446858ee5.tar.gz rust-ef64c762d24d763886d79d11f0e4d76446858ee5.zip | |
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
| -rw-r--r-- | clippy_lints/src/wildcard_dependencies.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clippy_lints/src/wildcard_dependencies.rs b/clippy_lints/src/wildcard_dependencies.rs index 59f3cc78afe..d7178f1f11a 100644 --- a/clippy_lints/src/wildcard_dependencies.rs +++ b/clippy_lints/src/wildcard_dependencies.rs @@ -12,6 +12,7 @@ use crate::rustc::{declare_tool_lint, lint_array}; use crate::syntax::{ast::*, source_map::DUMMY_SP}; use crate::utils::span_lint; +use if_chain::if_chain; use cargo_metadata; use semver; @@ -54,8 +55,12 @@ impl EarlyLintPass for Pass { for dep in &metadata.packages[0].dependencies { // VersionReq::any() does not work - if let Ok(wildcard_ver) = semver::VersionReq::parse("*") { - if dep.req == wildcard_ver { + if_chain! { + if let Ok(wildcard_ver) = semver::VersionReq::parse("*"); + if let Some(ref source) = dep.source; + if !source.starts_with("git"); + if dep.req == wildcard_ver; + then { span_lint( cx, WILDCARD_DEPENDENCIES, |
