From e97c6300c626d34665e760e165e4ac1b90d2c6f1 Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Sun, 13 Sep 2026 16:09:55 +0000 Subject: [PATCH] Rename `Ptr::try_into_valid` to `Ptr::try_into_safe` gherrit-pr-id: G43414d79608bdfefacdf84890ce8f2224bdb5ceb --- zerocopy/src/lib.rs | 12 ++++++------ zerocopy/src/pointer/ptr.rs | 2 +- zerocopy/src/util/macro_util.rs | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/zerocopy/src/lib.rs b/zerocopy/src/lib.rs index 9334924d22..40b835610e 100644 --- a/zerocopy/src/lib.rs +++ b/zerocopy/src/lib.rs @@ -1979,7 +1979,7 @@ pub unsafe trait TryFromBytes { // This call may panic. If that happens, it doesn't cause any soundness // issues, as we have not generated any invalid state which we need to // fix before returning. - match source.try_into_valid() { + match source.try_into_safe() { Ok(valid) => Ok(valid.as_ref()), Err(e) => { Err(e.map_src(|src| src.as_bytes::().as_ref()).into()) @@ -2306,7 +2306,7 @@ pub unsafe trait TryFromBytes { // This call may panic. If that happens, it doesn't cause any soundness // issues, as we have not generated any invalid state which we need to // fix before returning. - match source.try_into_valid() { + match source.try_into_safe() { Ok(source) => Ok(source.as_mut()), Err(e) => Err(e.map_src(|src| src.as_bytes().as_mut()).into()), } @@ -2623,7 +2623,7 @@ pub unsafe trait TryFromBytes { // This call may panic. If that happens, it doesn't cause any soundness // issues, as we have not generated any invalid state which we need to // fix before returning. - match source.try_into_valid() { + match source.try_into_safe() { Ok(source) => Ok(source.as_ref()), Err(e) => { Err(e.map_src(|src| src.as_bytes::().as_ref()).into()) @@ -2948,7 +2948,7 @@ pub unsafe trait TryFromBytes { // This call may panic. If that happens, it doesn't cause any soundness // issues, as we have not generated any invalid state which we need to // fix before returning. - match source.try_into_valid() { + match source.try_into_safe() { Ok(source) => Ok(source.as_mut()), Err(e) => Err(e.map_src(|src| src.as_bytes().as_mut()).into()), } @@ -3399,7 +3399,7 @@ fn try_ref_from_prefix_suffix Ok((valid.as_ref(), prefix_suffix.as_ref())), Err(e) => Err(e.map_src(|src| src.as_bytes::().as_ref()).into()), } @@ -3419,7 +3419,7 @@ fn try_mut_from_prefix_suffix Ok((valid.as_mut(), prefix_suffix.as_mut())), Err(e) => Err(e.map_src(|src| src.as_bytes().as_mut()).into()), } diff --git a/zerocopy/src/pointer/ptr.rs b/zerocopy/src/pointer/ptr.rs index fbc469ed87..0e6aa298f9 100644 --- a/zerocopy/src/pointer/ptr.rs +++ b/zerocopy/src/pointer/ptr.rs @@ -780,7 +780,7 @@ mod _transitions { /// On error, unsafe code may rely on this method's returned /// `ValidityError` containing `self`. #[inline] - pub fn try_into_valid( + pub fn try_into_safe( mut self, ) -> Result, ValidityError> where diff --git a/zerocopy/src/util/macro_util.rs b/zerocopy/src/util/macro_util.rs index 9dd4eb3aa0..f374a089f4 100644 --- a/zerocopy/src/util/macro_util.rs +++ b/zerocopy/src/util/macro_util.rs @@ -633,7 +633,7 @@ where let res = ptr.try_with(#[inline(always)] |ptr| { let ptr = ptr.recall_validity::(); let ptr = ptr.cast::<_, crate::layout::CastFrom, _>(); - ptr.try_into_valid() + ptr.try_into_safe() }); match res { Ok(ptr) => { @@ -696,7 +696,7 @@ where ptr.try_with_unchecked(#[inline(always)] |ptr| { let ptr = ptr.recall_validity::(); let ptr = ptr.cast::<_, crate::layout::CastFrom, _>(); - ptr.try_into_valid() + ptr.try_into_safe() }) }; match res {