From ef64c762d24d763886d79d11f0e4d76446858ee5 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Mon, 3 Dec 2018 08:12:35 +0100 Subject: [PATCH 1/2] 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 --- clippy_lints/src/wildcard_dependencies.rs | 9 +++++++-- 1 file 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, From 46ee676139006c74d7d7594a755d84290a5f1eee Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Tue, 4 Dec 2018 06:47:41 +0100 Subject: [PATCH 2/2] cargo fmt --- clippy_lints/src/wildcard_dependencies.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/wildcard_dependencies.rs b/clippy_lints/src/wildcard_dependencies.rs index d7178f1f11a..6de391d882f 100644 --- a/clippy_lints/src/wildcard_dependencies.rs +++ b/clippy_lints/src/wildcard_dependencies.rs @@ -12,8 +12,8 @@ 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 if_chain::if_chain; use semver; /// **What it does:** Checks for wildcard dependencies in the `Cargo.toml`.