about summary refs log tree commit diff
path: root/src/libcore/hash
diff options
context:
space:
mode:
authorLeSeulArtichaut <leseulartichaut@gmail.com>2020-04-23 23:05:37 +0200
committerLeSeulArtichaut <leseulartichaut@gmail.com>2020-04-23 23:05:37 +0200
commita694315ed1943496149980dd80a0da2b1d71ff1c (patch)
tree664ae37bb0aeac3adb32afa8b44a04e169f3c9fd /src/libcore/hash
parent3029e9e9e476337b9e2c71de669e87839bb19ed5 (diff)
downloadrust-a694315ed1943496149980dd80a0da2b1d71ff1c.tar.gz
rust-a694315ed1943496149980dd80a0da2b1d71ff1c.zip
Add a note about fat pointers
Co-Authored-By: Mark-Simulacrum <mark.simulacrum@gmail.com>
Diffstat (limited to 'src/libcore/hash')
-rw-r--r--src/libcore/hash/mod.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs
index 4f66b00b279..d80101753cb 100644
--- a/src/libcore/hash/mod.rs
+++ b/src/libcore/hash/mod.rs
@@ -695,6 +695,9 @@ mod impls {
                 // Fat pointer
                 // SAFETY: we are accessing the memory occupied by `self`
                 // which is guaranteed to be valid.
+                // This assumes a fat pointer can be represented by a `(usize, usize)`,
+                // which is safe to do in `std` because it is shipped and kept in sync
+                // with the implementation of fat pointers in `rustc`.
                 let (a, b) = unsafe { *(self as *const Self as *const (usize, usize)) };
                 state.write_usize(a);
                 state.write_usize(b);
@@ -712,6 +715,9 @@ mod impls {
                 // Fat pointer
                 // SAFETY: we are accessing the memory occupied by `self`
                 // which is guaranteed to be valid.
+                // This assumes a fat pointer can be represented by a `(usize, usize)`,
+                // which is safe to do in `std` because it is shipped and kept in sync
+                // with the implementation of fat pointers in `rustc`.
                 let (a, b) = unsafe { *(self as *const Self as *const (usize, usize)) };
                 state.write_usize(a);
                 state.write_usize(b);