Merge pull request #3488 from phansch/fix_cargo_lint_bug

Fix wildcard_dependencies false positive
This commit is contained in:
Philipp Hansch 2018-12-04 07:24:11 +01:00 committed by GitHub
commit 8b2eb06df3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@ use crate::syntax::{ast::*, source_map::DUMMY_SP};
use crate::utils::span_lint;
use cargo_metadata;
use if_chain::if_chain;
use semver;
/// **What it does:** Checks for wildcard dependencies in the `Cargo.toml`.
@ -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,