]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/wildcard_dependencies.rs
Auto merge of #4551 - mikerite:fix-ice-reporting, r=llogiq
[rust.git] / clippy_lints / src / wildcard_dependencies.rs
index 38bce9da932323a7a30b3e3fcedf1af7ab89f8b4..b2a66b6d5a44648939fd1f7804b56ad372760d4d 100644 (file)
@@ -1,52 +1,37 @@
-// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use crate::utils::span_lint;
 use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
-use rustc::{declare_tool_lint, lint_array};
+use rustc::{declare_lint_pass, declare_tool_lint};
 use syntax::{ast::*, source_map::DUMMY_SP};
 
 use cargo_metadata;
 use if_chain::if_chain;
 use semver;
 
-/// **What it does:** Checks for wildcard dependencies in the `Cargo.toml`.
-///
-/// **Why is this bad?** [As the edition guide says](https://rust-lang-nursery.github.io/edition-guide/rust-2018/cargo-and-crates-io/crates-io-disallows-wildcard-dependencies.html),
-/// it is highly unlikely that you work with any possible version of your dependency,
-/// and wildcard dependencies would cause unnecessary breakage in the ecosystem.
-///
-/// **Known problems:** None.
-///
-/// **Example:**
-///
-/// ```toml
-/// [dependencies]
-/// regex = "*"
-/// ```
 declare_clippy_lint! {
+    /// **What it does:** Checks for wildcard dependencies in the `Cargo.toml`.
+    ///
+    /// **Why is this bad?** [As the edition guide says](https://rust-lang-nursery.github.io/edition-guide/rust-2018/cargo-and-crates-io/crates-io-disallows-wildcard-dependencies.html),
+    /// it is highly unlikely that you work with any possible version of your dependency,
+    /// and wildcard dependencies would cause unnecessary breakage in the ecosystem.
+    ///
+    /// **Known problems:** None.
+    ///
+    /// **Example:**
+    ///
+    /// ```toml
+    /// [dependencies]
+    /// regex = "*"
+    /// ```
     pub WILDCARD_DEPENDENCIES,
     cargo,
     "wildcard dependencies being used"
 }
 
-pub struct Pass;
-
-impl LintPass for Pass {
-    fn get_lints(&self) -> LintArray {
-        lint_array!(WILDCARD_DEPENDENCIES)
-    }
-}
+declare_lint_pass!(WildcardDependencies => [WILDCARD_DEPENDENCIES]);
 
-impl EarlyLintPass for Pass {
+impl EarlyLintPass for WildcardDependencies {
     fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &Crate) {
-        let metadata = if let Ok(metadata) = cargo_metadata::metadata(None) {
+        let metadata = if let Ok(metadata) = cargo_metadata::MetadataCommand::new().no_deps().exec() {
             metadata
         } else {
             span_lint(cx, WILDCARD_DEPENDENCIES, DUMMY_SP, "could not read cargo metadata");