about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2022-07-20 10:22:16 -0400
committerRalf Jung <post@ralfj.de>2022-07-20 10:22:16 -0400
commit5848c27c7995eabe0db76eb7c1360c77e9fefba4 (patch)
tree9678bb2f4347ca53fdef46237ae0468709099cde
parentd60d88fe5cd55496b9ccb1511a9af4994b7c43d0 (diff)
downloadrust-5848c27c7995eabe0db76eb7c1360c77e9fefba4.tar.gz
rust-5848c27c7995eabe0db76eb7c1360c77e9fefba4.zip
make raw_eq precondition more restrictive
-rw-r--r--library/core/src/array/equality.rs7
-rw-r--r--library/core/src/intrinsics.rs3
2 files changed, 6 insertions, 4 deletions
diff --git a/library/core/src/array/equality.rs b/library/core/src/array/equality.rs
index 33f7f494e9d..a85f13a4b9e 100644
--- a/library/core/src/array/equality.rs
+++ b/library/core/src/array/equality.rs
@@ -173,13 +173,14 @@ macro_rules! is_raw_eq_comparable {
     )+};
 }
 
-// SAFETY: All the ordinary integer types allow all bit patterns as distinct values
+// SAFETY: All the ordinary integer types have no padding, and are no poointers.
 is_raw_eq_comparable!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize);
 
-// SAFETY: bool and char have *niches*, but no *padding*, so this is sound
+// SAFETY: bool and char have *niches*, but no *padding* (and these are not pointer types), so this
+// is sound
 is_raw_eq_comparable!(bool, char);
 
-// SAFETY: Similarly, the non-zero types have a niche, but no undef,
+// SAFETY: Similarly, the non-zero types have a niche, but no undef and no pointers,
 // and they compare like their underlying numeric type.
 is_raw_eq_comparable!(
     NonZeroU8,
diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs
index 998f7be3f73..565c32d6888 100644
--- a/library/core/src/intrinsics.rs
+++ b/library/core/src/intrinsics.rs
@@ -2277,7 +2277,8 @@ extern "rust-intrinsic" {
     ///
     /// # Safety
     ///
-    /// It's UB to call this if any of the *bytes* in `*a` or `*b` are uninitialized.
+    /// It's UB to call this if any of the *bytes* in `*a` or `*b` are uninitialized or carries a
+    /// pointer value.
     /// Note that this is a stricter criterion than just the *values* being
     /// fully-initialized: if `T` has padding, it's UB to call this intrinsic.
     ///