Skip to content

Commit 974b1e3

Browse files
committed
Clarify the behaviour from inside the query system.
1 parent e3d6320 commit 974b1e3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

compiler/rustc_query_impl/src/plumbing.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,14 @@ macro_rules! define_queries {
287287
} else {
288288
Some(key.default_span(*tcx))
289289
};
290-
// Use `tcx.hir().opt_def_kind()` to reduce the chance of
291-
// accidentally triggering an infinite query loop.
292-
let def_kind = key.key_as_def_id()
293-
.and_then(|def_id| def_id.as_local())
294-
.map(|def_id| tcx.def_kind(def_id));
290+
let def_kind = if kind == dep_graph::DepKind::opt_def_kind {
291+
// Try to avoid infinite recursion.
292+
None
293+
} else {
294+
key.key_as_def_id()
295+
.and_then(|def_id| def_id.as_local())
296+
.and_then(|def_id| tcx.opt_def_kind(def_id))
297+
};
295298
let hash = || {
296299
let mut hcx = tcx.create_stable_hashing_context();
297300
let mut hasher = StableHasher::new();

0 commit comments

Comments
 (0)