Auto merge of #86143 - bjorn3:revert_revert_merge_crate_disambiguator, r=michaelwoerister

Reland "Merge CrateDisambiguator into StableCrateId"

Reverts https://github.com/rust-lang/rust/pull/85891 as this revert of #85804 made perf even worse.

r? `@Mark-Simulacrum`
This commit is contained in:
bors
2021-07-06 11:31:59 +00:00
67 changed files with 227 additions and 298 deletions

View File

@@ -1299,30 +1299,34 @@ impl<'tcx> TyCtxt<'tcx> {
}
#[inline]
pub fn stable_crate_id(self, cnum: CrateNum) -> StableCrateId {
self.def_path_hash(cnum.as_def_id()).stable_crate_id()
pub fn stable_crate_id(self, crate_num: CrateNum) -> StableCrateId {
if crate_num == LOCAL_CRATE {
self.sess.local_stable_crate_id()
} else {
self.cstore.stable_crate_id_untracked(crate_num)
}
}
pub fn def_path_debug_str(self, def_id: DefId) -> String {
// We are explicitly not going through queries here in order to get
// crate name and disambiguator since this code is called from debug!()
// crate name and stable crate id since this code is called from debug!()
// statements within the query system and we'd run into endless
// recursion otherwise.
let (crate_name, crate_disambiguator) = if def_id.is_local() {
(self.crate_name, self.sess.local_crate_disambiguator())
let (crate_name, stable_crate_id) = if def_id.is_local() {
(self.crate_name, self.sess.local_stable_crate_id())
} else {
(
self.cstore.crate_name_untracked(def_id.krate),
self.cstore.crate_disambiguator_untracked(def_id.krate),
self.def_path_hash(def_id.krate.as_def_id()).stable_crate_id(),
)
};
format!(
"{}[{}]{}",
crate_name,
// Don't print the whole crate disambiguator. That's just
// Don't print the whole stable crate id. That's just
// annoying in debug output.
&(crate_disambiguator.to_fingerprint().to_hex())[..4],
&(format!("{:08x}", stable_crate_id.to_u64()))[..4],
self.def_path(def_id).to_string_no_crate_verbose()
)
}

View File

@@ -48,7 +48,6 @@ use rustc_index::{bit_set::FiniteBitSet, vec::IndexVec};
use rustc_serialize::opaque;
use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion};
use rustc_session::utils::NativeLibKind;
use rustc_session::CrateDisambiguator;
use rustc_session::Limits;
use rustc_target::spec::PanicStrategy;