diff options
| -rw-r--r-- | src/librustc/dep_graph/dep_node.rs | 20 | ||||
| -rw-r--r-- | src/librustc/middle/intrinsicck.rs | 3 | ||||
| -rw-r--r-- | src/librustc/middle/stability.rs | 2 | ||||
| -rw-r--r-- | src/librustc_const_eval/check_match.rs | 5 | ||||
| -rw-r--r-- | src/librustc_mir/mir_map.rs | 2 | ||||
| -rw-r--r-- | src/librustc_passes/consts.rs | 18 | ||||
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 6 | ||||
| -rw-r--r-- | src/librustc_typeck/coherence/orphan.rs | 3 | ||||
| -rw-r--r-- | src/librustc_typeck/coherence/overlap.rs | 2 | ||||
| -rw-r--r-- | src/librustc_typeck/collect.rs | 53 | ||||
| -rw-r--r-- | src/librustc_typeck/impl_wf_check.rs | 3 |
11 files changed, 21 insertions, 96 deletions
diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 59d04ea8c77..dfec80aafcd 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -61,8 +61,6 @@ pub enum DepNode<D: Clone + Debug> { RegionResolveCrate, PluginRegistrar, StabilityIndex, - CollectItem(D), - CollectItemSig(D), Coherence, Resolve, EntryPoint, @@ -71,15 +69,9 @@ pub enum DepNode<D: Clone + Debug> { CoherenceCheckImpl(D), CoherenceOverlapCheck(D), CoherenceOverlapCheckSpecial(D), - CoherenceOrphanCheck(D), Variance, - WfCheck(D), - TypeckItemType(D), UnusedTraitCheck, - CheckConst(D), PrivacyAccessLevels(CrateNum), - IntrinsicCheck(D), - MatchCheck(D), // Represents the MIR for a fn; also used as the task node for // things read/modify that MIR. @@ -92,7 +84,6 @@ pub enum DepNode<D: Clone + Debug> { RvalueCheck(D), Reachability, DeadCheck, - StabilityCheck(D), LateLintCheck, TransCrate, TransCrateItem(D), @@ -184,12 +175,10 @@ impl<D: Clone + Debug> DepNode<D> { } check! { - CollectItem, BorrowCheck, Hir, HirBody, TransCrateItem, - TypeckItemType, AssociatedItems, ItemSignature, AssociatedItemDefIds, @@ -237,18 +226,10 @@ impl<D: Clone + Debug> DepNode<D> { Hir(ref d) => op(d).map(Hir), HirBody(ref d) => op(d).map(HirBody), MetaData(ref d) => op(d).map(MetaData), - CollectItem(ref d) => op(d).map(CollectItem), - CollectItemSig(ref d) => op(d).map(CollectItemSig), CoherenceCheckTrait(ref d) => op(d).map(CoherenceCheckTrait), CoherenceCheckImpl(ref d) => op(d).map(CoherenceCheckImpl), CoherenceOverlapCheck(ref d) => op(d).map(CoherenceOverlapCheck), CoherenceOverlapCheckSpecial(ref d) => op(d).map(CoherenceOverlapCheckSpecial), - CoherenceOrphanCheck(ref d) => op(d).map(CoherenceOrphanCheck), - WfCheck(ref d) => op(d).map(WfCheck), - TypeckItemType(ref d) => op(d).map(TypeckItemType), - CheckConst(ref d) => op(d).map(CheckConst), - IntrinsicCheck(ref d) => op(d).map(IntrinsicCheck), - MatchCheck(ref d) => op(d).map(MatchCheck), Mir(ref d) => op(d).map(Mir), MirShim(ref def_ids) => { let def_ids: Option<Vec<E>> = def_ids.iter().map(op).collect(); @@ -256,7 +237,6 @@ impl<D: Clone + Debug> DepNode<D> { } BorrowCheck(ref d) => op(d).map(BorrowCheck), RvalueCheck(ref d) => op(d).map(RvalueCheck), - StabilityCheck(ref d) => op(d).map(StabilityCheck), TransCrateItem(ref d) => op(d).map(TransCrateItem), TransInlinedItem(ref d) => op(d).map(TransInlinedItem), AssociatedItems(ref d) => op(d).map(AssociatedItems), diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index 942f8475ece..ecc0bb9fe49 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use dep_graph::DepNode; use hir::def::Def; use hir::def_id::DefId; use infer::InferCtxt; @@ -25,7 +24,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut visitor = ItemVisitor { tcx: tcx }; - tcx.visit_all_item_likes_in_krate(DepNode::IntrinsicCheck, &mut visitor.as_deep_visitor()); + tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); } struct ItemVisitor<'a, 'tcx: 'a> { diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 2b5ea61d4e8..f618386c610 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -424,7 +424,7 @@ impl<'a, 'tcx> Index<'tcx> { /// features and possibly prints errors. pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut checker = Checker { tcx: tcx }; - tcx.visit_all_item_likes_in_krate(DepNode::StabilityCheck, &mut checker.as_deep_visitor()); + tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor()); } struct Checker<'a, 'tcx: 'a> { diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index f1ab6a00aa2..2e0afe789c6 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -14,8 +14,6 @@ use _match::WitnessPreference::*; use pattern::{Pattern, PatternContext, PatternError, PatternKind}; -use rustc::dep_graph::DepNode; - use rustc::middle::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor}; use rustc::middle::expr_use_visitor::{LoanCause, MutateMode}; use rustc::middle::expr_use_visitor as euv; @@ -56,8 +54,7 @@ impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> { } pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { - tcx.visit_all_item_likes_in_krate(DepNode::MatchCheck, - &mut OuterVisitor { tcx: tcx }.as_deep_visitor()); + tcx.hir.krate().visit_all_item_likes(&mut OuterVisitor { tcx: tcx }.as_deep_visitor()); tcx.sess.abort_if_errors(); } diff --git a/src/librustc_mir/mir_map.rs b/src/librustc_mir/mir_map.rs index 8c138d779c1..9dfe1a34c9c 100644 --- a/src/librustc_mir/mir_map.rs +++ b/src/librustc_mir/mir_map.rs @@ -68,7 +68,7 @@ pub fn build_mir_for_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { NestedVisitorMap::None } } - tcx.visit_all_item_likes_in_krate(DepNode::Mir, &mut GatherCtors { + tcx.hir.krate().visit_all_item_likes(&mut GatherCtors { tcx: tcx }.as_deep_visitor()); } diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index 44d3026d80c..2c4439f80a2 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -24,7 +24,6 @@ // - It's not possible to take the address of a static item with unsafe interior. This is enforced // by borrowck::gather_loans -use rustc::dep_graph::DepNode; use rustc::ty::cast::CastKind; use rustc_const_eval::ConstContext; use rustc::middle::const_val::ConstEvalErr; @@ -459,15 +458,14 @@ fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Exp } pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { - tcx.visit_all_item_likes_in_krate(DepNode::CheckConst, - &mut CheckCrateVisitor { - tcx: tcx, - tables: &ty::TypeckTables::empty(), - in_fn: false, - promotable: false, - mut_rvalue_borrows: NodeSet(), - param_env: tcx.empty_parameter_environment(), - }.as_deep_visitor()); + tcx.hir.krate().visit_all_item_likes(&mut CheckCrateVisitor { + tcx: tcx, + tables: &ty::TypeckTables::empty(), + in_fn: false, + promotable: false, + mut_rvalue_borrows: NodeSet(), + param_env: tcx.empty_parameter_environment(), + }.as_deep_visitor()); tcx.sess.abort_if_errors(); } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index f894c0d32e0..32aeeeb1105 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -82,7 +82,6 @@ pub use self::compare_method::{compare_impl_method, compare_const_impl}; use self::TupleArgumentsFlag::*; use astconv::AstConv; -use dep_graph::DepNode; use fmt_macros::{Parser, Piece, Position}; use hir::def::{Def, CtorKind}; use hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; @@ -577,14 +576,13 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'a, 'tcx> { pub fn check_wf_new<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> CompileResult { tcx.sess.track_errors(|| { let mut visit = wfcheck::CheckTypeWellFormedVisitor::new(tcx); - tcx.visit_all_item_likes_in_krate(DepNode::WfCheck, &mut visit.as_deep_visitor()); + tcx.hir.krate().visit_all_item_likes(&mut visit.as_deep_visitor()); }) } pub fn check_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> CompileResult { tcx.sess.track_errors(|| { - tcx.visit_all_item_likes_in_krate(DepNode::TypeckItemType, - &mut CheckItemTypesVisitor { tcx }); + tcx.hir.krate().visit_all_item_likes(&mut CheckItemTypesVisitor { tcx }); }) } diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index ee361ab6073..8ded3003c78 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -13,13 +13,12 @@ use rustc::traits; use rustc::ty::{self, TyCtxt}; -use rustc::dep_graph::DepNode; use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir; pub fn check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut orphan = OrphanChecker { tcx: tcx }; - tcx.visit_all_item_likes_in_krate(DepNode::CoherenceOrphanCheck, &mut orphan); + tcx.hir.krate().visit_all_item_likes(&mut orphan); } struct OrphanChecker<'cx, 'tcx: 'cx> { diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs index d334d0c4338..74edc7bff49 100644 --- a/src/librustc_typeck/coherence/overlap.rs +++ b/src/librustc_typeck/coherence/overlap.rs @@ -24,7 +24,7 @@ pub fn check_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { // this secondary walk specifically checks for some other cases, // like defaulted traits, for which additional overlap rules exist - tcx.visit_all_item_likes_in_krate(DepNode::CoherenceOverlapCheckSpecial, &mut overlap); + tcx.hir.krate().visit_all_item_likes(&mut overlap); } pub fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) { diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 73e3de0cc76..af0ef279e4f 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -64,7 +64,6 @@ use rustc::ty::{ToPredicate, ReprOptions}; use rustc::ty::{self, AdtKind, ToPolyTraitRef, Ty, TyCtxt}; use rustc::ty::maps::Providers; use rustc::ty::util::IntTypeExt; -use rustc::dep_graph::DepNode; use util::nodemap::{NodeMap, FxHashMap}; use rustc_const_math::ConstInt; @@ -87,7 +86,7 @@ use rustc::hir::def_id::DefId; pub fn collect_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let mut visitor = CollectItemTypesVisitor { tcx: tcx }; - tcx.visit_all_item_likes_in_krate(DepNode::CollectItem, &mut visitor.as_deep_visitor()); + tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor()); } pub fn provide(providers: &mut Providers) { @@ -126,57 +125,13 @@ struct CollectItemTypesVisitor<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx> } -impl<'a, 'tcx> CollectItemTypesVisitor<'a, 'tcx> { - /// Collect item types is structured into two tasks. The outer - /// task, `CollectItem`, walks the entire content of an item-like - /// thing, including its body. It also spawns an inner task, - /// `CollectItemSig`, which walks only the signature. This inner - /// task is the one that writes the item-type into the various - /// maps. This setup ensures that the item body is never - /// accessible to the task that computes its signature, so that - /// changes to the body don't affect the signature. - /// - /// Consider an example function `foo` that also has a closure in its body: - /// - /// ``` - /// fn foo(<sig>) { - /// ... - /// let bar = || ...; // we'll label this closure as "bar" below - /// } - /// ``` - /// - /// This results in a dep-graph like so. I've labeled the edges to - /// document where they arise. - /// - /// ``` - /// [HirBody(foo)] -2--> [CollectItem(foo)] -4-> [ItemSignature(bar)] - /// ^ ^ - /// 1 3 - /// [Hir(foo)] -----------+-6-> [CollectItemSig(foo)] -5-> [ItemSignature(foo)] - /// ``` - /// - /// 1. This is added by the `visit_all_item_likes_in_krate`. - /// 2. This is added when we fetch the item body. - /// 3. This is added because `CollectItem` launches `CollectItemSig`. - /// - it is arguably false; if we refactor the `with_task` system; - /// we could get probably rid of it, but it is also harmless enough. - /// 4. This is added by the code in `visit_expr` when we write to `item_types`. - /// 5. This is added by the code in `convert_item` when we write to `item_types`; - /// note that this write occurs inside the `CollectItemSig` task. - /// 6. Added by reads from within `op`. - fn with_collect_item_sig(&self, id: ast::NodeId, op: fn(TyCtxt<'a, 'tcx, 'tcx>, ast::NodeId)) { - let def_id = self.tcx.hir.local_def_id(id); - self.tcx.dep_graph.with_task(DepNode::CollectItemSig(def_id), self.tcx, id, op); - } -} - impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> { fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> { NestedVisitorMap::OnlyBodies(&self.tcx.hir) } fn visit_item(&mut self, item: &'tcx hir::Item) { - self.with_collect_item_sig(item.id, convert_item); + convert_item(self.tcx, item.id); intravisit::walk_item(self, item); } @@ -209,12 +164,12 @@ impl<'a, 'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'a, 'tcx> { } fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) { - self.with_collect_item_sig(trait_item.id, convert_trait_item); + convert_trait_item(self.tcx, trait_item.id); intravisit::walk_trait_item(self, trait_item); } fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) { - self.with_collect_item_sig(impl_item.id, convert_impl_item); + convert_impl_item(self.tcx, impl_item.id); intravisit::walk_impl_item(self, impl_item); } } diff --git a/src/librustc_typeck/impl_wf_check.rs b/src/librustc_typeck/impl_wf_check.rs index 3df25825a71..5751dc5ab8a 100644 --- a/src/librustc_typeck/impl_wf_check.rs +++ b/src/librustc_typeck/impl_wf_check.rs @@ -19,7 +19,6 @@ //! fixed, but for the moment it's easier to do these checks early. use constrained_type_params as ctp; -use rustc::dep_graph::DepNode; use rustc::hir; use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::def_id::DefId; @@ -63,7 +62,7 @@ pub fn impl_wf_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { // We will tag this as part of the WF check -- logically, it is, // but it's one that we must perform earlier than the rest of // WfCheck. - tcx.visit_all_item_likes_in_krate(DepNode::WfCheck, &mut ImplWfCheck { tcx: tcx }); + tcx.hir.krate().visit_all_item_likes(&mut ImplWfCheck { tcx: tcx }); } struct ImplWfCheck<'a, 'tcx: 'a> { |
