Skip to content

Commit 1d919a2

Browse files
committed
Avoid accessing the hir_crate query result from hir_walk_attributes
1 parent a5a03f3 commit 1d919a2

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
@@ -5,7 +5,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
55
use rustc_data_structures::svh::Svh;
66
use rustc_data_structures::sync::{DynSend, DynSync, par_for_each_in, try_par_for_each_in};
77
use rustc_hir::def::{DefKind, Res};
8-
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId, LocalModDefId};
8+
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId, LocalModDefId};
99
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
1010
use rustc_hir::intravisit::Visitor;
1111
use rustc_hir::*;
@@ -405,9 +405,8 @@ impl<'tcx> TyCtxt<'tcx> {
405405
where
406406
V: Visitor<'tcx>,
407407
{
408-
let krate = self.hir_crate(());
409-
for info in krate.owners.iter() {
410-
if let MaybeOwner::Owner(info) = info {
408+
for def_id in self.hir_crate_items(()).definitions().chain([CRATE_DEF_ID]) {
409+
if let MaybeOwner::Owner(info) = self.hir_owner(def_id) {
411410
for attrs in info.attrs.map.values() {
412411
walk_list!(visitor, visit_attribute, *attrs);
413412
}

0 commit comments

Comments
 (0)