Make iteration order of trimmed_def_paths query stable

This commit is contained in:
Michael Woerister 2023-12-21 12:27:04 +01:00
parent 36dd3d4524
commit 7d4f2ee817
2 changed files with 4 additions and 4 deletions

View File

@ -1791,7 +1791,7 @@ rustc_queries! {
}
/// Collects the "trimmed", shortest accessible paths to all items for diagnostics.
/// See the [provider docs](`rustc_middle::ty::print::trimmed_def_paths`) for more info.
query trimmed_def_paths(_: ()) -> &'tcx FxHashMap<DefId, Symbol> {
query trimmed_def_paths(_: ()) -> &'tcx DefIdMap<Symbol> {
arena_cache
desc { "calculating trimmed def paths" }
}

View File

@ -12,7 +12,7 @@ use rustc_apfloat::Float;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_hir as hir;
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
use rustc_hir::def_id::{DefIdSet, ModDefId, CRATE_DEF_ID, LOCAL_CRATE};
use rustc_hir::def_id::{DefIdMap, DefIdSet, ModDefId, CRATE_DEF_ID, LOCAL_CRATE};
use rustc_hir::definitions::{DefKey, DefPathDataName};
use rustc_hir::LangItem;
use rustc_session::config::TrimmedDefPaths;
@ -3049,8 +3049,8 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
///
/// See also [`DelayDm`](rustc_error_messages::DelayDm) and [`with_no_trimmed_paths!`].
// this is pub to be able to intra-doc-link it
pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> FxHashMap<DefId, Symbol> {
let mut map: FxHashMap<DefId, Symbol> = FxHashMap::default();
pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> DefIdMap<Symbol> {
let mut map: DefIdMap<Symbol> = Default::default();
if let TrimmedDefPaths::GoodPath = tcx.sess.opts.trimmed_def_paths {
// Trimming paths is expensive and not optimized, since we expect it to only be used for error reporting.