Skip to content

Commit 376a695

Browse files
Use FxIndexMap instead of otherwise unused StableMap for WEAK_ITEMS_REFS.
1 parent 0f97e02 commit 376a695

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

compiler/rustc_hir/src/lang_items.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::def_id::DefId;
1111
use crate::{MethodKind, Target};
1212

1313
use rustc_ast as ast;
14-
use rustc_data_structures::fx::FxHashMap;
14+
use rustc_data_structures::fx::FxIndexMap;
1515
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1616
use rustc_macros::HashStable_Generic;
1717
use rustc_span::symbol::{kw, sym, Symbol};
@@ -134,8 +134,8 @@ macro_rules! language_item_table {
134134
}
135135

136136
/// A mapping from the name of the lang item to its order and the form it must be of.
137-
pub static ITEM_REFS: LazyLock<FxHashMap<Symbol, (usize, Target)>> = LazyLock::new(|| {
138-
let mut item_refs = FxHashMap::default();
137+
pub static ITEM_REFS: LazyLock<FxIndexMap<Symbol, (usize, Target)>> = LazyLock::new(|| {
138+
let mut item_refs = FxIndexMap::default();
139139
$( item_refs.insert($module::$name, (LangItem::$variant as usize, $target)); )*
140140
item_refs
141141
});

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::stable_map::StableMap;
7+
use rustc_data_structures::fx::FxIndexMap;
88
use rustc_span::symbol::{sym, Symbol};
99

1010
use std::sync::LazyLock;
1111

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

15-
pub static WEAK_ITEMS_REFS: LazyLock<StableMap<Symbol, LangItem>> = LazyLock::new(|| {
16-
let mut map = StableMap::default();
15+
pub static WEAK_ITEMS_REFS: LazyLock<FxIndexMap<Symbol, LangItem>> = LazyLock::new(|| {
16+
let mut map = FxIndexMap::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
@@ -68,7 +68,7 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) {
6868
}
6969
}
7070

71-
for (name, item) in WEAK_ITEMS_REFS.clone().into_sorted_vector().into_iter() {
71+
for (name, &item) in WEAK_ITEMS_REFS.iter() {
7272
if missing.contains(&item) && required(tcx, item) && items.require(item).is_err() {
7373
if item == LangItem::PanicImpl {
7474
tcx.sess.err("`#[panic_handler]` function required, but not found");
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: extern location for std does not exist:
22

3+
error: `#[panic_handler]` function required, but not found
4+
35
error: language item required, but not found: `eh_personality`
46
|
57
= 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
68
= 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`
79

8-
error: `#[panic_handler]` function required, but not found
9-
1010
error: aborting due to 3 previous errors
1111

src/test/ui/panic-handler/weak-lang-item.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ help: you can use `as` to change the binding name of the import
1010
LL | extern crate core as other_core;
1111
|
1212

13+
error: `#[panic_handler]` function required, but not found
14+
1315
error: language item required, but not found: `eh_personality`
1416
|
1517
= 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
1618
= 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`
1719

18-
error: `#[panic_handler]` function required, but not found
19-
2020
error: aborting due to 3 previous errors
2121

2222
For more information about this error, try `rustc --explain E0259`.

0 commit comments

Comments
 (0)