]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/replace_consts.rs
Merge branch 'macro-use' into HEAD
[rust.git] / clippy_lints / src / replace_consts.rs
index 511dbf7a40f98729ef155a598f4da7a359250183..b9a4c6ebb1958d5927bcc4e73920a1b85e920d2b 100644 (file)
@@ -1,7 +1,9 @@
 use rustc::lint::*;
+use rustc::{declare_lint, lint_array};
+use if_chain::if_chain;
 use rustc::hir;
 use rustc::hir::def::Def;
-use utils::{match_def_path, span_lint_and_sugg};
+use crate::utils::{match_def_path, span_lint_and_sugg};
 
 /// **What it does:** Checks for usage of `ATOMIC_X_INIT`, `ONCE_INIT`, and
 /// `uX/iX::MIN/MAX`.
@@ -20,9 +22,9 @@
 /// ```rust
 /// static FOO: AtomicIsize = AtomicIsize::new(0);
 /// ```
-declare_lint! {
+declare_clippy_lint! {
     pub REPLACE_CONSTS,
-    Allow,
+    pedantic,
     "Lint usages of standard library `const`s that could be replaced by `const fn`s"
 }
 
@@ -37,7 +39,7 @@ fn get_lints(&self) -> LintArray {
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ReplaceConsts {
     fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
         if_chain! {
-            if let hir::ExprPath(ref qp) = expr.node;
+            if let hir::ExprKind::Path(ref qp) = expr.node;
             if let Def::Const(def_id) = cx.tables.qpath_def(qp, expr.hir_id);
             then {
                 for &(const_path, repl_snip) in REPLACEMENTS {