diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-11-30 13:49:03 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-11-30 13:49:17 +0100 |
| commit | de40124adb3c7bd064e9dbdcb4d82db6843889c3 (patch) | |
| tree | 990924fd8bba15c6710bb6020e6d19aed193b54f /crates/typst-macros | |
| parent | 5bdec9e1d81f0193e88e136453945481021440e1 (diff) | |
Fix content hashing
Fixes #2800
Diffstat (limited to 'crates/typst-macros')
| -rw-r--r-- | crates/typst-macros/src/elem.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/typst-macros/src/elem.rs b/crates/typst-macros/src/elem.rs index e0306b70..e531a7ed 100644 --- a/crates/typst-macros/src/elem.rs +++ b/crates/typst-macros/src/elem.rs @@ -964,8 +964,11 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream { #foundations::Element::of::<Self>() } - fn dyn_hash(&self, mut hasher: &mut dyn ::std::hash::Hasher) { - <Self as ::std::hash::Hash>::hash(self, &mut hasher); + fn dyn_hash(&self, mut state: &mut dyn ::std::hash::Hasher) { + // Also hash the TypeId since values with different types but + // equal data should be different. + ::std::hash::Hash::hash(&::std::any::TypeId::of::<Self>(), &mut state); + ::std::hash::Hash::hash(self, &mut state); } fn dyn_eq(&self, other: &#foundations::Content) -> bool { |
