diff --git a/compiler/rustc_resolve/src/rustdoc.rs b/compiler/rustc_resolve/src/rustdoc.rs
index d1c1b6c882eaa..02e255d7726d1 100644
--- a/compiler/rustc_resolve/src/rustdoc.rs
+++ b/compiler/rustc_resolve/src/rustdoc.rs
@@ -6,7 +6,7 @@ use pulldown_cmark::{
};
use rustc_ast as ast;
use rustc_ast::util::comments::beautify_doc_string;
-use rustc_data_structures::fx::FxHashMap;
+use rustc_data_structures::fx::FxIndexMap;
use rustc_middle::ty::TyCtxt;
use rustc_span::def_id::DefId;
use rustc_span::symbol::{Symbol, kw, sym};
@@ -235,8 +235,8 @@ fn span_for_value(attr: &ast::Attribute) -> Span {
/// early and late doc link resolution regardless of their position.
pub fn prepare_to_doc_link_resolution(
doc_fragments: &[DocFragment],
-) -> FxHashMap, String> {
- let mut res = FxHashMap::default();
+) -> FxIndexMap , String> {
+ let mut res = FxIndexMap::default();
for fragment in doc_fragments {
let out_str = res.entry(fragment.item_id).or_default();
add_doc_fragment(out_str, fragment);
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index ec31a51a81e2d..ea4388b305b36 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -9,7 +9,7 @@ use rustc_ast::NestedMetaItem;
use rustc_ast_pretty::pprust;
use rustc_attr::{ConstStability, Deprecation, Stability, StableSince};
use rustc_const_eval::const_eval::is_unstable_const_fn;
-use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
use rustc_hir::def::{CtorKind, DefKind, Res};
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId};
use rustc_hir::lang_items::LangItem;
@@ -114,7 +114,7 @@ impl From for ItemId {
pub(crate) struct Crate {
pub(crate) module: Item,
/// Only here so that they can be filtered through the rustdoc passes.
- pub(crate) external_traits: Box>,
+ pub(crate) external_traits: Box>,
}
impl Crate {
@@ -1223,7 +1223,7 @@ impl Attributes {
}
pub(crate) fn get_doc_aliases(&self) -> Box<[Symbol]> {
- let mut aliases = FxHashSet::default();
+ let mut aliases = FxIndexSet::default();
for attr in self.other_attrs.lists(sym::doc).filter(|a| a.has_name(sym::alias)) {
if let Some(values) = attr.meta_item_list() {
@@ -1759,7 +1759,7 @@ pub(crate) enum PrimitiveType {
Never,
}
-type SimplifiedTypes = FxHashMap>;
+type SimplifiedTypes = FxIndexMap>;
impl PrimitiveType {
pub(crate) fn from_hir(prim: hir::PrimTy) -> PrimitiveType {
use ast::{FloatTy, IntTy, UintTy};
@@ -1927,10 +1927,10 @@ impl PrimitiveType {
/// In particular, if a crate depends on both `std` and another crate that also defines
/// `rustc_doc_primitive`, then it's entirely random whether `std` or the other crate is picked.
/// (no_std crates are usually fine unless multiple dependencies define a primitive.)
- pub(crate) fn primitive_locations(tcx: TyCtxt<'_>) -> &FxHashMap {
- static PRIMITIVE_LOCATIONS: OnceCell> = OnceCell::new();
+ pub(crate) fn primitive_locations(tcx: TyCtxt<'_>) -> &FxIndexMap {
+ static PRIMITIVE_LOCATIONS: OnceCell> = OnceCell::new();
PRIMITIVE_LOCATIONS.get_or_init(|| {
- let mut primitive_locations = FxHashMap::default();
+ let mut primitive_locations = FxIndexMap::default();
// NOTE: technically this misses crates that are only passed with `--extern` and not loaded when checking the crate.
// This is a degenerate case that I don't plan to support.
for &crate_num in tcx.crates(()) {
@@ -2460,7 +2460,7 @@ pub(crate) struct Impl {
}
impl Impl {
- pub(crate) fn provided_trait_methods(&self, tcx: TyCtxt<'_>) -> FxHashSet {
+ pub(crate) fn provided_trait_methods(&self, tcx: TyCtxt<'_>) -> FxIndexSet {
self.trait_
.as_ref()
.map(|t| t.def_id())
diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs
index 7a37f5c70a592..2cd69474b1cf0 100644
--- a/src/librustdoc/config.rs
+++ b/src/librustdoc/config.rs
@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::{fmt, io};
-use rustc_data_structures::fx::FxHashMap;
+use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::DiagCtxtHandle;
use rustc_session::config::{
self, CodegenOptions, CrateType, ErrorOutputType, Externs, Input, JsonUnusedExterns,
@@ -249,7 +249,7 @@ pub(crate) struct RenderOptions {
pub(crate) extern_html_root_takes_precedence: bool,
/// A map of the default settings (values are as for DOM storage API). Keys should lack the
/// `rustdoc-` prefix.
- pub(crate) default_settings: FxHashMap,
+ pub(crate) default_settings: FxIndexMap,
/// If present, suffix added to CSS/JavaScript files when referencing them in generated pages.
pub(crate) resource_suffix: String,
/// Whether to create an index page in the root of the output directory. If this is true but
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index 4c48c075a944d..aaf4c80f99763 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -2,7 +2,7 @@ use std::sync::atomic::AtomicBool;
use std::sync::{Arc, LazyLock};
use std::{io, mem};
-use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::unord::UnordSet;
use rustc_errors::codes::*;
@@ -39,7 +39,7 @@ pub(crate) struct DocContext<'tcx> {
/// Most of this logic is copied from rustc_lint::late.
pub(crate) param_env: ParamEnv<'tcx>,
/// Later on moved through `clean::Crate` into `cache`
- pub(crate) external_traits: FxHashMap,
+ pub(crate) external_traits: FxIndexMap,
/// Used while populating `external_traits` to ensure we don't process the same trait twice at
/// the same time.
pub(crate) active_extern_traits: DefIdSet,
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs
index 4e7571a480380..d5bc2a93fa807 100644
--- a/src/librustdoc/doctest.rs
+++ b/src/librustdoc/doctest.rs
@@ -14,7 +14,7 @@ use std::{panic, str};
pub(crate) use make::DocTestBuilder;
pub(crate) use markdown::test as test_markdown;
use rustc_ast as ast;
-use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
use rustc_errors::{ColorConfig, DiagCtxtHandle, ErrorGuaranteed, FatalError};
use rustc_hir::CRATE_HIR_ID;
use rustc_hir::def_id::LOCAL_CRATE;
@@ -213,12 +213,13 @@ pub(crate) fn run(
let unused_extern_reports: Vec<_> =
std::mem::take(&mut unused_extern_reports.lock().unwrap());
if unused_extern_reports.len() == compiling_test_count {
- let extern_names = externs.iter().map(|(name, _)| name).collect::>();
+ let extern_names =
+ externs.iter().map(|(name, _)| name).collect::>();
let mut unused_extern_names = unused_extern_reports
.iter()
- .map(|uexts| uexts.unused_extern_names.iter().collect::>())
+ .map(|uexts| uexts.unused_extern_names.iter().collect::>())
.fold(extern_names, |uextsa, uextsb| {
- uextsa.intersection(&uextsb).copied().collect::>()
+ uextsa.intersection(&uextsb).copied().collect::>()
})
.iter()
.map(|v| (*v).clone())
@@ -253,7 +254,7 @@ pub(crate) fn run_tests(
rustdoc_options: &Arc,
unused_extern_reports: &Arc>>,
mut standalone_tests: Vec,
- mergeable_tests: FxHashMap>,
+ mergeable_tests: FxIndexMap>,
) {
let mut test_args = Vec::with_capacity(rustdoc_options.test_args.len() + 1);
test_args.insert(0, "rustdoctest".to_string());
@@ -775,7 +776,7 @@ pub(crate) trait DocTestVisitor {
struct CreateRunnableDocTests {
standalone_tests: Vec,
- mergeable_tests: FxHashMap>,
+ mergeable_tests: FxIndexMap>,
rustdoc_options: Arc,
opts: GlobalTestOptions,
@@ -790,7 +791,7 @@ impl CreateRunnableDocTests {
let can_merge_doctests = rustdoc_options.edition >= Edition::Edition2024;
CreateRunnableDocTests {
standalone_tests: Vec::new(),
- mergeable_tests: FxHashMap::default(),
+ mergeable_tests: FxIndexMap::default(),
rustdoc_options: Arc::new(rustdoc_options),
opts,
visited_tests: FxHashMap::default(),
diff --git a/src/librustdoc/doctest/runner.rs b/src/librustdoc/doctest/runner.rs
index 326ca4ee1e68f..942ec8d9936cf 100644
--- a/src/librustdoc/doctest/runner.rs
+++ b/src/librustdoc/doctest/runner.rs
@@ -1,6 +1,6 @@
use std::fmt::Write;
-use rustc_data_structures::fx::FxHashSet;
+use rustc_data_structures::fx::FxIndexSet;
use rustc_span::edition::Edition;
use crate::doctest::{
@@ -11,7 +11,7 @@ use crate::html::markdown::{Ignore, LangString};
/// Convenient type to merge compatible doctests into one.
pub(crate) struct DocTestRunner {
- crate_attrs: FxHashSet,
+ crate_attrs: FxIndexSet,
ids: String,
output: String,
supports_color: bool,
@@ -21,7 +21,7 @@ pub(crate) struct DocTestRunner {
impl DocTestRunner {
pub(crate) fn new() -> Self {
Self {
- crate_attrs: FxHashSet::default(),
+ crate_attrs: FxIndexSet::default(),
ids: String::new(),
output: String::new(),
supports_color: true,
diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs
index db1a0bd0af938..ff0d537b19f75 100644
--- a/src/librustdoc/formats/cache.rs
+++ b/src/librustdoc/formats/cache.rs
@@ -1,6 +1,6 @@
use std::mem;
-use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
+use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet};
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::Symbol;
@@ -42,7 +42,7 @@ pub(crate) struct Cache {
/// URLs when a type is being linked to. External paths are not located in
/// this map because the `External` type itself has all the information
/// necessary.
- pub(crate) paths: FxHashMap, ItemType)>,
+ pub(crate) paths: FxIndexMap, ItemType)>,
/// Similar to `paths`, but only holds external paths. This is only used for
/// generating explicit hyperlinks to other crates.
@@ -64,18 +64,18 @@ pub(crate) struct Cache {
/// Implementations of a crate should inherit the documentation of the
/// parent trait if no extra documentation is specified, and default methods
/// should show up in documentation about trait implementations.
- pub(crate) traits: FxHashMap,
+ pub(crate) traits: FxIndexMap,
/// When rendering traits, it's often useful to be able to list all
/// implementors of the trait, and this mapping is exactly, that: a mapping
/// of trait ids to the list of known implementors of the trait
- pub(crate) implementors: FxHashMap>,
+ pub(crate) implementors: FxIndexMap>,
/// Cache of where external crate documentation can be found.
- pub(crate) extern_locations: FxHashMap,
+ pub(crate) extern_locations: FxIndexMap,
/// Cache of where documentation for primitives can be found.
- pub(crate) primitive_locations: FxHashMap,
+ pub(crate) primitive_locations: FxIndexMap,
// Note that external items for which `doc(hidden)` applies to are shown as
// non-reachable while local items aren't. This is because we're reusing
@@ -118,7 +118,7 @@ pub(crate) struct Cache {
// crawl. In order to prevent crashes when looking for notable traits or
// when gathering trait documentation on a type, hold impls here while
// folding and add them to the cache later on if we find the trait.
- orphan_trait_impls: Vec<(DefId, FxHashSet, Impl)>,
+ orphan_trait_impls: Vec<(DefId, FxIndexSet, Impl)>,
/// All intra-doc links resolved so far.
///
@@ -376,7 +376,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
// Figure out the id of this impl. This may map to a
// primitive rather than always to a struct/enum.
// Note: matching twice to restrict the lifetime of the `i` borrow.
- let mut dids = FxHashSet::default();
+ let mut dids = FxIndexSet::default();
match i.for_ {
clean::Type::Path { ref path }
| clean::BorrowedRef { type_: box clean::Type::Path { ref path }, .. } => {
diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs
index 69b3421f8881f..e7ddd4b73b47b 100644
--- a/src/librustdoc/html/highlight.rs
+++ b/src/librustdoc/html/highlight.rs
@@ -8,7 +8,7 @@
use std::collections::VecDeque;
use std::fmt::{Display, Write};
-use rustc_data_structures::fx::FxHashMap;
+use rustc_data_structures::fx::FxIndexMap;
use rustc_lexer::{Cursor, LiteralKind, TokenKind};
use rustc_span::edition::Edition;
use rustc_span::symbol::Symbol;
@@ -34,7 +34,7 @@ pub(crate) struct HrefContext<'a, 'tcx> {
/// Decorations are represented as a map from CSS class to vector of character ranges.
/// Each range will be wrapped in a span with that class.
#[derive(Default)]
-pub(crate) struct DecorationInfo(pub(crate) FxHashMap<&'static str, Vec<(u32, u32)>>);
+pub(crate) struct DecorationInfo(pub(crate) FxIndexMap<&'static str, Vec<(u32, u32)>>);
#[derive(Eq, PartialEq, Clone, Copy)]
pub(crate) enum Tooltip {
diff --git a/src/librustdoc/html/highlight/tests.rs b/src/librustdoc/html/highlight/tests.rs
index 75328e724fea8..fd5275189d661 100644
--- a/src/librustdoc/html/highlight/tests.rs
+++ b/src/librustdoc/html/highlight/tests.rs
@@ -1,5 +1,5 @@
use expect_test::expect_file;
-use rustc_data_structures::fx::FxHashMap;
+use rustc_data_structures::fx::FxIndexMap;
use rustc_span::create_default_session_globals_then;
use super::{DecorationInfo, write_code};
@@ -73,7 +73,7 @@ fn test_decorations() {
let y = 2;
let z = 3;
let a = 4;";
- let mut decorations = FxHashMap::default();
+ let mut decorations = FxIndexMap::default();
decorations.insert("example", vec![(0, 10), (11, 21)]);
decorations.insert("example2", vec![(22, 32)]);
diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs
index 3684dc42ac73c..31ccfeb38738c 100644
--- a/src/librustdoc/html/layout.rs
+++ b/src/librustdoc/html/layout.rs
@@ -1,7 +1,7 @@
use std::path::PathBuf;
use rinja::Template;
-use rustc_data_structures::fx::FxHashMap;
+use rustc_data_structures::fx::FxIndexMap;
use super::static_files::{STATIC_FILES, StaticFiles};
use crate::externalfiles::ExternalHtml;
@@ -13,7 +13,7 @@ pub(crate) struct Layout {
pub(crate) logo: String,
pub(crate) favicon: String,
pub(crate) external_html: ExternalHtml,
- pub(crate) default_settings: FxHashMap,
+ pub(crate) default_settings: FxIndexMap,
pub(crate) krate: String,
pub(crate) krate_version: String,
/// The given user css file which allow to customize the generated
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 8ae5484feda7a..6c5c58754a88f 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -38,7 +38,7 @@ use pulldown_cmark::{
BrokenLink, BrokenLinkCallback, CodeBlockKind, CowStr, Event, LinkType, OffsetIter, Options,
Parser, Tag, TagEnd, html,
};
-use rustc_data_structures::fx::FxHashMap;
+use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_errors::{Diag, DiagMessage};
use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::TyCtxt;
@@ -651,12 +651,12 @@ impl<'a, I: Iterator- >> Iterator for SummaryLine<'a, I> {
/// references.
struct Footnotes<'a, I> {
inner: I,
- footnotes: FxHashMap
>, u16)>,
+ footnotes: FxIndexMap>, u16)>,
}
impl<'a, I> Footnotes<'a, I> {
fn new(iter: I) -> Self {
- Footnotes { inner: iter, footnotes: FxHashMap::default() }
+ Footnotes { inner: iter, footnotes: FxIndexMap::default() }
}
fn get_entry(&mut self, key: &str) -> &mut (Vec>, u16) {
@@ -694,7 +694,7 @@ impl<'a, I: Iterator- >> Iterator for Footnotes<'a, I> {
Some(e) => return Some(e),
None => {
if !self.footnotes.is_empty() {
- let mut v: Vec<_> = self.footnotes.drain().map(|(_, x)| x).collect();
+ let mut v: Vec<_> = self.footnotes.drain(..).map(|(_, x)| x).collect();
v.sort_by(|a, b| a.1.cmp(&b.1));
let mut ret = String::from("