From b8138db0ffbb7d29e5af2482c6eb0ef4e117d4a3 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Fri, 8 Jul 2022 17:45:55 +0200 Subject: [PATCH] Use FxIndexMap instead of otherwise unused StableMap for WEAK_ITEMS_REFS. --- compiler/rustc_hir/src/lang_items.rs | 6 +++--- compiler/rustc_hir/src/weak_lang_items.rs | 6 +++--- compiler/rustc_passes/src/weak_lang_items.rs | 2 +- src/test/ui/extern-flag/empty-extern-arg.stderr | 4 ++-- src/test/ui/panic-handler/weak-lang-item.stderr | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index b0bfac8e1f5..13b3e954e1f 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -11,7 +11,7 @@ use crate::def_id::DefId; use crate::{MethodKind, Target}; use rustc_ast as ast; -use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_macros::HashStable_Generic; use rustc_span::symbol::{kw, sym, Symbol}; @@ -134,8 +134,8 @@ macro_rules! language_item_table { } /// A mapping from the name of the lang item to its order and the form it must be of. - pub static ITEM_REFS: LazyLock> = LazyLock::new(|| { - let mut item_refs = FxHashMap::default(); + pub static ITEM_REFS: LazyLock> = LazyLock::new(|| { + let mut item_refs = FxIndexMap::default(); $( item_refs.insert($module::$name, (LangItem::$variant as usize, $target)); )* item_refs }); diff --git a/compiler/rustc_hir/src/weak_lang_items.rs b/compiler/rustc_hir/src/weak_lang_items.rs index dad22725511..b6a85c0472e 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::stable_map::StableMap; +use rustc_data_structures::fx::FxIndexMap; use rustc_span::symbol::{sym, Symbol}; use std::sync::LazyLock; @@ -12,8 +12,8 @@ use std::sync::LazyLock; macro_rules! weak_lang_items { ($($name:ident, $item:ident, $sym:ident;)*) => ( -pub static WEAK_ITEMS_REFS: LazyLock> = LazyLock::new(|| { - let mut map = StableMap::default(); +pub static WEAK_ITEMS_REFS: LazyLock> = LazyLock::new(|| { + let mut map = FxIndexMap::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 3291be05807..c48b4ecf87a 100644 --- a/compiler/rustc_passes/src/weak_lang_items.rs +++ b/compiler/rustc_passes/src/weak_lang_items.rs @@ -68,7 +68,7 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) { } } - for (name, item) in WEAK_ITEMS_REFS.clone().into_sorted_vector().into_iter() { + for (name, &item) in WEAK_ITEMS_REFS.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"); diff --git a/src/test/ui/extern-flag/empty-extern-arg.stderr b/src/test/ui/extern-flag/empty-extern-arg.stderr index 39a66c08de0..54b5e66fc21 100644 --- a/src/test/ui/extern-flag/empty-extern-arg.stderr +++ b/src/test/ui/extern-flag/empty-extern-arg.stderr @@ -1,11 +1,11 @@ error: extern location for std does not exist: +error: `#[panic_handler]` function required, but not found + error: language item required, but not found: `eh_personality` | = note: this can occur when a binary crate with `#![no_std]` is compiled for a target where `eh_personality` is defined in the standard library = help: you may be able to compile for a target that doesn't need `eh_personality`, specify a target with `--target` or in `.cargo/config` -error: `#[panic_handler]` function required, but not found - error: aborting due to 3 previous errors diff --git a/src/test/ui/panic-handler/weak-lang-item.stderr b/src/test/ui/panic-handler/weak-lang-item.stderr index cc25f08e33a..202f3309d03 100644 --- a/src/test/ui/panic-handler/weak-lang-item.stderr +++ b/src/test/ui/panic-handler/weak-lang-item.stderr @@ -10,13 +10,13 @@ help: you can use `as` to change the binding name of the import LL | extern crate core as other_core; | +error: `#[panic_handler]` function required, but not found + error: language item required, but not found: `eh_personality` | = note: this can occur when a binary crate with `#![no_std]` is compiled for a target where `eh_personality` is defined in the standard library = help: you may be able to compile for a target that doesn't need `eh_personality`, specify a target with `--target` or in `.cargo/config` -error: `#[panic_handler]` function required, but not found - error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0259`.