]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_passes/dead.rs
Rollup merge of #68462 - matthiaskrgr:novec, r=varkor
[rust.git] / src / librustc_passes / dead.rs
index a13c9aff70a229e9ae622370d5185d977ccca8e2..2ff9d744f2c4d771c782d03bd5854905d64e3dad 100644 (file)
@@ -2,24 +2,22 @@
 // closely. The idea is that all reachable symbols are live, codes called
 // from live codes are live, and everything else is dead.
 
-use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
-use rustc::hir::itemlikevisit::ItemLikeVisitor;
-use rustc::hir::Node;
-use rustc::hir::{self, PatKind, TyKind};
-
-use rustc::hir::def::{CtorOf, DefKind, Res};
-use rustc::hir::def_id::{DefId, LOCAL_CRATE};
-use rustc::hir::CodegenFnAttrFlags;
-use rustc::lint;
+use rustc::hir::map::Map;
+use rustc::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use rustc::middle::privacy;
 use rustc::ty::{self, DefIdTree, TyCtxt};
-use rustc::util::nodemap::FxHashSet;
-
-use rustc_data_structures::fx::FxHashMap;
-
-use syntax::symbol::sym;
+use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_hir as hir;
+use rustc_hir::def::{CtorOf, DefKind, Res};
+use rustc_hir::def_id::{DefId, LOCAL_CRATE};
+use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
+use rustc_hir::itemlikevisit::ItemLikeVisitor;
+use rustc_hir::{Node, PatKind, TyKind};
+use rustc_session::lint;
+
+use rustc_span;
+use rustc_span::symbol::sym;
 use syntax::{ast, attr};
-use syntax_pos;
 
 // Any local node that may call something in its body block should be
 // explored. For example, if it's a live Node::Item that is a
@@ -213,7 +211,9 @@ fn mark_as_used_if_union(&mut self, adt: &ty::AdtDef, fields: &[hir::Field<'_>])
 }
 
 impl<'a, 'tcx> Visitor<'tcx> for MarkSymbolVisitor<'a, 'tcx> {
-    fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+    type Map = Map<'tcx>;
+
+    fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<'_, Self::Map> {
         NestedVisitorMap::None
     }
 
@@ -229,9 +229,9 @@ fn visit_variant_data(
         &mut self,
         def: &'tcx hir::VariantData<'tcx>,
         _: ast::Name,
-        _: &hir::Generics,
+        _: &hir::Generics<'_>,
         _: hir::HirId,
-        _: syntax_pos::Span,
+        _: rustc_span::Span,
     ) {
         let has_repr_c = self.repr_has_repr_c;
         let inherited_pub_visibility = self.inherited_pub_visibility;
@@ -295,12 +295,12 @@ fn visit_pat(&mut self, pat: &'tcx hir::Pat<'tcx>) {
         self.in_pat = false;
     }
 
-    fn visit_path(&mut self, path: &'tcx hir::Path, _: hir::HirId) {
+    fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, _: hir::HirId) {
         self.handle_res(path.res);
         intravisit::walk_path(self, path);
     }
 
-    fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
+    fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) {
         match ty.kind {
             TyKind::Def(item_id, _) => {
                 let item = self.tcx.hir().expect_item(item_id.id);
@@ -405,10 +405,10 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
                     }
                 }
             }
-            hir::ItemKind::Impl(.., ref opt_trait, _, impl_item_refs) => {
-                for impl_item_ref in impl_item_refs {
+            hir::ItemKind::Impl { ref of_trait, items, .. } => {
+                for impl_item_ref in items {
                     let impl_item = self.krate.impl_item(impl_item_ref.id);
-                    if opt_trait.is_some()
+                    if of_trait.is_some()
                         || has_allow_dead_code_or_lang_attr(
                             self.tcx,
                             impl_item.hir_id,
@@ -549,7 +549,7 @@ fn symbol_is_live(&mut self, id: hir::HirId) -> bool {
     fn warn_dead_code(
         &mut self,
         id: hir::HirId,
-        span: syntax_pos::Span,
+        span: rustc_span::Span,
         name: ast::Name,
         node_type: &str,
         participle: &str,
@@ -566,11 +566,13 @@ fn warn_dead_code(
 }
 
 impl Visitor<'tcx> for DeadVisitor<'tcx> {
+    type Map = Map<'tcx>;
+
     /// Walk nested items in place so that we don't report dead-code
     /// on inner functions when the outer function is already getting
     /// an error. We could do this also by checking the parents, but
     /// this is how the code is setup and it seems harmless enough.
-    fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+    fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
         NestedVisitorMap::All(&self.tcx.hir())
     }
 
@@ -584,7 +586,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
                 | hir::ItemKind::Struct(..)
                 | hir::ItemKind::Union(..)
                 | hir::ItemKind::Trait(..)
-                | hir::ItemKind::Impl(..) => {
+                | hir::ItemKind::Impl { .. } => {
                     // FIXME(66095): Because item.span is annotated with things
                     // like expansion data, and ident.span isn't, we use the
                     // def_span method if it's part of a macro invocation
@@ -619,7 +621,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
     fn visit_variant(
         &mut self,
         variant: &'tcx hir::Variant<'tcx>,
-        g: &'tcx hir::Generics,
+        g: &'tcx hir::Generics<'tcx>,
         id: hir::HirId,
     ) {
         if self.should_warn_about_variant(&variant) {