Skip to content

Commit 78e2206

Browse files
committed
Auto merge of #81393 - pnkfelix:issue-81296-make-weak-item-traversal-deterministic, r=estebank
Make weak item traversal deterministic Fix #81296. (No test added. The relevant test *is* ui/panic-handler/weak-lang-item.rs, and this change should make it less flaky.)
2 parents d1aed50 + 4c5ede7 commit 78e2206

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

compiler/rustc_hir/src/weak_lang_items.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ use crate::def_id::DefId;
44
use crate::{lang_items, LangItem, LanguageItems};
55

66
use rustc_ast as ast;
7-
use rustc_data_structures::fx::FxHashMap;
7+
use rustc_data_structures::stable_map::StableMap;
88
use rustc_span::symbol::{sym, Symbol};
99

1010
use std::lazy::SyncLazy;
1111

1212
macro_rules! weak_lang_items {
1313
($($name:ident, $item:ident, $sym:ident;)*) => (
1414

15-
pub static WEAK_ITEMS_REFS: SyncLazy<FxHashMap<Symbol, LangItem>> = SyncLazy::new(|| {
16-
let mut map = FxHashMap::default();
15+
pub static WEAK_ITEMS_REFS: SyncLazy<StableMap<Symbol, LangItem>> = SyncLazy::new(|| {
16+
let mut map = StableMap::default();
1717
$(map.insert(sym::$name, LangItem::$item);)*
1818
map
1919
});

compiler/rustc_passes/src/weak_lang_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) {
5959
}
6060
}
6161

62-
for (name, &item) in WEAK_ITEMS_REFS.iter() {
62+
for (name, item) in WEAK_ITEMS_REFS.clone().into_sorted_vector().into_iter() {
6363
if missing.contains(&item) && required(tcx, item) && items.require(item).is_err() {
6464
if item == LangItem::PanicImpl {
6565
tcx.sess.err("`#[panic_handler]` function required, but not found");

0 commit comments

Comments
 (0)