]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_lint/unused.rs
rustc: use DefKind instead of Def, where possible.
[rust.git] / src / librustc_lint / unused.rs
index 043bc62ddce602dc98c70b96d599b1a56ea6408d..5155ac410aabdd0d6c4e65f3d3c7c0b1a6e7c7bd 100644 (file)
@@ -1,4 +1,4 @@
-use rustc::hir::def::Def;
+use rustc::hir::def::{Def, DefKind};
 use rustc::hir::def_id::DefId;
 use rustc::lint;
 use rustc::ty;
@@ -87,13 +87,14 @@ fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) {
 
         let mut fn_warned = false;
         let mut op_warned = false;
-        let maybe_def = match expr.node {
+        let maybe_def_id = match expr.node {
             hir::ExprKind::Call(ref callee, _) => {
                 match callee.node {
                     hir::ExprKind::Path(ref qpath) => {
                         let def = cx.tables.qpath_def(qpath, callee.hir_id);
                         match def {
-                            Def::Fn(_) | Def::Method(_) => Some(def),
+                            Def::Def(DefKind::Fn, def_id)
+                            | Def::Def(DefKind::Method, def_id) => Some(def_id),
                             // `Def::Local` if it was a closure, for which we
                             // do not currently support must-use linting
                             _ => None
@@ -103,12 +104,11 @@ fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) {
                 }
             },
             hir::ExprKind::MethodCall(..) => {
-                cx.tables.type_dependent_def(expr.hir_id)
+                cx.tables.type_dependent_def_id(expr.hir_id)
             },
             _ => None
         };
-        if let Some(def) = maybe_def {
-            let def_id = def.def_id();
+        if let Some(def_id) = maybe_def_id {
             fn_warned = check_must_use(cx, def_id, s.span, "return value of ", "");
         } else if type_permits_lack_of_use {
             // We don't warn about unused unit or uninhabited types.