From 4426e9a3c260e329f51c94e2b231f72574271f0b Mon Sep 17 00:00:00 2001 From: joboet Date: Fri, 10 Jan 2025 18:48:48 +0100 Subject: alloc: remove unsound `IsZero` for raw pointers Fixes #135338 --- library/alloc/src/vec/is_zero.rs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'library/alloc/src/vec') diff --git a/library/alloc/src/vec/is_zero.rs b/library/alloc/src/vec/is_zero.rs index ba57d940d8c..a3ddd6f6e23 100644 --- a/library/alloc/src/vec/is_zero.rs +++ b/library/alloc/src/vec/is_zero.rs @@ -40,19 +40,8 @@ impl_is_zero!(char, |x| x == '\0'); impl_is_zero!(f32, |x: f32| x.to_bits() == 0); impl_is_zero!(f64, |x: f64| x.to_bits() == 0); -unsafe impl IsZero for *const T { - #[inline] - fn is_zero(&self) -> bool { - (*self).is_null() - } -} - -unsafe impl IsZero for *mut T { - #[inline] - fn is_zero(&self) -> bool { - (*self).is_null() - } -} +// `IsZero` cannot be soundly implemented for pointers because of provenance +// (see #135338). unsafe impl IsZero for [T; N] { #[inline] -- cgit 1.4.1-3-g733a5