|
98 | 98 | //! DefPaths which are much more robust in the face of changes to the code base.
|
99 | 99 |
|
100 | 100 | use rustc::middle::weak_lang_items;
|
| 101 | +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
101 | 102 | use rustc_mir::monomorphize::Instance;
|
102 | 103 | use rustc_mir::monomorphize::item::{MonoItem, MonoItemExt, InstantiationMode};
|
103 | 104 | use rustc::hir::def_id::{DefId, LOCAL_CRATE};
|
104 | 105 | use rustc::hir::map as hir_map;
|
| 106 | +use rustc::ich::NodeIdHashingMode; |
105 | 107 | use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
|
106 |
| -use rustc::ty::fold::TypeVisitor; |
107 | 108 | use rustc::ty::item_path::{self, ItemPathBuffer, RootMode};
|
108 | 109 | use rustc::ty::maps::Providers;
|
109 | 110 | use rustc::ty::subst::Substs;
|
@@ -144,31 +145,29 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
144 | 145 | -> u64 {
|
145 | 146 | debug!("get_symbol_hash(def_id={:?}, parameters={:?})", def_id, substs);
|
146 | 147 |
|
147 |
| - let mut hasher = ty::util::TypeIdHasher::<u64>::new(tcx); |
| 148 | + let mut hasher = StableHasher::<u64>::new(); |
| 149 | + let mut hcx = tcx.create_stable_hashing_context(); |
148 | 150 |
|
149 | 151 | record_time(&tcx.sess.perf_stats.symbol_hash_time, || {
|
150 | 152 | // the main symbol name is not necessarily unique; hash in the
|
151 | 153 | // compiler's internal def-path, guaranteeing each symbol has a
|
152 | 154 | // truly unique path
|
153 |
| - hasher.hash(tcx.def_path_hash(def_id)); |
| 155 | + tcx.def_path_hash(def_id).hash_stable(&mut hcx, &mut hasher); |
154 | 156 |
|
155 | 157 | // Include the main item-type. Note that, in this case, the
|
156 | 158 | // assertions about `needs_subst` may not hold, but this item-type
|
157 | 159 | // ought to be the same for every reference anyway.
|
158 | 160 | assert!(!item_type.has_erasable_regions());
|
159 |
| - hasher.visit_ty(item_type); |
160 |
| - |
161 |
| - // If this is a function, we hash the signature as well. |
162 |
| - // This is not *strictly* needed, but it may help in some |
163 |
| - // situations, see the `run-make/a-b-a-linker-guard` test. |
164 |
| - if let ty::TyFnDef(..) = item_type.sty { |
165 |
| - item_type.fn_sig(tcx).visit_with(&mut hasher); |
166 |
| - } |
| 161 | + hcx.while_hashing_spans(false, |hcx| { |
| 162 | + hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| { |
| 163 | + item_type.hash_stable(hcx, &mut hasher); |
| 164 | + }); |
| 165 | + }); |
167 | 166 |
|
168 | 167 | // also include any type parameters (for generic items)
|
169 | 168 | assert!(!substs.has_erasable_regions());
|
170 | 169 | assert!(!substs.needs_subst());
|
171 |
| - substs.visit_with(&mut hasher); |
| 170 | + substs.hash_stable(&mut hcx, &mut hasher); |
172 | 171 |
|
173 | 172 | let is_generic = substs.types().next().is_some();
|
174 | 173 | let avoid_cross_crate_conflicts =
|
@@ -207,8 +206,8 @@ fn get_symbol_hash<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
207 | 206 | LOCAL_CRATE
|
208 | 207 | };
|
209 | 208 |
|
210 |
| - hasher.hash(&tcx.original_crate_name(instantiating_crate).as_str()[..]); |
211 |
| - hasher.hash(&tcx.crate_disambiguator(instantiating_crate)); |
| 209 | + (&tcx.original_crate_name(instantiating_crate).as_str()[..]).hash_stable(&mut hcx, &mut hasher); |
| 210 | + (&tcx.crate_disambiguator(instantiating_crate)).hash_stable(&mut hcx, &mut hasher); |
212 | 211 | }
|
213 | 212 | });
|
214 | 213 |
|
|
0 commit comments