Skip to content

Commit 0b38596

Browse files
committed
use ItemId.def_id and avoid fetching Item
1 parent f983d26 commit 0b38596

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,23 +1787,19 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
17871787
FxHashMap::default();
17881788

17891789
for id in tcx.hir().items() {
1790-
match tcx.hir().def_kind(id.def_id) {
1791-
DefKind::Impl => {
1792-
let item = tcx.hir().item(id);
1793-
if let Some(trait_ref) = tcx.impl_trait_ref(item.def_id.to_def_id()) {
1794-
let simplified_self_ty = fast_reject::simplify_type(
1795-
self.tcx,
1796-
trait_ref.self_ty(),
1797-
TreatParams::AsPlaceholders,
1798-
);
1799-
1800-
fx_hash_map
1801-
.entry(trait_ref.def_id)
1802-
.or_default()
1803-
.push((item.def_id.local_def_index, simplified_self_ty));
1804-
}
1790+
if matches!(tcx.hir().def_kind(id.def_id), DefKind::Impl) {
1791+
if let Some(trait_ref) = tcx.impl_trait_ref(id.def_id.to_def_id()) {
1792+
let simplified_self_ty = fast_reject::simplify_type(
1793+
self.tcx,
1794+
trait_ref.self_ty(),
1795+
TreatParams::AsPlaceholders,
1796+
);
1797+
1798+
fx_hash_map
1799+
.entry(trait_ref.def_id)
1800+
.or_default()
1801+
.push((id.def_id.local_def_index, simplified_self_ty));
18051802
}
1806-
_ => continue,
18071803
}
18081804
}
18091805

0 commit comments

Comments
 (0)