Skip to content

Commit e7184d6

Browse files
committed
Avoid accessing the hir_crate query result from hir_walk_attributes
1 parent 947090d commit e7184d6

File tree

1 file changed

+3
-4
lines changed
  • compiler/rustc_middle/src/hir

1 file changed

+3
-4
lines changed

compiler/rustc_middle/src/hir/map.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
99
use rustc_data_structures::svh::Svh;
1010
use rustc_data_structures::sync::{DynSend, DynSync, par_for_each_in, try_par_for_each_in};
1111
use rustc_hir::def::{DefKind, Res};
12-
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId, LocalModDefId};
12+
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId, LocalModDefId};
1313
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
1414
use rustc_hir::intravisit::Visitor;
1515
use rustc_hir::*;
@@ -396,9 +396,8 @@ impl<'tcx> TyCtxt<'tcx> {
396396
where
397397
V: Visitor<'tcx>,
398398
{
399-
let krate = self.hir_crate(());
400-
for info in krate.owners.iter() {
401-
if let MaybeOwner::Owner(info) = info {
399+
for def_id in self.hir_crate_items(()).definitions().chain([CRATE_DEF_ID]) {
400+
if let MaybeOwner::Owner(info) = self.hir_owner(def_id) {
402401
for attrs in info.attrs.map.values() {
403402
walk_list!(visitor, visit_attribute, *attrs);
404403
}

0 commit comments

Comments
 (0)