Skip to content

Commit 5d75ca5

Browse files
committed
Remove unused hashing infra.
1 parent 8a4cbcf commit 5d75ca5

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -631,14 +631,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
631631
) -> (Fingerprint, Fingerprint) {
632632
self.tcx.with_stable_hashing_context(|mut hcx| {
633633
let mut stable_hasher = StableHasher::new();
634-
hcx.with_hir_bodies(true, node.def_id(), bodies, |hcx| {
634+
hcx.with_hir_bodies(node.def_id(), bodies, |hcx| {
635635
node.hash_stable(hcx, &mut stable_hasher)
636636
});
637637
let hash_including_bodies = stable_hasher.finish();
638638
let mut stable_hasher = StableHasher::new();
639-
hcx.with_hir_bodies(false, node.def_id(), bodies, |hcx| {
640-
node.hash_stable(hcx, &mut stable_hasher)
641-
});
639+
hcx.without_hir_bodies(|hcx| node.hash_stable(hcx, &mut stable_hasher));
642640
let hash_without_bodies = stable_hasher.finish();
643641
(hash_including_bodies, hash_without_bodies)
644642
})

compiler/rustc_query_system/src/ich/hcx.rs

+5-20
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,8 @@ pub struct StableHashingContext<'a> {
4040
#[derive(Clone, Copy)]
4141
pub(super) enum BodyResolver<'tcx> {
4242
Forbidden,
43-
Traverse {
44-
hash_bodies: bool,
45-
owner: LocalDefId,
46-
bodies: &'tcx SortedMap<hir::ItemLocalId, &'tcx hir::Body<'tcx>>,
47-
},
43+
Ignore,
44+
Traverse { owner: LocalDefId, bodies: &'tcx SortedMap<hir::ItemLocalId, &'tcx hir::Body<'tcx>> },
4845
}
4946

5047
impl<'a> StableHashingContext<'a> {
@@ -98,32 +95,20 @@ impl<'a> StableHashingContext<'a> {
9895
Self::new_with_or_without_spans(sess, definitions, cstore, source_span, always_ignore_spans)
9996
}
10097

101-
/// Allow hashing
10298
#[inline]
103-
pub fn while_hashing_hir_bodies(&mut self, hb: bool, f: impl FnOnce(&mut Self)) {
104-
let prev = match &mut self.body_resolver {
105-
BodyResolver::Forbidden => panic!("Hashing HIR bodies is forbidden."),
106-
BodyResolver::Traverse { ref mut hash_bodies, .. } => {
107-
std::mem::replace(hash_bodies, hb)
108-
}
109-
};
110-
f(self);
111-
match &mut self.body_resolver {
112-
BodyResolver::Forbidden => unreachable!(),
113-
BodyResolver::Traverse { ref mut hash_bodies, .. } => *hash_bodies = prev,
114-
}
99+
pub fn without_hir_bodies(&mut self, f: impl FnOnce(&mut StableHashingContext<'_>)) {
100+
f(&mut StableHashingContext { body_resolver: BodyResolver::Ignore, ..self.clone() });
115101
}
116102

117103
#[inline]
118104
pub fn with_hir_bodies(
119105
&mut self,
120-
hash_bodies: bool,
121106
owner: LocalDefId,
122107
bodies: &SortedMap<hir::ItemLocalId, &hir::Body<'_>>,
123108
f: impl FnOnce(&mut StableHashingContext<'_>),
124109
) {
125110
f(&mut StableHashingContext {
126-
body_resolver: BodyResolver::Traverse { hash_bodies, owner, bodies },
111+
body_resolver: BodyResolver::Traverse { owner, bodies },
127112
..self.clone()
128113
});
129114
}

compiler/rustc_query_system/src/ich/impls_hir.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ impl<'ctx> rustc_hir::HashStableContext for StableHashingContext<'ctx> {
1212
let hcx = self;
1313
match hcx.body_resolver {
1414
BodyResolver::Forbidden => panic!("Hashing HIR bodies is forbidden."),
15-
BodyResolver::Traverse { hash_bodies: false, .. } => {}
16-
BodyResolver::Traverse { hash_bodies: true, owner, bodies } => {
15+
BodyResolver::Ignore => {}
16+
BodyResolver::Traverse { owner, bodies } => {
1717
assert_eq!(id.hir_id.owner, owner);
1818
bodies[&id.hir_id.local_id].hash_stable(hcx, hasher);
1919
}

0 commit comments

Comments
 (0)