diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 4babadb67bce6..ce027af8d6ab1 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -85,11 +85,6 @@ macro_rules! is_anon_attr { ($attr:ident) => (false); } -macro_rules! is_input_attr { - (input) => (true); - ($attr:ident) => (false); -} - macro_rules! is_eval_always_attr { (eval_always) => (true); ($attr:ident) => (false); @@ -99,10 +94,6 @@ macro_rules! contains_anon_attr { ($($attr:ident),*) => ({$(is_anon_attr!($attr) | )* false}); } -macro_rules! contains_input_attr { - ($($attr:ident),*) => ({$(is_input_attr!($attr) | )* false}); -} - macro_rules! contains_eval_always_attr { ($($attr:ident),*) => ({$(is_eval_always_attr!($attr) | )* false}); } @@ -151,7 +142,7 @@ macro_rules! define_dep_nodes { } } - // FIXME: Make `is_anon`, `is_input`, `is_eval_always` and `has_params` properties + // FIXME: Make `is_anon`, `is_eval_always` and `has_params` properties // of queries #[inline(always)] pub fn is_anon(&self) -> bool { @@ -162,15 +153,6 @@ macro_rules! define_dep_nodes { } } - #[inline(always)] - pub fn is_input(&self) -> bool { - match *self { - $( - DepKind :: $variant => { contains_input_attr!($($attr),*) } - )* - } - } - #[inline(always)] pub fn is_eval_always(&self) -> bool { match *self { @@ -438,17 +420,17 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx> // suitable wrapper, you can use `tcx.dep_graph.ignore()` to gain // access to the krate, but you must remember to add suitable // edges yourself for the individual items that you read. - [input] Krate, + [eval_always] Krate, // Represents the body of a function or method. The def-id is that of the // function/method. - [input] HirBody(DefId), + [eval_always] HirBody(DefId), // Represents the HIR node with the given node-id - [input] Hir(DefId), + [eval_always] Hir(DefId), // Represents metadata from an extern crate. - [input] CrateMetadata(CrateNum), + [eval_always] CrateMetadata(CrateNum), // Represents different phases in the compiler. [] RegionScopeTree(DefId), @@ -480,7 +462,7 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx> [] CollectModItemTypes(DefId), [] Reachability, - [eval_always] CrateVariances, + [] CrateVariances, // Nodes representing bits of computed IR in the tcx. Each shared // table in the tcx (or elsewhere) maps to one of these @@ -533,7 +515,7 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx> // The set of impls for a given trait. [] TraitImpls(DefId), - [input] AllLocalTraitImpls, + [eval_always] AllLocalTraitImpls, [anon] TraitSelect, @@ -545,7 +527,7 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx> // to make type debuginfo to be source location independent. Declaring // DefSpan an input makes sure that changes to these are always detected // regardless of HIR hashing. - [input] DefSpan(DefId), + [eval_always] DefSpan(DefId), [] LookupStability(DefId), [] LookupDeprecationEntry(DefId), [] ConstIsRvaluePromotableToStatic(DefId), @@ -563,10 +545,10 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx> [] IsCompilerBuiltins(CrateNum), [] HasGlobalAllocator(CrateNum), [] HasPanicHandler(CrateNum), - [input] ExternCrate(DefId), + [eval_always] ExternCrate(DefId), [] Specializes { impl1: DefId, impl2: DefId }, - [input] InScopeTraits(DefIndex), - [input] ModuleExports(DefId), + [eval_always] InScopeTraits(DefIndex), + [eval_always] ModuleExports(DefId), [] IsSanitizerRuntime(CrateNum), [] IsProfilerRuntime(CrateNum), [] GetPanicStrategy(CrateNum), @@ -579,10 +561,10 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx> [] EntryFn(CrateNum), [] PluginRegistrarFn(CrateNum), [] ProcMacroDeclsStatic(CrateNum), - [input] CrateDisambiguator(CrateNum), - [input] CrateHash(CrateNum), - [input] OriginalCrateName(CrateNum), - [input] ExtraFileName(CrateNum), + [eval_always] CrateDisambiguator(CrateNum), + [eval_always] CrateHash(CrateNum), + [eval_always] OriginalCrateName(CrateNum), + [eval_always] ExtraFileName(CrateNum), [] ImplementationsOfTrait { krate: CrateNum, trait_id: DefId }, [] AllTraitImplementations(CrateNum), @@ -591,7 +573,7 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx> [] IsDllimportForeignItem(DefId), [] IsStaticallyIncludedForeignItem(DefId), [] NativeLibraryKind(DefId), - [input] LinkArgs, + [eval_always] LinkArgs, [] ResolveLifetimes(CrateNum), [] NamedRegion(DefIndex), @@ -599,8 +581,8 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx> [] ObjectLifetimeDefaults(DefIndex), [] Visibility(DefId), - [input] DepKind(CrateNum), - [input] CrateName(CrateNum), + [eval_always] DepKind(CrateNum), + [eval_always] CrateName(CrateNum), [] ItemChildren(DefId), [] ExternModStmtCnum(DefId), [eval_always] GetLibFeatures, @@ -609,24 +591,24 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx> [] DefinedLangItems(CrateNum), [] MissingLangItems(CrateNum), [] VisibleParentMap, - [input] MissingExternCrateItem(CrateNum), - [input] UsedCrateSource(CrateNum), - [input] PostorderCnums, - - [input] Freevars(DefId), - [input] MaybeUnusedTraitImport(DefId), - [input] MaybeUnusedExternCrates, - [input] NamesImportedByGlobUse(DefId), + [eval_always] MissingExternCrateItem(CrateNum), + [eval_always] UsedCrateSource(CrateNum), + [eval_always] PostorderCnums, + + [eval_always] Freevars(DefId), + [eval_always] MaybeUnusedTraitImport(DefId), + [eval_always] MaybeUnusedExternCrates, + [eval_always] NamesImportedByGlobUse(DefId), [eval_always] StabilityIndex, [eval_always] AllTraits, - [input] AllCrateNums, + [eval_always] AllCrateNums, [] ExportedSymbols(CrateNum), [eval_always] CollectAndPartitionMonoItems, [] IsCodegenedItem(DefId), [] CodegenUnit(InternedString), [] BackendOptimizationLevel(CrateNum), [] CompileCodegenUnit(InternedString), - [input] OutputFilenames, + [eval_always] OutputFilenames, [] NormalizeProjectionTy(CanonicalProjectionGoal<'tcx>), [] NormalizeTyAfterErasingRegions(ParamEnvAnd<'tcx, Ty<'tcx>>), [] ImpliedOutlivesBounds(CanonicalTyGoal<'tcx>), @@ -645,11 +627,11 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx> [] SubstituteNormalizeAndTestPredicates { key: (DefId, SubstsRef<'tcx>) }, [] MethodAutoderefSteps(CanonicalTyGoal<'tcx>), - [input] TargetFeaturesWhitelist, + [eval_always] TargetFeaturesWhitelist, [] InstanceDefSizeEstimate { instance_def: InstanceDef<'tcx> }, - [input] Features, + [eval_always] Features, [] ForeignModules(CrateNum), diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 8a2f79e6793c0..db81a9d826f8c 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -388,10 +388,7 @@ impl DepGraph { |_| None, |data, key, fingerprint, _| { let mut current = data.borrow_mut(); - let krate_idx = current.node_to_node_index[ - &DepNode::new_no_params(DepKind::Krate) - ]; - current.alloc_node(key, smallvec![krate_idx], fingerprint) + current.alloc_node(key, smallvec![], fingerprint) }, hash_result) } @@ -576,7 +573,7 @@ impl DepGraph { tcx: TyCtxt<'_, '_, '_>, dep_node: &DepNode ) -> Option<(SerializedDepNodeIndex, DepNodeIndex)> { - debug_assert!(!dep_node.kind.is_input()); + debug_assert!(!dep_node.kind.is_eval_always()); // Return None if the dep graph is disabled let data = self.data.as_ref()?; @@ -620,8 +617,8 @@ impl DepGraph { debug_assert!(data.colors.get(prev_dep_node_index).is_none()); } - // We never try to mark inputs as green - debug_assert!(!dep_node.kind.is_input()); + // We never try to mark eval_always nodes as green + debug_assert!(!dep_node.kind.is_eval_always()); debug_assert_eq!(data.previous.index_to_node(prev_dep_node_index), *dep_node); @@ -658,8 +655,8 @@ impl DepGraph { let dep_dep_node = &data.previous.index_to_node(dep_dep_node_index); // We don't know the state of this dependency. If it isn't - // an input node, let's try to mark it green recursively. - if !dep_dep_node.kind.is_input() { + // an eval_always node, let's try to mark it green recursively. + if !dep_dep_node.kind.is_eval_always() { debug!("try_mark_previous_green({:?}) --- state of dependency {:?} \ is unknown, trying to mark it green", dep_node, dep_dep_node); @@ -694,7 +691,7 @@ impl DepGraph { } } _ => { - // For other kinds of inputs it's OK to be + // For other kinds of nodes it's OK to be // forced. } } @@ -1017,33 +1014,11 @@ impl CurrentDepGraph { task_deps: TaskDeps, fingerprint: Fingerprint ) -> DepNodeIndex { - // If this is an input node, we expect that it either has no - // dependencies, or that it just depends on DepKind::CrateMetadata - // or DepKind::Krate. This happens for some "thin wrapper queries" - // like `crate_disambiguator` which sometimes have zero deps (for - // when called for LOCAL_CRATE) or they depend on a CrateMetadata - // node. - if cfg!(debug_assertions) { - if node.kind.is_input() && task_deps.reads.len() > 0 && - // FIXME(mw): Special case for DefSpan until Spans are handled - // better in general. - node.kind != DepKind::DefSpan && - task_deps.reads.iter().any(|&i| { - !(self.data[i].node.kind == DepKind::CrateMetadata || - self.data[i].node.kind == DepKind::Krate) - }) - { - bug!("Input node {:?} with unexpected reads: {:?}", - node, - task_deps.reads.iter().map(|&i| self.data[i].node).collect::>()) - } - } - self.alloc_node(node, task_deps.reads, fingerprint) } fn complete_anon_task(&mut self, kind: DepKind, task_deps: TaskDeps) -> DepNodeIndex { - debug_assert!(!kind.is_input()); + debug_assert!(!kind.is_eval_always()); let mut fingerprint = self.anon_id_seed; let mut hasher = StableHasher::new(); diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index d810a9310c55f..ba5ed12a0c084 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -153,7 +153,7 @@ impl Forest { &self.krate } - /// This is internally in the depedency tracking system. + /// This is used internally in the dependency tracking system. /// Use the `krate` method to ensure your dependency on the /// crate is tracked. pub fn untracked_krate<'hir>(&'hir self) -> &'hir Crate { diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index adac19d3410b2..0a9bcac760301 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -414,7 +414,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { return result; } - if !dep_node.kind.is_input() { + if !dep_node.kind.is_eval_always() { // The diagnostics for this query will be // promoted to the current session during // try_mark_green(), so we can ignore them here. @@ -601,9 +601,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { pub(super) fn ensure_query>(self, key: Q::Key) -> () { let dep_node = Q::to_dep_node(self, &key); - // Ensuring an "input" or anonymous query makes no sense + if dep_node.kind.is_eval_always() { + let _ = self.get_query::(DUMMY_SP, key); + return; + } + + // Ensuring an anonymous query makes no sense assert!(!dep_node.kind.is_anon()); - assert!(!dep_node.kind.is_input()); if self.dep_graph.try_mark_green_and_read(self, &dep_node).is_none() { // A None return from `try_mark_green_and_read` means that this is either // a new dep node or that the dep node has already been marked red.