about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-03-03 01:09:14 +0100
committerGitHub <noreply@github.com>2022-03-03 01:09:14 +0100
commit3e6abf0c35da7e6906033ba6020af45f0dcab28d (patch)
tree68fbdd2ef71f78099564f1435f57b2ab66008e21 /compiler
parent293fa7a32bb8b55f6332f4563725a29bca08c385 (diff)
parent6a838e41bb9d8c24a621cb69efab4c99948fdcf1 (diff)
downloadrust-3e6abf0c35da7e6906033ba6020af45f0dcab28d.tar.gz
rust-3e6abf0c35da7e6906033ba6020af45f0dcab28d.zip
Rollup merge of #94505 - cuviper:mono-item-sort-local, r=michaelwoerister,davidtwco
Restore the local filter on mono item sorting

In `CodegenUnit::items_in_deterministic_order`, there's a comment that
only local HirIds should be taken into account, but #90408 removed the
`as_local` call that sets others to None. Restoring that check fixes the
s390x hangs seen in [RHBZ 2058803].

[RHBZ 2058803]: https://bugzilla.redhat.com/show_bug.cgi?id=2058803
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_middle/src/mir/mono.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs
index 892808386de..13c325a14e4 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::fx::FxHashMap;
 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 @@ impl<'tcx> CodegenUnit<'tcx> {
                             // 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 @@ impl<'tcx> CodegenUnit<'tcx> {
                             | 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),
             )