Skip to content

Commit 7921572

Browse files
committed
Rollup merge of #55722 - RalfJung:impl-stable-hash, r=varkor
impl_stable_hash_for: support enums and tuple structs with generic parameters Port a bunch of implementations over to the macro, now that that is possible.
2 parents 2173681 + db3c69e commit 7921572

File tree

3 files changed

+192
-377
lines changed

3 files changed

+192
-377
lines changed

src/librustc/ich/impls_mir.rs

+17-54
Original file line numberDiff line numberDiff line change
@@ -37,68 +37,31 @@ impl_stable_hash_for!(struct mir::BasicBlockData<'tcx> { statements, terminator,
3737
impl_stable_hash_for!(struct mir::UnsafetyViolation { source_info, description, details, kind });
3838
impl_stable_hash_for!(struct mir::UnsafetyCheckResult { violations, unsafe_blocks });
3939

40-
impl<'a> HashStable<StableHashingContext<'a>>
41-
for mir::BorrowKind {
42-
#[inline]
43-
fn hash_stable<W: StableHasherResult>(&self,
44-
hcx: &mut StableHashingContext<'a>,
45-
hasher: &mut StableHasher<W>) {
46-
mem::discriminant(self).hash_stable(hcx, hasher);
47-
48-
match *self {
49-
mir::BorrowKind::Shared |
50-
mir::BorrowKind::Shallow |
51-
mir::BorrowKind::Unique => {}
52-
mir::BorrowKind::Mut { allow_two_phase_borrow } => {
53-
allow_two_phase_borrow.hash_stable(hcx, hasher);
54-
}
55-
}
56-
}
57-
}
58-
59-
60-
impl<'a> HashStable<StableHashingContext<'a>>
61-
for mir::UnsafetyViolationKind {
62-
#[inline]
63-
fn hash_stable<W: StableHasherResult>(&self,
64-
hcx: &mut StableHashingContext<'a>,
65-
hasher: &mut StableHasher<W>) {
66-
67-
mem::discriminant(self).hash_stable(hcx, hasher);
68-
69-
match *self {
70-
mir::UnsafetyViolationKind::General => {}
71-
mir::UnsafetyViolationKind::MinConstFn => {}
72-
mir::UnsafetyViolationKind::ExternStatic(lint_node_id) |
73-
mir::UnsafetyViolationKind::BorrowPacked(lint_node_id) => {
74-
lint_node_id.hash_stable(hcx, hasher);
75-
}
40+
impl_stable_hash_for!(enum mir::BorrowKind {
41+
Shared,
42+
Shallow,
43+
Unique,
44+
Mut { allow_two_phase_borrow },
45+
});
7646

77-
}
78-
}
79-
}
47+
impl_stable_hash_for!(enum mir::UnsafetyViolationKind {
48+
General,
49+
MinConstFn,
50+
ExternStatic(lint_node_id),
51+
BorrowPacked(lint_node_id),
52+
});
8053

8154
impl_stable_hash_for!(struct mir::Terminator<'tcx> {
8255
kind,
8356
source_info
8457
});
8558

86-
impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> for mir::ClearCrossCrate<T>
87-
where T: HashStable<StableHashingContext<'a>>
88-
{
89-
#[inline]
90-
fn hash_stable<W: StableHasherResult>(&self,
91-
hcx: &mut StableHashingContext<'a>,
92-
hasher: &mut StableHasher<W>) {
93-
mem::discriminant(self).hash_stable(hcx, hasher);
94-
match *self {
95-
mir::ClearCrossCrate::Clear => {}
96-
mir::ClearCrossCrate::Set(ref value) => {
97-
value.hash_stable(hcx, hasher);
98-
}
99-
}
59+
impl_stable_hash_for!(
60+
impl<T> for enum mir::ClearCrossCrate<T> [ mir::ClearCrossCrate ] {
61+
Clear,
62+
Set(value),
10063
}
101-
}
64+
);
10265

10366
impl<'a> HashStable<StableHashingContext<'a>> for mir::Local {
10467
#[inline]

0 commit comments

Comments
 (0)