diff options
| author | bors <bors@rust-lang.org> | 2017-08-04 20:06:09 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-08-04 20:06:09 +0000 |
| commit | d692a91fa69a057d82cf6cb71aa3d50260f9de4a (patch) | |
| tree | 48c6be58e90989089620f5a658b860d4953fc8b5 /src | |
| parent | ff1135b224baac6bfc14970cb5d74dd66680e5e2 (diff) | |
| parent | b34c5a23ab0996321a414d47729a9076364a79c6 (diff) | |
Auto merge of #43590 - michaelwoerister:no-reopening-1, r=nikomatsakis
incr.comp.: Assert that no DepNode is re-opened (see issue #42298). This PR removes the last occurrence of DepNode re-opening and adds an assertion that prevents our doing so in the future too. The DepGraph should no be guaranteed to be cycle free. r? @nikomatsakis EDIT: Closes https://github.com/rust-lang/rust/issues/42298
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/dep_graph/dep_node.rs | 17 | ||||
| -rw-r--r-- | src/librustc/dep_graph/edges.rs | 10 | ||||
| -rw-r--r-- | src/librustc/ty/maps.rs | 43 |
3 files changed, 38 insertions, 32 deletions
diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 8e2c44a427b..c6f9cb2fcea 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -66,7 +66,6 @@ use hir::map::DefPathHash; use ich::Fingerprint; use ty::{TyCtxt, Instance, InstanceDef}; use ty::fast_reject::SimplifiedType; -use ty::subst::Substs; use rustc_data_structures::stable_hasher::{StableHasher, HashStable}; use ich::StableHashingContext; use std::fmt; @@ -104,6 +103,8 @@ macro_rules! define_dep_nodes { match *self { $( DepKind :: $variant => { + $(return !anon_attr_to_bool!($anon);)* + // tuple args $({ return <( $($tuple_arg,)* ) as DepNodeParams> @@ -112,6 +113,7 @@ macro_rules! define_dep_nodes { // struct args $({ + return <( $($struct_arg_ty,)* ) as DepNodeParams> ::CAN_RECONSTRUCT_QUERY_KEY; })* @@ -394,6 +396,7 @@ define_dep_nodes!( <'tcx> // Represents different phases in the compiler. [] RegionMaps(DefId), [] Coherence, + [] CoherenceInherentImplOverlapCheck, [] Resolve, [] CoherenceCheckTrait(DefId), [] PrivacyAccessLevels(CrateNum), @@ -444,17 +447,17 @@ define_dep_nodes!( <'tcx> [] TypeckBodiesKrate, [] TypeckTables(DefId), [] HasTypeckTables(DefId), - [] ConstEval { def_id: DefId, substs: &'tcx Substs<'tcx> }, + [anon] ConstEval, [] SymbolName(DefId), [] InstanceSymbolName { instance: Instance<'tcx> }, [] SpecializationGraph(DefId), [] ObjectSafety(DefId), - [anon] IsCopy(DefId), - [anon] IsSized(DefId), - [anon] IsFreeze(DefId), - [anon] NeedsDrop(DefId), - [anon] Layout(DefId), + [anon] IsCopy, + [anon] IsSized, + [anon] IsFreeze, + [anon] NeedsDrop, + [anon] Layout, // The set of impls for a given trait. [] TraitImpls(DefId), diff --git a/src/librustc/dep_graph/edges.rs b/src/librustc/dep_graph/edges.rs index 277b69262c9..9aa634770df 100644 --- a/src/librustc/dep_graph/edges.rs +++ b/src/librustc/dep_graph/edges.rs @@ -23,6 +23,11 @@ pub struct DepGraphEdges { edges: FxHashSet<(DepNodeIndex, DepNodeIndex)>, task_stack: Vec<OpenTask>, forbidden_edge: Option<EdgeFilter>, + + // A set to help assert that no two tasks use the same DepNode. This is a + // temporary measure. Once we load the previous dep-graph as readonly, this + // check will fall out of the graph implementation naturally. + opened_once: FxHashSet<DepNode>, } #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] @@ -80,6 +85,7 @@ impl DepGraphEdges { edges: FxHashSet(), task_stack: Vec::new(), forbidden_edge, + opened_once: FxHashSet(), } } @@ -97,6 +103,10 @@ impl DepGraphEdges { } pub fn push_task(&mut self, key: DepNode) { + if !self.opened_once.insert(key) { + bug!("Re-opened node {:?}", key) + } + self.task_stack.push(OpenTask::Regular { node: key, reads: Vec::new(), diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index 7a45a706ea4..a2e335c00b2 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -9,7 +9,7 @@ // except according to those terms. use dep_graph::{DepConstructor, DepNode, DepNodeIndex}; -use hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE}; +use hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use hir::def::Def; use hir; use middle::const_val; @@ -931,7 +931,7 @@ define_maps! { <'tcx> /// Checks all types in the krate for overlap in their inherent impls. Reports errors. /// Not meant to be used directly outside of coherence. /// (Defined only for LOCAL_CRATE) - [] crate_inherent_impls_overlap_check: crate_inherent_impls_dep_node(CrateNum) -> (), + [] crate_inherent_impls_overlap_check: inherent_impls_overlap_check_dep_node(CrateNum) -> (), /// Results of evaluating const items or constants embedded in /// other items (such as enum variant explicit discriminants). @@ -1014,6 +1014,10 @@ fn crate_inherent_impls_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> { DepConstructor::Coherence } +fn inherent_impls_overlap_check_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> { + DepConstructor::CoherenceInherentImplOverlapCheck +} + fn reachability_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> { DepConstructor::Reachability } @@ -1032,10 +1036,9 @@ fn typeck_item_bodies_dep_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> { DepConstructor::TypeckBodiesKrate } -fn const_eval_dep_node<'tcx>(key: ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>) +fn const_eval_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, (DefId, &'tcx Substs<'tcx>)>) -> DepConstructor<'tcx> { - let (def_id, substs) = key.value; - DepConstructor::ConstEval { def_id, substs } + DepConstructor::ConstEval } fn mir_keys<'tcx>(_: CrateNum) -> DepConstructor<'tcx> { @@ -1050,32 +1053,22 @@ fn relevant_trait_impls_for<'tcx>((def_id, t): (DefId, SimplifiedType)) -> DepCo DepConstructor::RelevantTraitImpls(def_id, t) } -fn is_copy_dep_node<'tcx>(key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> { - let def_id = ty::item_path::characteristic_def_id_of_type(key.value) - .unwrap_or(DefId::local(CRATE_DEF_INDEX)); - DepConstructor::IsCopy(def_id) +fn is_copy_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> { + DepConstructor::IsCopy } -fn is_sized_dep_node<'tcx>(key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> { - let def_id = ty::item_path::characteristic_def_id_of_type(key.value) - .unwrap_or(DefId::local(CRATE_DEF_INDEX)); - DepConstructor::IsSized(def_id) +fn is_sized_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> { + DepConstructor::IsSized } -fn is_freeze_dep_node<'tcx>(key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> { - let def_id = ty::item_path::characteristic_def_id_of_type(key.value) - .unwrap_or(DefId::local(CRATE_DEF_INDEX)); - DepConstructor::IsFreeze(def_id) +fn is_freeze_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> { + DepConstructor::IsFreeze } -fn needs_drop_dep_node<'tcx>(key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> { - let def_id = ty::item_path::characteristic_def_id_of_type(key.value) - .unwrap_or(DefId::local(CRATE_DEF_INDEX)); - DepConstructor::NeedsDrop(def_id) +fn needs_drop_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> { + DepConstructor::NeedsDrop } -fn layout_dep_node<'tcx>(key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> { - let def_id = ty::item_path::characteristic_def_id_of_type(key.value) - .unwrap_or(DefId::local(CRATE_DEF_INDEX)); - DepConstructor::Layout(def_id) +fn layout_dep_node<'tcx>(_: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> DepConstructor<'tcx> { + DepConstructor::Layout } |
