Skip to content

Commit e3d6320

Browse files
committed
Only compute DefKind through the query.
1 parent 9a6fa4f commit e3d6320

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

compiler/rustc_middle/src/hir/map/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ impl<'hir> Map<'hir> {
225225
self.tcx.definitions_untracked().iter_local_def_id()
226226
}
227227

228-
pub fn opt_def_kind(self, local_def_id: LocalDefId) -> Option<DefKind> {
228+
/// Do not call this function directly. The query should be called.
229+
pub(super) fn opt_def_kind(self, local_def_id: LocalDefId) -> Option<DefKind> {
229230
let hir_id = self.local_def_id_to_hir_id(local_def_id);
230231
let def_kind = match self.find(hir_id)? {
231232
Node::Item(item) => match item.kind {

compiler/rustc_privacy/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ impl<'tcx> EmbargoVisitor<'tcx> {
467467
}
468468

469469
let macro_module_def_id = self.tcx.local_parent(local_def_id);
470-
if self.tcx.hir().opt_def_kind(macro_module_def_id) != Some(DefKind::Mod) {
470+
if self.tcx.opt_def_kind(macro_module_def_id) != Some(DefKind::Mod) {
471471
// The macro's parent doesn't correspond to a `mod`, return early (#63164, #65252).
472472
return;
473473
}

compiler/rustc_query_impl/src/plumbing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ macro_rules! define_queries {
291291
// accidentally triggering an infinite query loop.
292292
let def_kind = key.key_as_def_id()
293293
.and_then(|def_id| def_id.as_local())
294-
.and_then(|def_id| tcx.hir().opt_def_kind(def_id));
294+
.map(|def_id| tcx.def_kind(def_id));
295295
let hash = || {
296296
let mut hcx = tcx.create_stable_hashing_context();
297297
let mut hasher = StableHasher::new();

0 commit comments

Comments
 (0)