Auto merge of #80602 - tgnottingham:cratemetadata_you_aint_special, r=michaelwoerister

Remove DepKind::CrateMetadata and pre-allocation of DepNodes

Remove much of the special-case handling around crate metadata
dependency tracking by replacing `DepKind::CrateMetadata` and the
pre-allocation of corresponding `DepNodes` with on-demand invocation
of the `crate_hash` query.
This commit is contained in:
bors
2021-01-15 21:13:35 +00:00
10 changed files with 15 additions and 107 deletions

View File

@@ -207,17 +207,6 @@ pub mod dep_kind {
try_load_from_on_disk_cache: |_, _| {},
};
// Represents metadata from an extern crate.
pub const CrateMetadata: DepKindStruct = DepKindStruct {
has_params: true,
is_anon: false,
is_eval_always: true,
can_reconstruct_query_key: || true,
force_from_dep_node: |_, dep_node| bug!("force_from_dep_node: encountered {:?}", dep_node),
try_load_from_on_disk_cache: |_, _| {},
};
pub const TraitSelect: DepKindStruct = DepKindStruct {
has_params: false,
is_anon: true,
@@ -353,9 +342,6 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
// We use this for most things when incr. comp. is turned off.
[] Null,
// Represents metadata from an extern crate.
[eval_always] CrateMetadata(CrateNum),
[anon] TraitSelect,
// WARNING: if `Symbol` is changed, make sure you update `make_compile_codegen_unit` below.

View File

@@ -116,20 +116,9 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
// be removed. https://github.com/rust-lang/rust/issues/62649 is one such
// bug that must be fixed before removing this.
match dep_node.kind {
DepKind::hir_owner | DepKind::hir_owner_nodes | DepKind::CrateMetadata => {
DepKind::hir_owner | DepKind::hir_owner_nodes => {
if let Some(def_id) = dep_node.extract_def_id(*self) {
if def_id_corresponds_to_hir_dep_node(*self, def_id.expect_local()) {
if dep_node.kind == DepKind::CrateMetadata {
// The `DefPath` has corresponding node,
// and that node should have been marked
// either red or green in `data.colors`.
bug!(
"DepNode {:?} should have been \
pre-marked as red or green but wasn't.",
dep_node
);
}
} else {
if !def_id_corresponds_to_hir_dep_node(*self, def_id.expect_local()) {
// This `DefPath` does not have a
// corresponding `DepNode` (e.g. a
// struct field), and the ` DefPath`