Skip to content

Commit 45ebd58

Browse files
committed
Auto merge of #68944 - Zoxc:hir-map, r=eddyb
Use queries for the HIR map r? @eddyb cc @michaelwoerister
2 parents e0f5df0 + 14fdd85 commit 45ebd58

File tree

108 files changed

+1526
-1626
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1526
-1626
lines changed

src/librustc/arena.rs

+6
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ macro_rules! arena_types {
161161
[] type_binding: rustc_hir::TypeBinding<$tcx>,
162162
[] variant: rustc_hir::Variant<$tcx>,
163163
[] where_predicate: rustc_hir::WherePredicate<$tcx>,
164+
165+
// HIR query types
166+
[few] indexed_hir: rustc::hir::map::IndexedHir<$tcx>,
167+
[few] hir_definitions: rustc::hir::map::definitions::Definitions,
168+
[] hir_owner: rustc::hir::HirOwner<$tcx>,
169+
[] hir_owner_items: rustc::hir::HirOwnerItems<$tcx>,
164170
], $tcx);
165171
)
166172
}

src/librustc/dep_graph/dep_node.rs

+4-19
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
//! "infer" some properties for each kind of `DepNode`:
3636
//!
3737
//! * Whether a `DepNode` of a given kind has any parameters at all. Some
38-
//! `DepNode`s, like `AllLocalTraitImpls`, represent global concepts with only one value.
38+
//! `DepNode`s could represent global concepts with only one value.
3939
//! * Whether it is possible, in principle, to reconstruct a query key from a
4040
//! given `DepNode`. Many `DepKind`s only require a single `DefId` parameter,
4141
//! in which case it is possible to map the node's fingerprint back to the
@@ -223,8 +223,8 @@ macro_rules! define_dep_nodes {
223223
/// Construct a DepNode from the given DepKind and DefPathHash. This
224224
/// method will assert that the given DepKind actually requires a
225225
/// single DefId/DefPathHash parameter.
226-
pub fn from_def_path_hash(kind: DepKind,
227-
def_path_hash: DefPathHash)
226+
pub fn from_def_path_hash(def_path_hash: DefPathHash,
227+
kind: DepKind)
228228
-> DepNode {
229229
debug_assert!(kind.can_reconstruct_query_key() && kind.has_params());
230230
DepNode {
@@ -280,7 +280,7 @@ macro_rules! define_dep_nodes {
280280
}
281281

282282
if kind.has_params() {
283-
Ok(def_path_hash.to_dep_node(kind))
283+
Ok(DepNode::from_def_path_hash(def_path_hash, kind))
284284
} else {
285285
Ok(DepNode::new_no_params(kind))
286286
}
@@ -337,28 +337,13 @@ impl fmt::Debug for DepNode {
337337
}
338338
}
339339

340-
impl DefPathHash {
341-
pub fn to_dep_node(self, kind: DepKind) -> DepNode {
342-
DepNode::from_def_path_hash(kind, self)
343-
}
344-
}
345-
346340
rustc_dep_node_append!([define_dep_nodes!][ <'tcx>
347341
// We use this for most things when incr. comp. is turned off.
348342
[] Null,
349343

350-
// Represents the body of a function or method. The def-id is that of the
351-
// function/method.
352-
[eval_always] HirBody(DefId),
353-
354-
// Represents the HIR node with the given node-id
355-
[eval_always] Hir(DefId),
356-
357344
// Represents metadata from an extern crate.
358345
[eval_always] CrateMetadata(CrateNum),
359346

360-
[eval_always] AllLocalTraitImpls,
361-
362347
[anon] TraitSelect,
363348

364349
[] CompileCodegenUnit(Symbol),

src/librustc/dep_graph/graph.rs

+15-30
Original file line numberDiff line numberDiff line change
@@ -225,28 +225,6 @@ impl DepGraph {
225225
)
226226
}
227227

228-
/// Creates a new dep-graph input with value `input`
229-
pub fn input_task<'a, C, R>(&self, key: DepNode, cx: C, input: R) -> (R, DepNodeIndex)
230-
where
231-
C: DepGraphSafe + StableHashingContextProvider<'a>,
232-
R: for<'b> HashStable<StableHashingContext<'b>>,
233-
{
234-
fn identity_fn<C, A>(_: C, arg: A) -> A {
235-
arg
236-
}
237-
238-
self.with_task_impl(
239-
key,
240-
cx,
241-
input,
242-
true,
243-
identity_fn,
244-
|_| None,
245-
|data, key, fingerprint, _| data.alloc_node(key, SmallVec::new(), fingerprint),
246-
hash_result::<R>,
247-
)
248-
}
249-
250228
fn with_task_impl<'a, C, A, R>(
251229
&self,
252230
key: DepNode,
@@ -676,18 +654,25 @@ impl DepGraph {
676654
continue;
677655
}
678656
} else {
657+
// FIXME: This match is just a workaround for incremental bugs and should
658+
// be removed. https://github.com/rust-lang/rust/issues/62649 is one such
659+
// bug that must be fixed before removing this.
679660
match dep_dep_node.kind {
680-
DepKind::Hir | DepKind::HirBody | DepKind::CrateMetadata => {
661+
DepKind::hir_owner
662+
| DepKind::hir_owner_items
663+
| DepKind::CrateMetadata => {
681664
if let Some(def_id) = dep_dep_node.extract_def_id(tcx) {
682665
if def_id_corresponds_to_hir_dep_node(tcx, def_id) {
683-
// The `DefPath` has corresponding node,
684-
// and that node should have been marked
685-
// either red or green in `data.colors`.
686-
bug!(
687-
"DepNode {:?} should have been \
666+
if dep_dep_node.kind == DepKind::CrateMetadata {
667+
// The `DefPath` has corresponding node,
668+
// and that node should have been marked
669+
// either red or green in `data.colors`.
670+
bug!(
671+
"DepNode {:?} should have been \
688672
pre-marked as red or green but wasn't.",
689-
dep_dep_node
690-
);
673+
dep_dep_node
674+
);
675+
}
691676
} else {
692677
// This `DefPath` does not have a
693678
// corresponding `DepNode` (e.g. a

0 commit comments

Comments
 (0)