Skip to content

Commit 9a23196

Browse files
committed
rustc: Move stability functionality into queries
This commit primarily removes the `stability` field from `TyCtxt` as well as its internal mutable state, instead using a query to build the stability index as well as primarily using queries for other related lookups. Like previous commits the calculation of the stability index is wrapped in a `with_ignore` node to avoid regressing the current tests, and otherwise this commit also introduces #44232 but somewhat intentionally so.
1 parent 0182c8b commit 9a23196

File tree

12 files changed

+212
-202
lines changed

12 files changed

+212
-202
lines changed

src/librustc/dep_graph/dep_node.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,8 @@ define_dep_nodes!( <'tcx>
511511
[] ParamEnv(DefId),
512512
[] DescribeDef(DefId),
513513
[] DefSpan(DefId),
514-
[] Stability(DefId),
515-
[] Deprecation(DefId),
514+
[] LookupStability(DefId),
515+
[] LookupDeprecationEntry(DefId),
516516
[] ItemBodyNestedBodies(DefId),
517517
[] ConstIsRvaluePromotableToStatic(DefId),
518518
[] ImplParent(DefId),
@@ -573,6 +573,7 @@ define_dep_nodes!( <'tcx>
573573
[] Freevars(HirId),
574574
[] MaybeUnusedTraitImport(HirId),
575575
[] MaybeUnusedExternCrates,
576+
[] StabilityIndex,
576577
);
577578

578579
trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {

src/librustc/hir/map/mod.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,17 @@ impl<'hir> Map<'hir> {
878878

879879
Some(RootCrate(_)) => self.forest.krate.span,
880880
Some(NotPresent) | None => {
881-
bug!("hir::map::Map::span: id not in map: {:?}", id)
881+
// Some nodes, notably macro definitions, are not
882+
// present in the map for whatever reason, but
883+
// they *do* have def-ids. So if we encounter an
884+
// empty hole, check for that case.
885+
if let Some(def_index) = self.definitions.opt_def_index(id) {
886+
let def_path_hash = self.definitions.def_path_hash(def_index);
887+
self.dep_graph.read(def_path_hash.to_dep_node(DepKind::Hir));
888+
DUMMY_SP
889+
} else {
890+
bug!("hir::map::Map::span: id not in map: {:?}", id)
891+
}
882892
}
883893
}
884894
}

0 commit comments

Comments
 (0)