From 4c5ede7c6a6b7ea37292d94aa79dc832d196f3fe Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 25 Jan 2021 14:37:27 -0500 Subject: [PATCH] This should address issue 81294. (No test added. The relevant test *is* ui/panic-handler/weak-lang-item.rs, and this change should make it less flaky.) --- compiler/rustc_hir/src/weak_lang_items.rs | 6 +++--- compiler/rustc_passes/src/weak_lang_items.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_hir/src/weak_lang_items.rs b/compiler/rustc_hir/src/weak_lang_items.rs index 52f28bf8f4c..b8cd15e7f00 100644 --- a/compiler/rustc_hir/src/weak_lang_items.rs +++ b/compiler/rustc_hir/src/weak_lang_items.rs @@ -4,7 +4,7 @@ use crate::def_id::DefId; use crate::{lang_items, LangItem, LanguageItems}; use rustc_ast as ast; -use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::stable_map::StableMap; use rustc_span::symbol::{sym, Symbol}; use std::lazy::SyncLazy; @@ -12,8 +12,8 @@ use std::lazy::SyncLazy; macro_rules! weak_lang_items { ($($name:ident, $item:ident, $sym:ident;)*) => ( -pub static WEAK_ITEMS_REFS: SyncLazy> = SyncLazy::new(|| { - let mut map = FxHashMap::default(); +pub static WEAK_ITEMS_REFS: SyncLazy> = SyncLazy::new(|| { + let mut map = StableMap::default(); $(map.insert(sym::$name, LangItem::$item);)* map }); diff --git a/compiler/rustc_passes/src/weak_lang_items.rs b/compiler/rustc_passes/src/weak_lang_items.rs index 4273d600004..daff94cb6d3 100644 --- a/compiler/rustc_passes/src/weak_lang_items.rs +++ b/compiler/rustc_passes/src/weak_lang_items.rs @@ -59,7 +59,7 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) { } } - for (name, &item) in WEAK_ITEMS_REFS.iter() { + for (name, item) in WEAK_ITEMS_REFS.clone().into_sorted_vector().into_iter() { if missing.contains(&item) && required(tcx, item) && items.require(item).is_err() { if item == LangItem::PanicImpl { tcx.sess.err("`#[panic_handler]` function required, but not found");