]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/functions.rs
Merge branch 'macro-use' into HEAD
[rust.git] / clippy_lints / src / functions.rs
index 554c983d7c514748cbc4982f33effe3b3c8c37cd..d9f50d652d37bf284cb4e5d1f118946a6210fdb8 100644 (file)
@@ -1,6 +1,8 @@
+use matches::matches;
 use rustc::hir::intravisit;
 use rustc::hir;
 use rustc::lint::*;
+use rustc::{declare_lint, lint_array};
 use rustc::ty;
 use rustc::hir::def::Def;
 use std::collections::HashSet;
@@ -86,7 +88,7 @@ fn check_fn(
         use rustc::hir::map::Node::*;
 
         let is_impl = if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) {
-            matches!(item.node, hir::ItemImpl(_, _, _, _, Some(_), _, _))
+            matches!(item.node, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _))
         } else {
             false
         };
@@ -168,7 +170,7 @@ fn check_raw_ptr(
 }
 
 fn raw_ptr_arg(arg: &hir::Arg, ty: &hir::Ty) -> Option<ast::NodeId> {
-    if let (&hir::PatKind::Binding(_, id, _, _), &hir::TyPtr(_)) = (&arg.pat.node, &ty.node) {
+    if let (&hir::PatKind::Binding(_, id, _, _), &hir::TyKind::Ptr(_)) = (&arg.pat.node, &ty.node) {
         Some(id)
     } else {
         None
@@ -184,7 +186,7 @@ struct DerefVisitor<'a, 'tcx: 'a> {
 impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
     fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
         match expr.node {
-            hir::ExprCall(ref f, ref args) => {
+            hir::ExprKind::Call(ref f, ref args) => {
                 let ty = self.tables.expr_ty(f);
 
                 if type_is_unsafe_function(self.cx, ty) {
@@ -193,7 +195,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
                     }
                 }
             },
-            hir::ExprMethodCall(_, _, ref args) => {
+            hir::ExprKind::MethodCall(_, _, ref args) => {
                 let def_id = self.tables.type_dependent_defs()[expr.hir_id].def_id();
                 let base_type = self.cx.tcx.type_of(def_id);
 
@@ -203,7 +205,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
                     }
                 }
             },
-            hir::ExprUnary(hir::UnDeref, ref ptr) => self.check_arg(ptr),
+            hir::ExprKind::Unary(hir::UnDeref, ref ptr) => self.check_arg(ptr),
             _ => (),
         }
 
@@ -216,7 +218,7 @@ fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'thi
 
 impl<'a, 'tcx: 'a> DerefVisitor<'a, 'tcx> {
     fn check_arg(&self, ptr: &hir::Expr) {
-        if let hir::ExprPath(ref qpath) = ptr.node {
+        if let hir::ExprKind::Path(ref qpath) = ptr.node {
             if let Def::Local(id) = self.cx.tables.qpath_def(qpath, ptr.hir_id) {
                 if self.ptrs.contains(&id) {
                     span_lint(