rust/rust-pr94505-mono-item-sort-local.patch

35 lines
1.9 KiB
Diff
Raw Normal View History

2022-03-02 01:32:36 +00:00
diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs
index 892808386dee..13c325a14e40 100644
--- a/compiler/rustc_middle/src/mir/mono.rs
+++ b/compiler/rustc_middle/src/mir/mono.rs
@@ -7,6 +7,7 @@
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc_hir::ItemId;
+use rustc_index::vec::Idx;
use rustc_query_system::ich::{NodeIdHashingMode, StableHashingContext};
use rustc_session::config::OptLevel;
use rustc_span::source_map::Span;
@@ -380,7 +381,7 @@ fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>) -> ItemSortKey<'
// instances into account. The others don't matter for
// the codegen tests and can even make item order
// unstable.
- InstanceDef::Item(def) => Some(def.did.index.as_usize()),
+ InstanceDef::Item(def) => def.did.as_local().map(Idx::index),
InstanceDef::VtableShim(..)
| InstanceDef::ReifyShim(..)
| InstanceDef::Intrinsic(..)
@@ -391,10 +392,8 @@ fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>) -> ItemSortKey<'
| InstanceDef::CloneShim(..) => None,
}
}
- MonoItem::Static(def_id) => Some(def_id.index.as_usize()),
- MonoItem::GlobalAsm(item_id) => {
- Some(item_id.def_id.to_def_id().index.as_usize())
- }
+ MonoItem::Static(def_id) => def_id.as_local().map(Idx::index),
+ MonoItem::GlobalAsm(item_id) => Some(item_id.def_id.index()),
},
item.symbol_name(tcx),
)