Skip to content

Commit

Permalink
Auto merge of #68944 - Zoxc:hir-map, r=<try>
Browse files Browse the repository at this point in the history
[WIP] Use queries for the HIR map

r? @eddyb cc @michaelwoerister
  • Loading branch information
bors committed Feb 8, 2020
2 parents 8498c5f + 81fc1bd commit 534242c
Show file tree
Hide file tree
Showing 39 changed files with 567 additions and 621 deletions.
6 changes: 6 additions & 0 deletions src/librustc/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ macro_rules! arena_types {
[] type_binding: rustc_hir::TypeBinding<$tcx>,
[] variant: rustc_hir::Variant<$tcx>,
[] where_predicate: rustc_hir::WherePredicate<$tcx>,

// HIR query types
[few] hir_map: rustc::hir::map::Map<$tcx>,
[few] hir_definitions: rustc::hir::map::definitions::Definitions,
[] hir_owner: rustc::hir::HirOwner<$tcx>,
[] hir_owner_items: rustc::hir::HirOwnerItems<$tcx>,
], $tcx);
)
}
Expand Down
23 changes: 4 additions & 19 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
//! "infer" some properties for each kind of `DepNode`:
//!
//! * Whether a `DepNode` of a given kind has any parameters at all. Some
//! `DepNode`s, like `AllLocalTraitImpls`, represent global concepts with only one value.
//! `DepNode`s, like `?`, represent global concepts with only one value.
//! * Whether it is possible, in principle, to reconstruct a query key from a
//! given `DepNode`. Many `DepKind`s only require a single `DefId` parameter,
//! in which case it is possible to map the node's fingerprint back to the
Expand Down Expand Up @@ -276,8 +276,8 @@ macro_rules! define_dep_nodes {
/// Construct a DepNode from the given DepKind and DefPathHash. This
/// method will assert that the given DepKind actually requires a
/// single DefId/DefPathHash parameter.
pub fn from_def_path_hash(kind: DepKind,
def_path_hash: DefPathHash)
pub fn from_def_path_hash(def_path_hash: DefPathHash,
kind: DepKind)
-> DepNode {
debug_assert!(kind.can_reconstruct_query_key() && kind.has_params());
DepNode {
Expand Down Expand Up @@ -333,7 +333,7 @@ macro_rules! define_dep_nodes {
}

if kind.has_params() {
Ok(def_path_hash.to_dep_node(kind))
Ok(DepNode::from_def_path_hash(def_path_hash, kind))
} else {
Ok(DepNode::new_no_params(kind))
}
Expand Down Expand Up @@ -390,28 +390,13 @@ impl fmt::Debug for DepNode {
}
}

impl DefPathHash {
pub fn to_dep_node(self, kind: DepKind) -> DepNode {
DepNode::from_def_path_hash(kind, self)
}
}

rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
// We use this for most things when incr. comp. is turned off.
[] Null,

// Represents the body of a function or method. The def-id is that of the
// function/method.
[eval_always] HirBody(DefId),

// Represents the HIR node with the given node-id
[eval_always] Hir(DefId),

// Represents metadata from an extern crate.
[eval_always] CrateMetadata(CrateNum),

[eval_always] AllLocalTraitImpls,

[anon] TraitSelect,

[] CompileCodegenUnit(Symbol),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ impl DepGraph {
}
} else {
match dep_dep_node.kind {
DepKind::Hir | DepKind::HirBody | DepKind::CrateMetadata => {
DepKind::CrateMetadata => {
if let Some(def_id) = dep_dep_node.extract_def_id(tcx) {
if def_id_corresponds_to_hir_dep_node(tcx, def_id) {
// The `DefPath` has corresponding node,
Expand Down
Loading

0 comments on commit 534242c

Please sign in to comment.