Skip to content

Commit 9322a2c

Browse files
authored
[pointer] Remove Ptr::project method (#2339)
Now that #1122 is complete in #1896, `project` is redundant. gherrit-pr-id: I15d38f2f1fffad82caa70ea6eb18dffcd6504495
1 parent 28b55b9 commit 9322a2c

File tree

4 files changed

+42
-68
lines changed

4 files changed

+42
-68
lines changed

src/pointer/ptr.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,32 +1077,6 @@ mod _casts {
10771077
mod _project {
10781078
use super::*;
10791079

1080-
impl<'a, T: ?Sized, I> Ptr<'a, Initialized<T>, I>
1081-
where
1082-
I: Invariants,
1083-
{
1084-
/// Projects a field from `self`.
1085-
///
1086-
/// # Safety
1087-
///
1088-
/// `project` has the same safety preconditions as
1089-
/// `cast_unsized_unchecked`.
1090-
#[doc(hidden)]
1091-
#[inline]
1092-
pub unsafe fn project<W: 'a + ?Sized>(
1093-
self,
1094-
projector: impl FnOnce(*mut T) -> *mut W,
1095-
) -> Ptr<'a, Initialized<W>, (I::Aliasing, Unknown)> {
1096-
// TODO(#1122): If `cast_unsized` were able to reason that, when
1097-
// casting from an `Initialized` pointer, the result is another
1098-
// `Initialized` pointer, we could remove this method entirely.
1099-
1100-
// SAFETY: This method has the same safety preconditions as
1101-
// `cast_unsized_unchecked`.
1102-
unsafe { self.cast_unsized_unchecked(projector) }
1103-
}
1104-
}
1105-
11061080
impl<V, T, I> Ptr<'_, V, I>
11071081
where
11081082
V: Validity<Inner = [T]>,

zerocopy-derive/src/enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ pub(crate) fn derive_is_bit_valid(
349349
// subfield pointer just points to a smaller portion of the
350350
// overall struct.
351351
let variants = unsafe {
352-
raw_enum.project(|p: *mut ___ZerocopyRawEnum #ty_generics| {
352+
raw_enum.cast_unsized_unchecked(|p: *mut ___ZerocopyRawEnum #ty_generics| {
353353
core_reexport::ptr::addr_of_mut!((*p).variants)
354354
})
355355
};

zerocopy-derive/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ fn derive_try_from_bytes_struct(
571571
let project = |slf: *mut Self|
572572
::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!((*slf).#field_names);
573573

574-
candidate.reborrow().project(project)
574+
candidate.reborrow().cast_unsized_unchecked(project)
575575
};
576576

577577
<#field_tys as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate)
@@ -629,7 +629,7 @@ fn derive_try_from_bytes_union(
629629
let project = |slf: *mut Self|
630630
::zerocopy::util::macro_util::core_reexport::ptr::addr_of_mut!((*slf).#field_names);
631631

632-
candidate.reborrow().project(project)
632+
candidate.reborrow().cast_unsized_unchecked(project)
633633
};
634634

635635
<#field_tys as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate)

0 commit comments

Comments
 (0)