]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/reachable.rs
rustc: use DefKind instead of Def, where possible.
[rust.git] / src / librustc / middle / reachable.rs
index b55e840596b851b5cc24f7c577972fa64ce815c6..a68be387d61091603e434a10059208c7bfc55c83 100644 (file)
@@ -7,7 +7,7 @@
 
 use crate::hir::{CodegenFnAttrs, CodegenFnAttrFlags};
 use crate::hir::Node;
-use crate::hir::def::Def;
+use crate::hir::def::{Def, DefKind};
 use crate::hir::def_id::{DefId, CrateNum};
 use rustc_data_structures::sync::Lrc;
 use crate::ty::{self, TyCtxt};
@@ -98,13 +98,13 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
             }
             hir::ExprKind::MethodCall(..) => {
                 self.tables.type_dependent_def(expr.hir_id)
+                    .map(|(kind, def_id)| Def::Def(kind, def_id))
             }
             _ => None
         };
 
         match def {
-            Some(Def::Local(node_id)) | Some(Def::Upvar(node_id, ..)) => {
-                let hir_id = self.tcx.hir().node_to_hir_id(node_id);
+            Some(Def::Local(hir_id)) | Some(Def::Upvar(hir_id, ..)) => {
                 self.reachable_symbols.insert(hir_id);
             }
             Some(def) => {
@@ -118,7 +118,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
                             // If this path leads to a constant, then we need to
                             // recurse into the constant to continue finding
                             // items that are reachable.
-                            Def::Const(..) | Def::AssociatedConst(..) => {
+                            Def::Def(DefKind::Const, _) | Def::Def(DefKind::AssociatedConst, _) => {
                                 self.worklist.push(hir_id);
                             }
 
@@ -358,7 +358,7 @@ fn visit_item(&mut self, item: &hir::Item) {
                 self.worklist.extend(impl_item_refs.iter().map(|ii_ref| ii_ref.id.hir_id));
 
                 let trait_def_id = match trait_ref.path.def {
-                    Def::Trait(def_id) => def_id,
+                    Def::Def(DefKind::Trait, def_id) => def_id,
                     _ => unreachable!()
                 };