Merge CrateDisambiguator into StableCrateId
This commit is contained in:
parent
d93b6a4598
commit
d0ec85d3fb
30 changed files with 125 additions and 207 deletions
|
@ -126,10 +126,9 @@ fn get_symbol_hash<'tcx>(
|
|||
substs.hash_stable(&mut hcx, &mut hasher);
|
||||
|
||||
if let Some(instantiating_crate) = instantiating_crate {
|
||||
tcx.original_crate_name(instantiating_crate)
|
||||
.as_str()
|
||||
tcx.def_path_hash(instantiating_crate.as_def_id())
|
||||
.stable_crate_id()
|
||||
.hash_stable(&mut hcx, &mut hasher);
|
||||
tcx.crate_disambiguator(instantiating_crate).hash_stable(&mut hcx, &mut hasher);
|
||||
}
|
||||
|
||||
// We want to avoid accidental collision between different types of instances.
|
||||
|
|
|
@ -165,12 +165,12 @@ fn compute_symbol_name(
|
|||
// FIXME(eddyb) Precompute a custom symbol name based on attributes.
|
||||
let is_foreign = if let Some(def_id) = def_id.as_local() {
|
||||
if tcx.plugin_registrar_fn(()) == Some(def_id) {
|
||||
let disambiguator = tcx.sess.local_crate_disambiguator();
|
||||
return tcx.sess.generate_plugin_registrar_symbol(disambiguator);
|
||||
let stable_crate_id = tcx.sess.local_stable_crate_id();
|
||||
return tcx.sess.generate_plugin_registrar_symbol(stable_crate_id);
|
||||
}
|
||||
if tcx.proc_macro_decls_static(()) == Some(def_id) {
|
||||
let disambiguator = tcx.sess.local_crate_disambiguator();
|
||||
return tcx.sess.generate_proc_macro_decls_symbol(disambiguator);
|
||||
let stable_crate_id = tcx.sess.local_stable_crate_id();
|
||||
return tcx.sess.generate_proc_macro_decls_symbol(stable_crate_id);
|
||||
}
|
||||
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
|
||||
matches!(tcx.hir().get(hir_id), Node::ForeignItem(_))
|
||||
|
|
|
@ -592,8 +592,8 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
|
|||
|
||||
fn path_crate(mut self, cnum: CrateNum) -> Result<Self::Path, Self::Error> {
|
||||
self.push("C");
|
||||
let fingerprint = self.tcx.crate_disambiguator(cnum).to_fingerprint();
|
||||
self.push_disambiguator(fingerprint.to_smaller_hash());
|
||||
let stable_crate_id = self.tcx.def_path_hash(cnum.as_def_id()).stable_crate_id();
|
||||
self.push_disambiguator(stable_crate_id.to_u64());
|
||||
let name = self.tcx.original_crate_name(cnum).as_str();
|
||||
self.push_ident(&name);
|
||||
Ok(self)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue