Skip to content

Commit 8c967d8

Browse files
committed
Use the TLS tcx instead of passing it into the StableHashContext
1 parent 3085789 commit 8c967d8

File tree

23 files changed

+333
-335
lines changed

23 files changed

+333
-335
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug {
657657
}
658658

659659
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a, T> DepNodeParams<'a, 'gcx, 'tcx> for T
660-
where T: HashStable<StableHashingContext<'a, 'gcx>> + fmt::Debug
660+
where T: HashStable<StableHashingContext<'a>> + fmt::Debug
661661
{
662662
default const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
663663

src/librustc/hir/map/collector.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub(super) struct NodeCollector<'a, 'hir> {
4141
dep_graph: &'a DepGraph,
4242
definitions: &'a definitions::Definitions,
4343

44-
hcx: StableHashingContext<'a, 'a>,
44+
hcx: StableHashingContext<'a>,
4545

4646
// We are collecting DepNode::HirBody hashes here so we can compute the
4747
// crate hash from then later on.
@@ -52,7 +52,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
5252
pub(super) fn root(krate: &'hir Crate,
5353
dep_graph: &'a DepGraph,
5454
definitions: &'a definitions::Definitions,
55-
hcx: StableHashingContext<'a, 'a>)
55+
hcx: StableHashingContext<'a>)
5656
-> NodeCollector<'a, 'hir> {
5757
let root_mod_def_path_hash = definitions.def_path_hash(CRATE_DEF_INDEX);
5858

@@ -235,7 +235,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
235235
self.parent_node = parent_node;
236236
}
237237

238-
fn with_dep_node_owner<T: HashStable<StableHashingContext<'a, 'a>>,
238+
fn with_dep_node_owner<T: HashStable<StableHashingContext<'a>>,
239239
F: FnOnce(&mut Self)>(&mut self,
240240
dep_node_owner: DefIndex,
241241
item_like: &T,
@@ -513,11 +513,11 @@ struct HirItemLike<T> {
513513
hash_bodies: bool,
514514
}
515515

516-
impl<'a, 'hir, T> HashStable<StableHashingContext<'a, 'hir>> for HirItemLike<T>
517-
where T: HashStable<StableHashingContext<'a, 'hir>>
516+
impl<'a, 'hir, T> HashStable<StableHashingContext<'hir>> for HirItemLike<T>
517+
where T: HashStable<StableHashingContext<'hir>>
518518
{
519519
fn hash_stable<W: StableHasherResult>(&self,
520-
hcx: &mut StableHashingContext<'a, 'hir>,
520+
hcx: &mut StableHashingContext<'hir>,
521521
hasher: &mut StableHasher<W>) {
522522
hcx.while_hashing_hir_bodies(self.hash_bodies, |hcx| {
523523
self.item_like.hash_stable(hcx, hasher);

src/librustc/hir/map/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ pub fn map_crate<'hir>(sess: &::session::Session,
10531053
definitions: &'hir Definitions)
10541054
-> Map<'hir> {
10551055
let (map, crate_hash) = {
1056-
let hcx = ::ich::StableHashingContext::new(sess, &forest.krate, definitions, cstore, None);
1056+
let hcx = ::ich::StableHashingContext::new(sess, &forest.krate, definitions, cstore);
10571057

10581058
let mut collector = NodeCollector::root(&forest.krate,
10591059
&forest.dep_graph,

src/librustc/ich/hcx.rs

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use hir::map::DefPathHash;
1414
use hir::map::definitions::Definitions;
1515
use ich::{self, CachingCodemapView, Fingerprint};
1616
use middle::cstore::CrateStore;
17-
use ty::{TyCtxt, fast_reject, InterpretInterner};
17+
use ty::{TyCtxt, fast_reject};
1818
use session::Session;
1919

2020
use std::cmp::Ord;
@@ -44,20 +44,19 @@ thread_local!(static IGNORED_ATTR_NAMES: RefCell<FxHashSet<Symbol>> =
4444
/// a reference to the TyCtxt) and it holds a few caches for speeding up various
4545
/// things (e.g. each DefId/DefPath is only hashed once).
4646
#[derive(Clone)]
47-
pub struct StableHashingContext<'a, 'gcx: 'a> {
48-
sess: &'gcx Session,
49-
definitions: &'gcx Definitions,
50-
cstore: &'gcx CrateStore,
51-
body_resolver: BodyResolver<'gcx>,
47+
pub struct StableHashingContext<'a> {
48+
sess: &'a Session,
49+
definitions: &'a Definitions,
50+
cstore: &'a CrateStore,
51+
body_resolver: BodyResolver<'a>,
5252
hash_spans: bool,
5353
hash_bodies: bool,
5454
node_id_hashing_mode: NodeIdHashingMode,
55-
pub interpret_interner: Option<&'a RefCell<InterpretInterner<'gcx>>>,
5655

5756
// Very often, we are hashing something that does not need the
5857
// CachingCodemapView, so we initialize it lazily.
59-
raw_codemap: &'gcx CodeMap,
60-
caching_codemap: Option<CachingCodemapView<'gcx>>,
58+
raw_codemap: &'a CodeMap,
59+
caching_codemap: Option<CachingCodemapView<'a>>,
6160
}
6261

6362
#[derive(PartialEq, Eq, Clone, Copy)]
@@ -80,15 +79,14 @@ impl<'gcx> BodyResolver<'gcx> {
8079
}
8180
}
8281

83-
impl<'a, 'gcx> StableHashingContext<'a, 'gcx> {
82+
impl<'a> StableHashingContext<'a> {
8483
// The `krate` here is only used for mapping BodyIds to Bodies.
8584
// Don't use it for anything else or you'll run the risk of
8685
// leaking data out of the tracking system.
87-
pub fn new(sess: &'gcx Session,
88-
krate: &'gcx hir::Crate,
89-
definitions: &'gcx Definitions,
90-
cstore: &'gcx CrateStore,
91-
interpret_interner: Option<&'a RefCell<InterpretInterner<'gcx>>>)
86+
pub fn new(sess: &'a Session,
87+
krate: &'a hir::Crate,
88+
definitions: &'a Definitions,
89+
cstore: &'a CrateStore)
9290
-> Self {
9391
let hash_spans_initial = !sess.opts.debugging_opts.incremental_ignore_spans;
9492

@@ -111,12 +109,11 @@ impl<'a, 'gcx> StableHashingContext<'a, 'gcx> {
111109
hash_spans: hash_spans_initial,
112110
hash_bodies: true,
113111
node_id_hashing_mode: NodeIdHashingMode::HashDefPath,
114-
interpret_interner,
115112
}
116113
}
117114

118115
#[inline]
119-
pub fn sess(&self) -> &'gcx Session {
116+
pub fn sess(&self) -> &'a Session {
120117
self.sess
121118
}
122119

@@ -175,7 +172,7 @@ impl<'a, 'gcx> StableHashingContext<'a, 'gcx> {
175172
}
176173

177174
#[inline]
178-
pub fn codemap(&mut self) -> &mut CachingCodemapView<'gcx> {
175+
pub fn codemap(&mut self) -> &mut CachingCodemapView<'a> {
179176
match self.caching_codemap {
180177
Some(ref mut cm) => {
181178
cm
@@ -205,38 +202,38 @@ impl<'a, 'gcx> StableHashingContext<'a, 'gcx> {
205202
}
206203

207204
impl<'a, 'gcx, 'lcx> StableHashingContextProvider for TyCtxt<'a, 'gcx, 'lcx> {
208-
type ContextType = StableHashingContext<'a, 'gcx>;
205+
type ContextType = StableHashingContext<'a>;
209206
fn create_stable_hashing_context(&self) -> Self::ContextType {
210207
(*self).create_stable_hashing_context()
211208
}
212209
}
213210

214211

215-
impl<'a, 'gcx> StableHashingContextProvider for StableHashingContext<'a, 'gcx> {
216-
type ContextType = StableHashingContext<'a, 'gcx>;
212+
impl<'a> StableHashingContextProvider for StableHashingContext<'a> {
213+
type ContextType = StableHashingContext<'a>;
217214
fn create_stable_hashing_context(&self) -> Self::ContextType {
218215
self.clone()
219216
}
220217
}
221218

222-
impl<'a, 'gcx> ::dep_graph::DepGraphSafe for StableHashingContext<'a, 'gcx> {
219+
impl<'a> ::dep_graph::DepGraphSafe for StableHashingContext<'a> {
223220
}
224221

225222

226-
impl<'a, 'gcx> HashStable<StableHashingContext<'a, 'gcx>> for hir::BodyId {
223+
impl<'a> HashStable<StableHashingContext<'a>> for hir::BodyId {
227224
fn hash_stable<W: StableHasherResult>(&self,
228-
hcx: &mut StableHashingContext<'a, 'gcx>,
225+
hcx: &mut StableHashingContext<'a>,
229226
hasher: &mut StableHasher<W>) {
230227
if hcx.hash_bodies() {
231228
hcx.body_resolver.body(*self).hash_stable(hcx, hasher);
232229
}
233230
}
234231
}
235232

236-
impl<'a, 'gcx> HashStable<StableHashingContext<'a, 'gcx>> for hir::HirId {
233+
impl<'a> HashStable<StableHashingContext<'a>> for hir::HirId {
237234
#[inline]
238235
fn hash_stable<W: StableHasherResult>(&self,
239-
hcx: &mut StableHashingContext<'a, 'gcx>,
236+
hcx: &mut StableHashingContext<'a>,
240237
hasher: &mut StableHasher<W>) {
241238
match hcx.node_id_hashing_mode {
242239
NodeIdHashingMode::Ignore => {
@@ -255,21 +252,21 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a, 'gcx>> for hir::HirId {
255252
}
256253
}
257254

258-
impl<'a, 'gcx> ToStableHashKey<StableHashingContext<'a, 'gcx>> for hir::HirId {
255+
impl<'a> ToStableHashKey<StableHashingContext<'a>> for hir::HirId {
259256
type KeyType = (DefPathHash, hir::ItemLocalId);
260257

261258
#[inline]
262259
fn to_stable_hash_key(&self,
263-
hcx: &StableHashingContext<'a, 'gcx>)
260+
hcx: &StableHashingContext<'a>)
264261
-> (DefPathHash, hir::ItemLocalId) {
265262
let def_path_hash = hcx.local_def_path_hash(self.owner);
266263
(def_path_hash, self.local_id)
267264
}
268265
}
269266

270-
impl<'a, 'gcx> HashStable<StableHashingContext<'a, 'gcx>> for ast::NodeId {
267+
impl<'a> HashStable<StableHashingContext<'a>> for ast::NodeId {
271268
fn hash_stable<W: StableHasherResult>(&self,
272-
hcx: &mut StableHashingContext<'a, 'gcx>,
269+
hcx: &mut StableHashingContext<'a>,
273270
hasher: &mut StableHasher<W>) {
274271
match hcx.node_id_hashing_mode {
275272
NodeIdHashingMode::Ignore => {
@@ -282,18 +279,18 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a, 'gcx>> for ast::NodeId {
282279
}
283280
}
284281

285-
impl<'a, 'gcx> ToStableHashKey<StableHashingContext<'a, 'gcx>> for ast::NodeId {
282+
impl<'a> ToStableHashKey<StableHashingContext<'a>> for ast::NodeId {
286283
type KeyType = (DefPathHash, hir::ItemLocalId);
287284

288285
#[inline]
289286
fn to_stable_hash_key(&self,
290-
hcx: &StableHashingContext<'a, 'gcx>)
287+
hcx: &StableHashingContext<'a>)
291288
-> (DefPathHash, hir::ItemLocalId) {
292289
hcx.definitions.node_to_hir_id(*self).to_stable_hash_key(hcx)
293290
}
294291
}
295292

296-
impl<'a, 'gcx> HashStable<StableHashingContext<'a, 'gcx>> for Span {
293+
impl<'a> HashStable<StableHashingContext<'a>> for Span {
297294

298295
// Hash a span in a stable way. We can't directly hash the span's BytePos
299296
// fields (that would be similar to hashing pointers, since those are just
@@ -305,7 +302,7 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a, 'gcx>> for Span {
305302
// Also, hashing filenames is expensive so we avoid doing it twice when the
306303
// span starts and ends in the same file, which is almost always the case.
307304
fn hash_stable<W: StableHasherResult>(&self,
308-
hcx: &mut StableHashingContext<'a, 'gcx>,
305+
hcx: &mut StableHashingContext<'a>,
309306
hasher: &mut StableHasher<W>) {
310307
const TAG_VALID_SPAN: u8 = 0;
311308
const TAG_INVALID_SPAN: u8 = 1;
@@ -386,7 +383,7 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a, 'gcx>> for Span {
386383
}
387384

388385
pub fn hash_stable_trait_impls<'a, 'gcx, W, R>(
389-
hcx: &mut StableHashingContext<'a, 'gcx>,
386+
hcx: &mut StableHashingContext<'a>,
390387
hasher: &mut StableHasher<W>,
391388
blanket_impls: &Vec<DefId>,
392389
non_blanket_impls: &HashMap<fast_reject::SimplifiedType, Vec<DefId>, R>)

0 commit comments

Comments
 (0)