From a8c2332cc890ca73911ea0133457b10bf56aefdc Mon Sep 17 00:00:00 2001 From: iancormac84 Date: Tue, 8 May 2018 07:52:01 -0400 Subject: [PATCH 01/10] Removed use of TypeIdHasher in debuginfo and replaced it with StableHasher. Also corrected erroneous mention of TypeIdHasher in implementation of HashStable trait. --- src/librustc/ich/impls_ty.rs | 2 +- src/librustc_codegen_llvm/debuginfo/metadata.rs | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 31dce2a14c2b7..eb672e9ed4b97 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -132,7 +132,7 @@ for ty::RegionKind { ty::ReLateBound(..) | ty::ReVar(..) | ty::ReSkolemized(..) => { - bug!("TypeIdHasher: unexpected region {:?}", *self) + bug!("StableHasher: unexpected region {:?}", *self) } } } diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index ee60711c11d44..4a68ac35deaa0 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -26,9 +26,7 @@ use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor, use rustc::hir::CodegenFnAttrFlags; use rustc::hir::def::CtorKind; use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE}; -use rustc::ty::fold::TypeVisitor; -use rustc::ty::util::TypeIdHasher; -use rustc::ich::Fingerprint; +use rustc::ich::{Fingerprint, NodeIdHashingMode}; use rustc::ty::Instance; use common::CodegenCx; use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt}; @@ -144,9 +142,15 @@ impl<'tcx> TypeMap<'tcx> { // The hasher we are using to generate the UniqueTypeId. We want // something that provides more than the 64 bits of the DefaultHasher. - let mut type_id_hasher = TypeIdHasher::::new(cx.tcx); - type_id_hasher.visit_ty(type_); - let unique_type_id = type_id_hasher.finish().to_hex(); + let mut hasher = StableHasher::::new(); + let mut hcx = cx.tcx.create_stable_hashing_context(); + let type_ = cx.tcx.erase_regions(&type_); + hcx.while_hashing_spans(false, |hcx| { + hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| { + type_.hash_stable(hcx, &mut hasher); + }); + }); + let unique_type_id = hasher.finish().to_hex(); let key = self.unique_id_interner.intern(&unique_type_id); self.type_to_unique_id.insert(type_, UniqueTypeId(key)); From 9a746d5c1dad836c615e879b443dbf7ed73123e1 Mon Sep 17 00:00:00 2001 From: iancormac84 Date: Tue, 8 May 2018 07:58:33 -0400 Subject: [PATCH 02/10] Removed use of TypeIdHasher in symbol hash generation and replaced it with StableHasher. --- src/librustc_codegen_utils/symbol_names.rs | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 1a62f39ae3d8b..0afb2f7e54b49 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -98,12 +98,13 @@ //! DefPaths which are much more robust in the face of changes to the code base. use rustc::middle::weak_lang_items; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_mir::monomorphize::Instance; use rustc_mir::monomorphize::item::{MonoItem, MonoItemExt, InstantiationMode}; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::hir::map as hir_map; +use rustc::ich::NodeIdHashingMode; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; -use rustc::ty::fold::TypeVisitor; use rustc::ty::item_path::{self, ItemPathBuffer, RootMode}; use rustc::ty::maps::Providers; use rustc::ty::subst::Substs; @@ -144,31 +145,29 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, -> u64 { debug!("get_symbol_hash(def_id={:?}, parameters={:?})", def_id, substs); - let mut hasher = ty::util::TypeIdHasher::::new(tcx); + let mut hasher = StableHasher::::new(); + let mut hcx = tcx.create_stable_hashing_context(); record_time(&tcx.sess.perf_stats.symbol_hash_time, || { // the main symbol name is not necessarily unique; hash in the // compiler's internal def-path, guaranteeing each symbol has a // truly unique path - hasher.hash(tcx.def_path_hash(def_id)); + tcx.def_path_hash(def_id).hash_stable(&mut hcx, &mut hasher); // Include the main item-type. Note that, in this case, the // assertions about `needs_subst` may not hold, but this item-type // ought to be the same for every reference anyway. assert!(!item_type.has_erasable_regions()); - hasher.visit_ty(item_type); - - // If this is a function, we hash the signature as well. - // This is not *strictly* needed, but it may help in some - // situations, see the `run-make/a-b-a-linker-guard` test. - if let ty::TyFnDef(..) = item_type.sty { - item_type.fn_sig(tcx).visit_with(&mut hasher); - } + hcx.while_hashing_spans(false, |hcx| { + hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| { + item_type.hash_stable(hcx, &mut hasher); + }); + }); // also include any type parameters (for generic items) assert!(!substs.has_erasable_regions()); assert!(!substs.needs_subst()); - substs.visit_with(&mut hasher); + substs.hash_stable(&mut hcx, &mut hasher); let is_generic = substs.types().next().is_some(); let avoid_cross_crate_conflicts = @@ -207,8 +206,8 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, LOCAL_CRATE }; - hasher.hash(&tcx.original_crate_name(instantiating_crate).as_str()[..]); - hasher.hash(&tcx.crate_disambiguator(instantiating_crate)); + (&tcx.original_crate_name(instantiating_crate).as_str()[..]).hash_stable(&mut hcx, &mut hasher); + (&tcx.crate_disambiguator(instantiating_crate)).hash_stable(&mut hcx, &mut hasher); } }); From 659f164167221ccd9a686dab4fe22bddca471606 Mon Sep 17 00:00:00 2001 From: iancormac84 Date: Tue, 8 May 2018 09:23:36 -0400 Subject: [PATCH 03/10] Removed TypeIdHasher. --- src/librustc/ty/util.rs | 144 ---------------------------------------- 1 file changed, 144 deletions(-) diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index d5532f8f8355a..551825cc3545c 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -615,150 +615,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } -pub struct TypeIdHasher<'a, 'gcx: 'a+'tcx, 'tcx: 'a, W> { - tcx: TyCtxt<'a, 'gcx, 'tcx>, - state: StableHasher, -} - -impl<'a, 'gcx, 'tcx, W> TypeIdHasher<'a, 'gcx, 'tcx, W> - where W: StableHasherResult -{ - pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Self { - TypeIdHasher { tcx: tcx, state: StableHasher::new() } - } - - pub fn finish(self) -> W { - self.state.finish() - } - - pub fn hash(&mut self, x: T) { - x.hash(&mut self.state); - } - - fn hash_discriminant_u8(&mut self, x: &T) { - let v = unsafe { - intrinsics::discriminant_value(x) - }; - let b = v as u8; - assert_eq!(v, b as u64); - self.hash(b) - } - - fn def_id(&mut self, did: DefId) { - // Hash the DefPath corresponding to the DefId, which is independent - // of compiler internal state. We already have a stable hash value of - // all DefPaths available via tcx.def_path_hash(), so we just feed that - // into the hasher. - let hash = self.tcx.def_path_hash(did); - self.hash(hash); - } -} - -impl<'a, 'gcx, 'tcx, W> TypeVisitor<'tcx> for TypeIdHasher<'a, 'gcx, 'tcx, W> - where W: StableHasherResult -{ - fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool { - // Distinguish between the Ty variants uniformly. - self.hash_discriminant_u8(&ty.sty); - - match ty.sty { - TyInt(i) => self.hash(i), - TyUint(u) => self.hash(u), - TyFloat(f) => self.hash(f), - TyArray(_, n) => { - self.hash_discriminant_u8(&n.val); - match n.val { - ConstVal::Value(alloc) => self.hash(alloc), - ConstVal::Unevaluated(def_id, _) => self.def_id(def_id), - } - } - TyRawPtr(m) => self.hash(m.mutbl), - TyRef(_, _, mutbl) => self.hash(mutbl), - TyClosure(def_id, _) | - TyGenerator(def_id, _, _) | - TyAnon(def_id, _) | - TyFnDef(def_id, _) => self.def_id(def_id), - TyAdt(d, _) => self.def_id(d.did), - TyForeign(def_id) => self.def_id(def_id), - TyFnPtr(f) => { - self.hash(f.unsafety()); - self.hash(f.abi()); - self.hash(f.variadic()); - self.hash(f.inputs().skip_binder().len()); - } - TyDynamic(ref data, ..) => { - if let Some(p) = data.principal() { - self.def_id(p.def_id()); - } - for d in data.auto_traits() { - self.def_id(d); - } - } - TyGeneratorWitness(tys) => { - self.hash(tys.skip_binder().len()); - } - TyTuple(tys) => { - self.hash(tys.len()); - } - TyParam(p) => { - self.hash(p.idx); - self.hash(p.name); - } - TyProjection(ref data) => { - self.def_id(data.item_def_id); - } - TyNever | - TyBool | - TyChar | - TyStr | - TySlice(_) => {} - - TyError | - TyInfer(_) => bug!("TypeIdHasher: unexpected type {}", ty) - } - - ty.super_visit_with(self) - } - - fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool { - self.hash_discriminant_u8(r); - match *r { - ty::ReErased | - ty::ReStatic | - ty::ReEmpty => { - // No variant fields to hash for these ... - } - ty::ReCanonical(c) => { - self.hash(c); - } - ty::ReLateBound(db, ty::BrAnon(i)) => { - self.hash(db.depth); - self.hash(i); - } - ty::ReEarlyBound(ty::EarlyBoundRegion { def_id, .. }) => { - self.def_id(def_id); - } - - ty::ReClosureBound(..) | - ty::ReLateBound(..) | - ty::ReFree(..) | - ty::ReScope(..) | - ty::ReVar(..) | - ty::ReSkolemized(..) => { - bug!("TypeIdHasher: unexpected region {:?}", r) - } - } - false - } - - fn visit_binder>(&mut self, x: &ty::Binder) -> bool { - // Anonymize late-bound regions so that, for example: - // `for<'a, b> fn(&'a &'b T)` and `for<'a, b> fn(&'b &'a T)` - // result in the same TypeId (the two types are equivalent). - self.tcx.anonymize_late_bound_regions(x).super_visit_with(self) - } -} - impl<'a, 'tcx> ty::TyS<'tcx> { pub fn moves_by_default(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>, From 9041d81f7880d1dbd2beee601cbc46d2889f31e6 Mon Sep 17 00:00:00 2001 From: iancormac84 Date: Tue, 8 May 2018 09:38:29 -0400 Subject: [PATCH 04/10] Code structure edits. --- src/librustc_codegen_utils/symbol_names.rs | 118 +++++++++++---------- 1 file changed, 61 insertions(+), 57 deletions(-) diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 0afb2f7e54b49..8ddefdf474fb1 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -97,19 +97,19 @@ //! virtually impossible. Thus, symbol hash generation exclusively relies on //! DefPaths which are much more robust in the face of changes to the code base. -use rustc::middle::weak_lang_items; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; -use rustc_mir::monomorphize::Instance; -use rustc_mir::monomorphize::item::{MonoItem, MonoItemExt, InstantiationMode}; use rustc::hir::def_id::{DefId, LOCAL_CRATE}; use rustc::hir::map as hir_map; +use rustc::hir::map::definitions::DefPathData; use rustc::ich::NodeIdHashingMode; -use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; +use rustc::middle::weak_lang_items; use rustc::ty::item_path::{self, ItemPathBuffer, RootMode}; use rustc::ty::maps::Providers; use rustc::ty::subst::Substs; -use rustc::hir::map::definitions::DefPathData; +use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc::util::common::record_time; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_mir::monomorphize::item::{InstantiationMode, MonoItem, MonoItemExt}; +use rustc_mir::monomorphize::Instance; use syntax::attr; use syntax_pos::symbol::Symbol; @@ -125,25 +125,29 @@ pub fn provide(providers: &mut Providers) { }; } -fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, +fn get_symbol_hash<'a, 'tcx>( + tcx: TyCtxt<'a, 'tcx, 'tcx>, - // the DefId of the item this name is for - def_id: DefId, + // the DefId of the item this name is for + def_id: DefId, - // instance this name will be for - instance: Instance<'tcx>, + // instance this name will be for + instance: Instance<'tcx>, - // type of the item, without any generic - // parameters substituted; this is - // included in the hash as a kind of - // safeguard. - item_type: Ty<'tcx>, + // type of the item, without any generic + // parameters substituted; this is + // included in the hash as a kind of + // safeguard. + item_type: Ty<'tcx>, - // values for generic type parameters, - // if any. - substs: &'tcx Substs<'tcx>) - -> u64 { - debug!("get_symbol_hash(def_id={:?}, parameters={:?})", def_id, substs); + // values for generic type parameters, + // if any. + substs: &'tcx Substs<'tcx>, +) -> u64 { + debug!( + "get_symbol_hash(def_id={:?}, parameters={:?})", + def_id, substs + ); let mut hasher = StableHasher::::new(); let mut hcx = tcx.create_stable_hashing_context(); @@ -193,12 +197,11 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, if !def_id.is_local() && tcx.share_generics() { // If we are re-using a monomorphization from another crate, // we have to compute the symbol hash accordingly. - let upstream_monomorphizations = - tcx.upstream_monomorphizations_for(def_id); + let upstream_monomorphizations = tcx.upstream_monomorphizations_for(def_id); - upstream_monomorphizations.and_then(|monos| monos.get(&substs) - .cloned()) - .unwrap_or(LOCAL_CRATE) + upstream_monomorphizations + .and_then(|monos| monos.get(&substs).cloned()) + .unwrap_or(LOCAL_CRATE) } else { LOCAL_CRATE } @@ -206,7 +209,8 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, LOCAL_CRATE }; - (&tcx.original_crate_name(instantiating_crate).as_str()[..]).hash_stable(&mut hcx, &mut hasher); + (&tcx.original_crate_name(instantiating_crate).as_str()[..]) + .hash_stable(&mut hcx, &mut hasher); (&tcx.crate_disambiguator(instantiating_crate)).hash_stable(&mut hcx, &mut hasher); } }); @@ -215,9 +219,7 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hasher.finish() } -fn def_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) - -> ty::SymbolName -{ +fn def_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::SymbolName { let mut buffer = SymbolPathBuffer::new(); item_path::with_forced_absolute_paths(|| { tcx.push_item_path(&mut buffer, def_id); @@ -225,20 +227,17 @@ fn def_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) buffer.into_interned() } -fn symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance<'tcx>) - -> ty::SymbolName -{ - ty::SymbolName { name: Symbol::intern(&compute_symbol_name(tcx, instance)).as_interned_str() } +fn symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance<'tcx>) -> ty::SymbolName { + ty::SymbolName { + name: Symbol::intern(&compute_symbol_name(tcx, instance)).as_interned_str(), + } } -fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance<'tcx>) - -> String -{ +fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance<'tcx>) -> String { let def_id = instance.def_id(); let substs = instance.substs; - debug!("symbol_name(def_id={:?}, substs={:?})", - def_id, substs); + debug!("symbol_name(def_id={:?}, substs={:?})", def_id, substs); let node_id = tcx.hir.as_local_node_id(def_id); @@ -258,7 +257,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance let is_foreign = if let Some(id) = node_id { match tcx.hir.get(id) { hir_map::NodeForeignItem(_) => true, - _ => false + _ => false, } } else { tcx.is_foreign_item(def_id) @@ -295,8 +294,7 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance loop { let key = tcx.def_key(ty_def_id); match key.disambiguated_data.data { - DefPathData::TypeNs(_) | - DefPathData::ValueNs(_) => { + DefPathData::TypeNs(_) | DefPathData::ValueNs(_) => { instance_ty = tcx.type_of(ty_def_id); break; } @@ -305,8 +303,12 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance // to be a value or type-def or something in there // *somewhere* ty_def_id.index = key.parent.unwrap_or_else(|| { - bug!("finding type for {:?}, encountered def-id {:?} with no \ - parent", def_id, ty_def_id); + bug!( + "finding type for {:?}, encountered def-id {:?} with no \ + parent", + def_id, + ty_def_id + ); }); } } @@ -336,14 +338,14 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance // use C++ name-mangling. struct SymbolPathBuffer { result: String, - temp_buf: String + temp_buf: String, } impl SymbolPathBuffer { fn new() -> Self { let mut result = SymbolPathBuffer { result: String::with_capacity(64), - temp_buf: String::with_capacity(16) + temp_buf: String::with_capacity(16), }; result.result.push_str("_ZN"); // _Z == Begin name-sequence, N == nested result @@ -352,14 +354,16 @@ impl SymbolPathBuffer { fn from_interned(symbol: ty::SymbolName) -> Self { let mut result = SymbolPathBuffer { result: String::with_capacity(64), - temp_buf: String::with_capacity(16) + temp_buf: String::with_capacity(16), }; result.result.push_str(&symbol.name.as_str()); result } fn into_interned(self) -> ty::SymbolName { - ty::SymbolName { name: Symbol::intern(&self.result).as_interned_str() } + ty::SymbolName { + name: Symbol::intern(&self.result).as_interned_str(), + } } fn finish(mut self, hash: u64) -> String { @@ -378,7 +382,11 @@ impl ItemPathBuffer for SymbolPathBuffer { fn push(&mut self, text: &str) { self.temp_buf.clear(); let need_underscore = sanitize(&mut self.temp_buf, text); - let _ = write!(self.result, "{}", self.temp_buf.len() + (need_underscore as usize)); + let _ = write!( + self.result, + "{}", + self.temp_buf.len() + (need_underscore as usize) + ); if need_underscore { self.result.push('_'); } @@ -409,16 +417,13 @@ pub fn sanitize(result: &mut String, s: &str) -> bool { '-' | ':' => result.push('.'), // These are legal symbols - 'a' ... 'z' - | 'A' ... 'Z' - | '0' ... '9' - | '_' | '.' | '$' => result.push(c), + 'a'...'z' | 'A'...'Z' | '0'...'9' | '_' | '.' | '$' => result.push(c), _ => { result.push('$'); for c in c.escape_unicode().skip(1) { match c { - '{' => {}, + '{' => {} '}' => result.push('$'), c => result.push(c), } @@ -428,7 +433,6 @@ pub fn sanitize(result: &mut String, s: &str) -> bool { } // Underscore-qualify anything that didn't start as an ident. - !result.is_empty() && - result.as_bytes()[0] != '_' as u8 && - ! (result.as_bytes()[0] as char).is_xid_start() + !result.is_empty() && result.as_bytes()[0] != '_' as u8 + && !(result.as_bytes()[0] as char).is_xid_start() } From ef38712f87997b87d7ad1aca653d54b47877838a Mon Sep 17 00:00:00 2001 From: iancormac84 Date: Tue, 8 May 2018 10:02:41 -0400 Subject: [PATCH 05/10] Removed unused imports. --- src/librustc/ty/util.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 551825cc3545c..5a745eeab4b80 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -30,8 +30,6 @@ use rustc_data_structures::stable_hasher::{StableHasher, StableHasherResult, HashStable}; use rustc_data_structures::fx::FxHashMap; use std::{cmp, fmt}; -use std::hash::Hash; -use std::intrinsics; use syntax::ast; use syntax::attr::{self, SignedInt, UnsignedInt}; use syntax_pos::{Span, DUMMY_SP}; From 6131c0a98c8dc4739e7985940474f6ae5f0941c3 Mon Sep 17 00:00:00 2001 From: iancormac84 Date: Tue, 8 May 2018 10:58:32 -0400 Subject: [PATCH 06/10] Fix more unused imports errors. --- src/librustc/ty/util.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 5a745eeab4b80..53f82625951ce 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -26,8 +26,7 @@ use ty::layout::{Integer, IntegerExt}; use util::common::ErrorReported; use middle::lang_items; -use rustc_data_structures::stable_hasher::{StableHasher, StableHasherResult, - HashStable}; +use rustc_data_structures::stable_hasher::{StableHasher, HashStable}; use rustc_data_structures::fx::FxHashMap; use std::{cmp, fmt}; use syntax::ast; From b79edf008f3191e28d96ed98c77fa25533c650d7 Mon Sep 17 00:00:00 2001 From: iancormac84 Date: Tue, 8 May 2018 19:57:45 -0400 Subject: [PATCH 07/10] Added extra hashing step. --- src/librustc_codegen_utils/symbol_names.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 8ddefdf474fb1..2063db6dc5331 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -168,6 +168,13 @@ fn get_symbol_hash<'a, 'tcx>( }); }); + // If this is a function, we hash the signature as well. + // This is not *strictly* needed, but it may help in some + // situations, see the `run-make/a-b-a-linker-guard` test. + if let ty::TyFnDef(..) = item_type.sty { + item_type.fn_sig(tcx).hash_stable(&mut hcx, &mut hasher); + } + // also include any type parameters (for generic items) assert!(!substs.has_erasable_regions()); assert!(!substs.needs_subst()); From 18b032a96bcc68aa1d78aabb888b07a1fdbee3e6 Mon Sep 17 00:00:00 2001 From: iancormac84 Date: Tue, 15 May 2018 20:27:37 -0400 Subject: [PATCH 08/10] Removed unused import. --- src/librustc/ty/util.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 53f82625951ce..122cd0e707d35 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -15,7 +15,6 @@ use hir::def_id::DefId; use hir::map::{DefPathData, Node}; use hir; use ich::NodeIdHashingMode; -use middle::const_val::ConstVal; use traits::{self, ObligationCause}; use ty::{self, Ty, TyCtxt, GenericParamDefKind, TypeFoldable}; use ty::fold::TypeVisitor; From 1839faead079a0f1e0e44e54249567ca27230c1d Mon Sep 17 00:00:00 2001 From: iancormac84 Date: Wed, 16 May 2018 02:29:15 -0400 Subject: [PATCH 09/10] Removed yet another unused import. --- src/librustc/ty/util.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 122cd0e707d35..7cfcbcb86af98 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -17,7 +17,6 @@ use hir; use ich::NodeIdHashingMode; use traits::{self, ObligationCause}; use ty::{self, Ty, TyCtxt, GenericParamDefKind, TypeFoldable}; -use ty::fold::TypeVisitor; use ty::subst::{Substs, UnpackedKind}; use ty::maps::TyCtxtAt; use ty::TypeVariants::*; From 03493941fb5fa18d592da57530382f5c4b7cf2f9 Mon Sep 17 00:00:00 2001 From: iancormac84 Date: Thu, 17 May 2018 19:43:36 -0400 Subject: [PATCH 10/10] Fixed accidental removal of StableHasher declaration. --- src/librustc_codegen_llvm/debuginfo/metadata.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 4a68ac35deaa0..ae0f6067f4767 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -23,6 +23,7 @@ use llvm::{self, ValueRef}; use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor, DICompositeType, DILexicalBlock, DIFlags}; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc::hir::CodegenFnAttrFlags; use rustc::hir::def::CtorKind; use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};