]> git.lizzy.rs Git - rust.git/commitdiff
kill the old `visit_all_item_likes` infrastructure
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 2 May 2017 15:22:03 +0000 (11:22 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 3 May 2017 20:42:07 +0000 (16:42 -0400)
src/librustc/dep_graph/mod.rs
src/librustc/dep_graph/visit.rs [deleted file]
src/librustc/hir/intravisit.rs
src/librustc/hir/itemlikevisit.rs
src/librustc/ty/mod.rs
src/librustc_typeck/variance/terms.rs

index 6cb86a30400a772806fdcb546ad65b32871deff6..809bed939f54ca4bcb78e102d33077f0ba4499f7 100644 (file)
@@ -18,7 +18,6 @@
 mod safe;
 mod shadow;
 mod thread;
-mod visit;
 
 pub use self::dep_tracking_map::{DepTrackingMap, DepTrackingMapConfig};
 pub use self::dep_node::DepNode;
@@ -28,5 +27,4 @@
 pub use self::query::DepGraphQuery;
 pub use self::safe::AssertDepGraphSafe;
 pub use self::safe::DepGraphSafe;
-pub use self::visit::visit_all_item_likes_in_krate;
 pub use self::raii::DepTask;
diff --git a/src/librustc/dep_graph/visit.rs b/src/librustc/dep_graph/visit.rs
deleted file mode 100644 (file)
index bf37486..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use hir;
-use hir::def_id::DefId;
-use hir::itemlikevisit::ItemLikeVisitor;
-use ty::TyCtxt;
-
-use super::dep_node::DepNode;
-
-/// Visit all the items in the krate in some order. When visiting a
-/// particular item, first create a dep-node by calling `dep_node_fn`
-/// and push that onto the dep-graph stack of tasks, and also create a
-/// read edge from the corresponding AST node. This is used in
-/// compiler passes to automatically record the item that they are
-/// working on.
-pub fn visit_all_item_likes_in_krate<'a, 'tcx, V, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                                                     mut dep_node_fn: F,
-                                                     visitor: &mut V)
-    where F: FnMut(DefId) -> DepNode<DefId>, V: ItemLikeVisitor<'tcx>
-{
-    struct TrackingVisitor<'visit, 'tcx: 'visit, F: 'visit, V: 'visit> {
-        tcx: TyCtxt<'visit, 'tcx, 'tcx>,
-        dep_node_fn: &'visit mut F,
-        visitor: &'visit mut V,
-    }
-
-    impl<'visit, 'tcx, F, V> ItemLikeVisitor<'tcx> for TrackingVisitor<'visit, 'tcx, F, V>
-        where F: FnMut(DefId) -> DepNode<DefId>, V: ItemLikeVisitor<'tcx>
-    {
-        fn visit_item(&mut self, i: &'tcx hir::Item) {
-            let item_def_id = self.tcx.hir.local_def_id(i.id);
-            let task_id = (self.dep_node_fn)(item_def_id);
-            let _task = self.tcx.dep_graph.in_task(task_id.clone());
-            debug!("Started task {:?}", task_id);
-            self.tcx.dep_graph.read(DepNode::Hir(item_def_id));
-            self.visitor.visit_item(i);
-            debug!("Ended task {:?}", task_id);
-        }
-
-        fn visit_trait_item(&mut self, i: &'tcx hir::TraitItem) {
-            let trait_item_def_id = self.tcx.hir.local_def_id(i.id);
-            let task_id = (self.dep_node_fn)(trait_item_def_id);
-            let _task = self.tcx.dep_graph.in_task(task_id.clone());
-            debug!("Started task {:?}", task_id);
-            self.tcx.dep_graph.read(DepNode::Hir(trait_item_def_id));
-            self.visitor.visit_trait_item(i);
-            debug!("Ended task {:?}", task_id);
-        }
-
-        fn visit_impl_item(&mut self, i: &'tcx hir::ImplItem) {
-            let impl_item_def_id = self.tcx.hir.local_def_id(i.id);
-            let task_id = (self.dep_node_fn)(impl_item_def_id);
-            let _task = self.tcx.dep_graph.in_task(task_id.clone());
-            debug!("Started task {:?}", task_id);
-            self.tcx.dep_graph.read(DepNode::Hir(impl_item_def_id));
-            self.visitor.visit_impl_item(i);
-            debug!("Ended task {:?}", task_id);
-        }
-    }
-
-    let krate = tcx.dep_graph.with_ignore(|| tcx.hir.krate());
-    let mut tracking_visitor = TrackingVisitor {
-        tcx: tcx,
-        dep_node_fn: &mut dep_node_fn,
-        visitor: visitor,
-    };
-    krate.visit_all_item_likes(&mut tracking_visitor)
-}
-
index 3e610dd3c0d87a74eda2f237177080f37a1b9b24..def6b2b3421f6f4135e0741b575506381f5a2e10 100644 (file)
@@ -88,7 +88,7 @@ pub enum NestedVisitorMap<'this, 'tcx: 'this> {
     /// that are inside of an item-like.
     ///
     /// **This is the most common choice.** A very commmon pattern is
-    /// to use `tcx.visit_all_item_likes_in_krate()` as an outer loop,
+    /// to use `visit_all_item_likes()` as an outer loop,
     /// and to have the visitor that visits the contents of each item
     /// using this setting.
     OnlyBodies(&'this Map<'tcx>),
index 0d79017066b01da6946a97a70559737aa8596de7..ce1a34faf5ee8a850df8e9ec91ce463009c1c9ad 100644 (file)
@@ -19,9 +19,8 @@
 ///
 /// 1. **Shallow visit**: Get a simple callback for every item (or item-like thing) in the HIR.
 ///    - Example: find all items with a `#[foo]` attribute on them.
-///    - How: Implement `ItemLikeVisitor` and call `tcx.visit_all_item_likes_in_krate()`.
+///    - How: Implement `ItemLikeVisitor` and call `tcx.hir.krate().visit_all_item_likes()`.
 ///    - Pro: Efficient; just walks the lists of item-like things, not the nodes themselves.
-///    - Pro: Integrates well into dependency tracking.
 ///    - Con: Don't get information about nesting
 ///    - Con: Don't have methods for specific bits of HIR, like "on
 ///      every expr, do this".
@@ -30,7 +29,7 @@
 ///    within one another.
 ///    - Example: Examine each expression to look for its type and do some check or other.
 ///    - How: Implement `intravisit::Visitor` and use
-///      `tcx.visit_all_item_likes_in_krate(visitor.as_deep_visitor())`. Within
+///      `tcx.hir.krate().visit_all_item_likes(visitor.as_deep_visitor())`. Within
 ///      your `intravisit::Visitor` impl, implement methods like
 ///      `visit_expr()`; don't forget to invoke
 ///      `intravisit::walk_visit_expr()` to keep walking the subparts.
index 481098450eda416a9459f68d272c2e819351b321..2355ed7e147b33ac0d398a482ad626608c9483ab 100644 (file)
@@ -15,7 +15,7 @@
 pub use self::LvaluePreference::*;
 pub use self::fold::TypeFoldable;
 
-use dep_graph::{self, DepNode};
+use dep_graph::DepNode;
 use hir::{map as hir_map, FreevarMap, TraitMap};
 use hir::def::{Def, CtorKind, ExportMap};
 use hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX, LOCAL_CRATE};
@@ -58,7 +58,6 @@
 use rustc_data_structures::transitive_relation::TransitiveRelation;
 
 use hir;
-use hir::itemlikevisit::ItemLikeVisitor;
 
 pub use self::sty::{Binder, DebruijnIndex};
 pub use self::sty::{FnSig, PolyFnSig};
@@ -2565,14 +2564,6 @@ pub fn node_scope_region(self, id: NodeId) -> Region<'tcx> {
         self.mk_region(ty::ReScope(self.node_extent(id)))
     }
 
-    pub fn visit_all_item_likes_in_krate<V,F>(self,
-                                              dep_node_fn: F,
-                                              visitor: &mut V)
-        where F: FnMut(DefId) -> DepNode<DefId>, V: ItemLikeVisitor<'gcx>
-    {
-        dep_graph::visit_all_item_likes_in_krate(self.global_tcx(), dep_node_fn, visitor);
-    }
-
     /// Looks up the span of `impl_did` if the impl is local; otherwise returns `Err`
     /// with the name of the crate containing the impl.
     pub fn span_of_impl(self, impl_did: DefId) -> Result<Span, Symbol> {
index 3f4b15e35a42db30d6019df2c046ac3efcada97a..ad787c57e76f2a60ee49739eef874e17c4ae5665 100644 (file)
@@ -32,8 +32,6 @@
 
 pub type VarianceTermPtr<'a> = &'a VarianceTerm<'a>;
 
-use dep_graph::DepNode::ItemSignature as VarianceDepNode;
-
 #[derive(Copy, Clone, Debug)]
 pub struct InferredIndex(pub usize);
 
@@ -109,7 +107,7 @@ pub fn determine_parameters_to_be_inferred<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>
     };
 
     // See README.md for a discussion on dep-graph management.
-    tcx.visit_all_item_likes_in_krate(|def_id| VarianceDepNode(def_id), &mut terms_cx);
+    tcx.hir.krate().visit_all_item_likes(&mut terms_cx);
 
     terms_cx
 }