Lines Matching +full:lint +full:- +full:rustfmt +full:- +full:rules
3 // Licensed under the 2-Clause BSD License <LICENSE-BSD or
4 // https://opensource.org/license/bsd-2-clause>, Apache License, Version 2.0
5 // <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
6 // license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
13 // ./generate-readme.sh > README.md
15 //! *<span style="font-size: 100%; color:grey;">Want to help improve zerocopy?
16 //! Fill out our [user survey][user-survey]!</span>*
18 //! ***<span style="font-size: 140%">Fast, safe, <span
21 //! Zerocopy makes zero-cost memory manipulation effortless. We write `unsafe`
28 //! - [`FromZeroes`] indicates that a sequence of zero bytes represents a valid
30 //! - [`FromBytes`] indicates that a type may safely be converted from an
32 //! - [`AsBytes`] indicates that a type may safely be converted *to* a byte
34 //! - [`Unaligned`] indicates that a type's alignment requirement is 1
39 //! Zerocopy also provides byte-order aware integer types that support these
43 //! [user-survey]: https://docs.google.com/forms/d/e/1FAIpQLSdzBNTN9tzwsmtyZxRFNL02K36IWCdHWW2ZBcky…
47 //! - **`alloc`**
49 //! the `alloc` crate is added as a dependency, and some allocation-related
52 //! - **`byteorder`** (enabled by default)
54 //! The `byteorder` module provides byte order-aware equivalents of the
55 //! multi-byte primitive numerical types. Unlike their primitive equivalents,
61 //! - **`derive`**
62 //! Provides derives for the core marker traits via the `zerocopy-derive`
63 //! crate. These derives are re-exported from `zerocopy`, so it is not
64 //! necessary to depend on `zerocopy-derive` directly.
67 //! depend on both `zerocopy` and `zerocopy-derive` in your `Cargo.toml`,
70 //! your `Cargo.toml` with the same leading non-zero version number; e.g:
75 //! zerocopy-derive = "0.X"
78 //! - **`simd`**
84 //! page on the [layout of packed SIMD vectors][simd-layout].
86 //! - **`simd-nightly`**
91 //! [simd-layout]: https://rust-lang.github.io/unsafe-code-guidelines/layout/packed-simd-vectors.ht…
95 //! Zerocopy is expressly designed for use in security-critical contexts. We
98 //! - **...not 'guessing' about Rust's semantics.**
103 //! - **...rigorously testing our implementation.**
107 //! - **...formally proving the correctness of our implementation.**
113 //! [Miri]: https://github.com/rust-lang/miri
114 //! [Kani]: https://github.com/model-checking/kani
120 //! develop language-level support for safer transmutation. The Project consults
123 //! compiler-supported analysis][mcp-transmutability] which determines whether,
127 //! custom derives) with the compiler-supported one. This change will likely be
131 //! higher-level abstractions. The experimental compiler analysis is a tool for
134 //! will still be required in order to provide higher-level abstractions on top
137 //! [Project Safe Transmute]: https://rust-lang.github.io/rfcs/2835-project-safe-transmute.html
138 //! [mcp-transmutability]: https://github.com/rust-lang/compiler-team/issues/411
154 // this attribute, any unknown lint would cause a CI failure when testing with
224 // In tests, there's no harm to "panic risks" - the worst that can happen is
233 all(feature = "simd-nightly", any(target_arch = "x86", target_arch = "x86_64")),
237 all(feature = "simd-nightly", target_arch = "arm"),
241 all(feature = "simd-nightly", any(target_arch = "powerpc", target_arch = "powerpc64")),
250 // This is a hack to allow zerocopy-derive derives to work in this crate. They
326 …#[deprecated = "some tests may be skipped due to missing RUSTFLAGS=\"--cfg __INTERNAL_USE_ONLY_NIG…
335 /// The layout of a type which might be dynamically-sized.
338 /// DSTs" - ie, those that are known by the type system to have a trailing slice
339 /// (as distinguished from `dyn Trait` types - such types *might* have a
345 /// Rust types - ie, those that satisfy the layout requirements outlined by
350 /// - `layout.align` is equal to `T`'s alignment
351 /// - If `layout.size_info` is `SizeInfo::Sized { size }`, then `T: Sized` and
353 /// - If `layout.size_info` is `SizeInfo::SliceDst(slice_layout)`, then
354 /// - `T` is a slice DST
355 /// - The `size` of an instance of `T` with `elems` trailing slice elements is
361 /// [the reference]: https://doc.rust-lang.org/reference/type-layout.html
399 const fn try_to_nonzero_elem_size(&self) -> Option<SizeInfo<NonZeroUsize>> { in try_to_nonzero_elem_size()
432 /// maximum power-of-two that fits into a `usize`. See also
435 match NonZeroUsize::new(1 << (POINTER_WIDTH_BITS - 1)) {
442 /// \[1\] Per <https://doc.rust-lang.org/reference/type-layout.html#the-alignment-modifiers>:
452 /// Constructs a `DstLayout` for a zero-sized type with `repr_align`
465 pub const fn new_zst(repr_align: Option<NonZeroUsize>) -> DstLayout { in new_zst()
483 pub const fn for_type<T>() -> DstLayout { in for_type()
501 const fn for_slice<T>() -> DstLayout { in for_slice()
524 /// necessary inter-field padding, but not any trailing padding.
549 pub const fn extend(self, field: DstLayout, repr_packed: Option<NonZeroUsize>) -> Self { in extend()
576 // [1] Per https://doc.rust-lang.org/reference/type-layout.html#the-alignment-modifiers: in extend()
593 // Compute the minimum amount of inter-field padding needed to in extend()
597 … // [1] Per https://doc.rust-lang.org/reference/type-layout.html#the-alignment-modifiers: in extend()
599 // Inter-field padding is guaranteed to be the minimum in extend()
619 // size of inter-field padding between the two. in extend()
688 pub const fn pad_to_align(self) -> Self { in pad_to_align()
720 /// `(elems, split_at)`. If `self` describes a dynamically-sized type, then
729 /// - The smallest possible value for the type is larger than the provided
731 /// - A prefix cast is requested, and `addr` does not satisfy `self`'s
733 /// - A suffix cast is requested, and `addr + bytes_len` does not satisfy
744 /// - A pointer to the type (for dynamically sized types, this includes
747 /// - If this is a prefix cast:
748 /// - `addr` satisfies `self`'s alignment
749 /// - `size == split_at`
750 /// - If this is a suffix cast:
751 /// - `split_at == bytes_len - size`
752 /// - `addr + split_at` satisfies `self`'s alignment
759 /// long as the arguments to this method are derived from a known-valid
768 /// DST whose trailing slice element is zero-sized.
782 ) -> Option<(usize, usize)> { in validate_cast_and_convert_metadata()
794 // Note that, in practice, `self` is always a compile-time constant. We in validate_cast_and_convert_metadata()
798 // would have failed anyway for runtime reasons (such as a too-small in validate_cast_and_convert_metadata()
801 // TODO(#67): Once our MSRV is 1.65, use let-else: in validate_cast_and_convert_metadata()
802 // https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html#let-else-statements in validate_cast_and_convert_metadata()
805 None => panic!("attempted to cast to slice type with zero-sized element"), in validate_cast_and_convert_metadata()
812 // into the top-level scope. in validate_cast_and_convert_metadata()
816 // of this check is trivial - `addr` is the address the object will in validate_cast_and_convert_metadata()
822 // validly-sized instance which lives at a validly-aligned address in validate_cast_and_convert_metadata()
823 // must also end at a validly-aligned address. Thus, if the end in validate_cast_and_convert_metadata()
834 // by 0 because `align` is non-zero. in validate_cast_and_convert_metadata()
850 // - any number of bytes larger than this will either not be a in validate_cast_and_convert_metadata()
858 // TODO(#67): Once our MSRV is 1.65, use let-else: in validate_cast_and_convert_metadata()
859 // https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html#let-else-statements in validate_cast_and_convert_metadata()
870 // Guaranteed not to divide by zero: `elem_size` is non-zero. in validate_cast_and_convert_metadata()
878 // - max_slice_and_padding_bytes == max_total_bytes - offset in validate_cast_and_convert_metadata()
879 // - elems * elem_size <= max_slice_and_padding_bytes == max_total_bytes - offset in validate_cast_and_convert_metadata()
880 // - elems * elem_size + offset <= max_total_bytes <= usize::MAX in validate_cast_and_convert_metadata()
891 // - By previous comment: without_padding == elems * elem_size + in validate_cast_and_convert_metadata()
893 // - By construction, `max_total_bytes` is a multiple of in validate_cast_and_convert_metadata()
895 // - At most, adding padding needed to round `without_padding` in validate_cast_and_convert_metadata()
910 // - In the `Sized` branch, only returns `size` if `size <= in validate_cast_and_convert_metadata()
912 // - In the `SliceDst` branch, calculates `self_bytes <= in validate_cast_and_convert_metadata()
913 // max_toatl_bytes`, which is upper-bounded by `bytes_len`. in validate_cast_and_convert_metadata()
915 _CastType::_Suffix => bytes_len - self_bytes, in validate_cast_and_convert_metadata()
939 // forwards-compatible with object safety.
952 fn raw_from_ptr_len(bytes: NonNull<u8>, elems: usize) -> NonNull<Self>; in raw_from_ptr_len()
968 fn raw_from_ptr_len(data: NonNull<u8>, elems: usize) -> NonNull<Self> { in raw_from_ptr_len()
975 #[rustfmt::skip]
983 #[rustfmt::skip]
1000 /// [1] Per https://doc.rust-lang.org/nightly/core/mem/struct.ManuallyDrop.html:
1006 /// - Add quotes from docs.
1007 /// - Once [1] (added in
1008 /// https://github.com/rust-lang/rust/pull/115522) is available on stable,
1061 /// - If the type is a struct, all of its fields must be `FromZeroes`.
1062 /// - If the type is an enum, it must be C-like (meaning that all variants have
1065 /// - The type must not contain any [`UnsafeCell`]s (this is required in order
1076 … [the reference]: https://doc.rust-lang.org/reference/items/enumerations.html#custom-discriminant-…
1089 /// [reference]: https://doc.rust-lang.org/reference/type-layout.html#representations
1101 /// [discussion]: https://github.com/rust-lang/unsafe-code-guidelines/issues/174
1121 /// `TryFromBytes` is ignorant of byte order. For byte order-aware types, see
1132 /// Rust's bit validity rules are currently being decided, which means that some
1149 /// we encourage you to let us know by [filing an issue][github-repo].
1159 /// on this trait that provide well-defined safety invariants, no stability
1161 /// releases of zerocopy may make backwards-breaking changes to these items,
1165 /// [undefined behavior]: https://raphlinus.github.io/programming/rust/2018/08/17/undefined-behavio…
1166 /// [github-repo]: https://github.com/google/zerocopy
1181 /// - Those `UnsafeCell`s exist at the same byte ranges as `UnsafeCell`s in
1184 /// vice-versa.
1185 /// - Those `UnsafeCell`s are never used to perform mutation for the
1201 /// - If, in all instances `s: Self` of length `len`, the byte at offset `b`
1204 /// - Let `c` be the contents of the byte range `[0, b)` in `*candidate`.
1216 /// same rules apply depending on the state of its discriminant, and so on
1228 /// panicking. (We support user-defined validation routines; so long as
1234 unsafe fn is_bit_valid(candidate: Ptr<'_, Self>) -> bool; in is_bit_valid()
1242 /// Note that Rust's bit validity rules are still being decided. As such,
1250 fn try_from_ref(bytes: &[u8]) -> Option<&Self> in try_from_ref()
1257 // - Since `bytes` is an immutable reference, we know that no mutable in try_from_ref()
1259 // - Since `[u8]` contains no `UnsafeCell`s, we know there are no in try_from_ref()
1261 // - Since we don't permit implementing `TryFromBytes` for types which in try_from_ref()
1265 // - All bytes of `bytes` are initialized. in try_from_ref()
1275 // - Preconditions for `as_ref`: in try_from_ref()
1276 // - `is_bit_valid` guarantees that `*maybe_self` contains a valid in try_from_ref()
1279 // - Since the argument and return types are immutable references, in try_from_ref()
1282 // - Since `Self` is not allowed to contain any `UnsafeCell`s and the in try_from_ref()
1287 // - Since interior mutation isn't possible within `Self`, there's no in try_from_ref()
1337 /// This derive performs a sophisticated, compile-time safety analysis to
1348 /// - It is sound to treat any initialized sequence of zero bytes of length
1350 /// - Given `b: &[u8]` where `b.len() == size_of::<T>()`, `b` is aligned to
1359 /// requirements][derive-analysis].
1364 doc = "[derive-analysis]: zerocopy_derive::FromZeroes#analysis"
1369 …doc = concat!("[derive-analysis]: https://docs.rs/zerocopy/", "0.7.34", "/zerocopy/derive.FromZero…
1383 /// drop the current value and replace it with a new one - it simply
1420 // - `self` is guaranteed by the type system to be valid for writes of in zero()
1422 // - `u8`'s alignment is 1, and thus `self` is guaranteed to be aligned in zero()
1424 // - Since `Self: FromZeroes`, the all-zeroes instance is a valid in zero()
1456 fn new_zeroed() -> Self in new_zeroed()
1460 // SAFETY: `FromZeroes` says that the all-zeroes bit pattern is legal. in new_zeroed()
1467 /// zero-initializing them, without ever creating a temporary instance of
1473 /// pre-zeroed memory, using `new_box_zeroed` (or related functions) may
1485 fn new_box_zeroed() -> Box<Self> in new_box_zeroed()
1512 /// heap and zero-initializing them, without ever creating a temporary
1518 /// pre-zeroed memory, using `new_box_slice_zeroed` may have performance
1521 /// If `Self` is a zero-sized type, then this function will return a
1533 fn new_box_slice_zeroed(len: usize) -> Box<[Self]> in new_box_slice_zeroed()
1542 // bug in which sufficiently-large allocations (those which, when in new_box_slice_zeroed()
1550 // TODO(https://github.com/rust-lang/rust/issues/55724): Use in new_box_slice_zeroed()
1564 // `Box<[T]>` does not allocate when `T` is zero-sized or when `len` in new_box_slice_zeroed()
1565 // is zero, but it does require a non-null dangling pointer for its in new_box_slice_zeroed()
1580 /// zero-initializing them, without ever creating a temporary instance of
1586 /// pre-zeroed memory, using `new_vec_zeroed` may have performance benefits.
1588 /// If `Self` is a zero-sized type, then this function will return a
1600 fn new_vec_zeroed(len: usize) -> Vec<Self> in new_vec_zeroed()
1672 /// - If the type is a struct, all of its fields must be `FromBytes`.
1673 /// - If the type is an enum:
1674 /// - It must be a C-like enum (meaning that all variants have no fields).
1675 /// - It must have a defined representation (`repr`s `C`, `u8`, `u16`, `u32`,
1677 /// - The maximum number of discriminants must be used (so that every possible
1680 /// platform-dependent.
1681 /// - The type must not contain any [`UnsafeCell`]s (this is required in order
1704 /// [reference]: https://doc.rust-lang.org/reference/type-layout.html#representations
1716 /// [discussion]: https://github.com/rust-lang/unsafe-code-guidelines/issues/174
1782 /// This derive performs a sophisticated, compile-time safety analysis to
1793 /// - It is sound to treat any initialized sequence of bytes of length
1795 /// - Given `b: &[u8]` where `b.len() == size_of::<T>()`, `b` is aligned to
1803 /// requirements][derive-analysis].
1808 doc = "[derive-analysis]: zerocopy_derive::FromBytes#analysis"
1813 …doc = concat!("[derive-analysis]: https://docs.rs/zerocopy/", "0.7.34", "/zerocopy/derive.FromByte…
1854 fn ref_from(bytes: &[u8]) -> Option<&Self> in ref_from()
1896 fn ref_from_prefix(bytes: &[u8]) -> Option<&Self> in ref_from_prefix()
1932 fn ref_from_suffix(bytes: &[u8]) -> Option<&Self> in ref_from_suffix()
1974 fn mut_from(bytes: &mut [u8]) -> Option<&mut Self> in mut_from()
2021 fn mut_from_prefix(bytes: &mut [u8]) -> Option<&mut Self> in mut_from_prefix()
2061 fn mut_from_suffix(bytes: &mut [u8]) -> Option<&mut Self> in mut_from_suffix()
2079 /// If `Self` is a zero-sized type.
2108 fn slice_from(bytes: &[u8]) -> Option<&[Self]> in slice_from()
2128 /// If `T` is a zero-sized type.
2159 fn slice_from_prefix(bytes: &[u8], count: usize) -> Option<(&[Self], &[u8])> in slice_from_prefix()
2179 /// If `T` is a zero-sized type.
2210 fn slice_from_suffix(bytes: &[u8], count: usize) -> Option<(&[u8], &[Self])> in slice_from_suffix()
2228 /// If `T` is a zero-sized type.
2261 fn mut_slice_from(bytes: &mut [u8]) -> Option<&mut [Self]> in mut_slice_from()
2281 /// If `T` is a zero-sized type.
2316 fn mut_slice_from_prefix(bytes: &mut [u8], count: usize) -> Option<(&mut [Self], &mut [u8])> in mut_slice_from_prefix()
2336 /// If `T` is a zero-sized type.
2371 fn mut_slice_from_suffix(bytes: &mut [u8], count: usize) -> Option<(&mut [u8], &mut [Self])> in mut_slice_from_suffix()
2408 fn read_from(bytes: &[u8]) -> Option<Self> in read_from()
2447 fn read_from_prefix(bytes: &[u8]) -> Option<Self> in read_from_prefix()
2481 fn read_from_suffix(bytes: &[u8]) -> Option<Self> in read_from_suffix()
2535 /// --> lib.rs:23:10
2550 /// [type layout]: https://doc.rust-lang.org/reference/type-layout.html
2563 /// - If the type is a struct:
2564 /// - It must have a defined representation (`repr(C)`, `repr(transparent)`,
2566 /// - All of its fields must be `AsBytes`.
2567 /// - Its layout must have no padding. This is always true for
2570 /// - If the type is an enum:
2571 /// - It must be a C-like enum (meaning that all variants have no fields).
2572 /// - It must have a defined representation (`repr`s `C`, `u8`, `u16`, `u32`,
2574 /// - The type must not contain any [`UnsafeCell`]s (this is required in order
2587 /// [Rust Reference]: https://doc.rust-lang.org/reference/type-layout.html
2632 /// This derive performs a sophisticated, compile-time safety analysis to
2645 /// - It is sound to treat any `t: T` as an immutable `[u8]` of length
2647 /// - Given `t: &T`, it is sound to construct a `b: &[u8]` where `b.len() ==
2655 /// requirements][derive-analysis].
2660 doc = "[derive-analysis]: zerocopy_derive::AsBytes#analysis"
2665 …doc = concat!("[derive-analysis]: https://docs.rs/zerocopy/", "0.7.34", "/zerocopy/derive.AsBytes.…
2711 fn as_bytes(&self) -> &[u8] { in as_bytes()
2718 // - `slf.cast::<u8>()` is valid for reads for `len * in as_bytes()
2720 // - `slf` is the same pointer as `self`, and `self` is a reference in as_bytes()
2722 // - The entire region of `len` bytes starting at `slf` is contained in as_bytes()
2724 // - `slf` is non-null. in as_bytes()
2725 // - `slf` is trivially aligned to `align_of::<u8>() == 1`. in as_bytes()
2726 // - `Self: AsBytes` ensures that all of the bytes of `slf` are in as_bytes()
2728 // - Since `slf` is derived from `self`, and `self` is an immutable in as_bytes()
2733 // - The total size of the resulting slice is no larger than in as_bytes()
2783 fn as_bytes_mut(&mut self) -> &mut [u8] in as_bytes_mut()
2793 // - `slf.cast::<u8>()` is valid for reads and writes for `len * in as_bytes_mut()
2795 // - `slf` is the same pointer as `self`, and `self` is a reference in as_bytes_mut()
2797 // - The entire region of `len` bytes starting at `slf` is contained in as_bytes_mut()
2799 // - `slf` is non-null. in as_bytes_mut()
2800 // - `slf` is trivially aligned to `align_of::<u8>() == 1`. in as_bytes_mut()
2801 // - `Self: AsBytes` ensures that all of the bytes of `slf` are in as_bytes_mut()
2803 // - `Self: FromBytes` ensures that no write to this memory region in as_bytes_mut()
2805 // - Since `slf` is derived from `self`, and `self` is a mutable in as_bytes_mut()
2807 // - The total size of the resulting slice is no larger than in as_bytes_mut()
2862 fn write_to(&self, bytes: &mut [u8]) -> Option<()> { in write_to()
2919 fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()> { in write_to_prefix()
2980 fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()> { in write_to_suffix()
2984 .expect("`start` should be in-bounds of `bytes`") in write_to_suffix()
3022 /// zero-sized type to have a size of 0 and an alignment of 1."
3023 /// - `TryFromBytes` (with no validator), `FromZeroes`, `FromBytes`: There
3025 /// - `AsBytes`: Since `()` has size 0, it contains no padding bytes.
3026 /// - `Unaligned`: `()` has alignment 1.
3028 /// [1] https://doc.rust-lang.org/reference/type-layout.html#tuple-layout
3035 /// - `TryFromBytes` (with no validator), `FromZeroes`, `FromBytes`: all bit
3037 /// - `AsBytes`: numeric types have no padding bytes [1]
3038 /// - `Unaligned` (`u8` and `i8` only): The reference [2] specifies the size
3040 /// - Alignment is >= 1 [3]
3041 /// - Size is an integer multiple of alignment [4]
3042 /// - The only value >= 1 for which 1 is an integer multiple is 1
3045 /// [1] Per https://doc.rust-lang.org/beta/reference/types/numeric.html#bit-validity:
3051 /// TODO(https://github.com/rust-lang/reference/pull/1392): Once this text
3054 /// [2] https://doc.rust-lang.org/reference/type-layout.html#primitive-data-layout
3056 /// [3] Per https://doc.rust-lang.org/reference/type-layout.html#size-and-alignment:
3060 /// [4] Per https://doc.rust-lang.org/reference/type-layout.html#size-and-alignment:
3086 /// - `FromZeroes`: Valid since "[t]he value false has the bit pattern
3088 /// - `AsBytes`: Since "the boolean type has a size and alignment of 1 each"
3092 /// - `Unaligned`: Per the reference [1], "[a]n object with the boolean type
3095 /// [1] https://doc.rust-lang.org/reference/types/boolean.html
3099 /// - The safety requirements for `unsafe_impl!` with an `is_bit_valid`
3101 /// - Given `t: *mut bool` and `let r = *mut u8`, `r` refers to an object
3104 /// - Since the closure takes a `&u8` argument, given a `Ptr<'a, bool>`
3112 /// - The alignment of `bool` is equal to the alignment of `u8`. [1] [2]
3113 /// - The impl must only return `true` for its argument if the original
3118 /// [1] Per https://doc.rust-lang.org/reference/type-layout.html#primitive-data-layout:
3123 /// |-----------|----------------------|
3127 /// [2] Per https://doc.rust-lang.org/reference/type-layout.html#size-and-alignment:
3131 /// [3] Per https://doc.rust-lang.org/reference/types/boolean.html:
3139 /// - `FromZeroes`: Per reference [1], "[a] value of type char is a Unicode
3141 /// as a 32-bit unsigned word in the 0x0000 to 0xD7FF or 0xE000 to
3143 /// - `AsBytes`: `char` is per reference [1] "represented as a 32-bit
3147 /// [1] https://doc.rust-lang.org/reference/types/textual.html
3150 /// - The safety requirements for `unsafe_impl!` with an `is_bit_valid`
3152 /// - Given `t: *mut char` and `let r = *mut u32`, `r` refers to an object
3155 /// - Since the closure takes a `&u32` argument, given a `Ptr<'a, char>`
3163 /// - The alignment of `char` is equal to the alignment of `u32`. [1]
3164 /// - The impl must only return `true` for its argument if the original
3168 …/// [1] Per https://doc.rust-lang.org/nightly/reference/types/textual.html#layout-and-bit-validity:
3173 /// [2] Per https://doc.rust-lang.org/core/primitive.char.html#method.from_u32:
3177 /// [3] Per https://doc.rust-lang.org/core/primitive.char.html#method.from_u32:
3185 /// - `FromZeroes`, `AsBytes`, `Unaligned`: Per the reference [1], `str`
3194 /// [1] https://doc.rust-lang.org/reference/type-layout.html#str-layout
3197 /// - The safety requirements for `unsafe_impl!` with an `is_bit_valid`
3199 /// - Given `t: *mut str` and `let r = *mut [u8]`, `r` refers to an object
3202 /// - Since the closure takes a `&[u8]` argument, given a `Ptr<'a, str>`
3210 /// - The alignment of `str` is equal to the alignment of `[u8]`. [1]
3211 /// - The impl must only return `true` for its argument if the original
3215 /// [1] Per https://doc.rust-lang.org/reference/types/textual.html:
3219 /// [2] Per https://doc.rust-lang.org/core/str/fn.from_utf8.html#errors:
3221 /// Returns `Err` if the slice is not UTF-8.
3229 /// - `AsBytes`: `NonZeroXxx` has the same layout as its associated
3231 /// padding - integers have no padding, and there's no room for padding
3233 /// - `Unaligned`: `NonZeroU8` and `NonZeroI8` document that
3241 /// alignment for a 1-byte type is 1.
3245 /// [1] https://doc.rust-lang.org/stable/std/num/struct.NonZeroU8.html
3246 /// [2] https://doc.rust-lang.org/stable/std/num/struct.NonZeroI8.html
3247 /// TODO(https://github.com/rust-lang/rust/pull/104082): Cite documentation
3263 /// - The safety requirements for `unsafe_impl!` with an `is_bit_valid`
3265 /// - Given `t: *mut NonZeroXxx` and `let r = *mut xxx`, `r` refers to an
3268 /// - Since the closure takes a `&xxx` argument, given a `Ptr<'a,
3277 /// - The alignment of `NonZeroXxx` is equal to the alignment of `xxx`.
3279 /// - The impl must only return `true` for its argument if the original
3283 /// [1] Per https://doc.rust-lang.org/core/num/struct.NonZeroU16.html:
3302 /// - `TryFromBytes` (with no validator), `FromZeroes`, `FromBytes`,
3306 /// - `Unaligned`: `NonZeroU8` and `NonZeroI8` document that
3311 /// a 1-byte type is 1.
3315 /// [1] https://doc.rust-lang.org/stable/std/num/struct.NonZeroU8.html
3316 /// [2] https://doc.rust-lang.org/stable/std/num/struct.NonZeroI8.html
3318 /// TODO(https://github.com/rust-lang/rust/pull/104082): Cite documentation
3342 /// https://doc.rust-lang.org/nightly/core/option/index.html#representation:
3351 /// |-----------------------|-----------------------------------------------------------|
3358 /// TODO(#429), TODO(https://github.com/rust-lang/rust/pull/115333): Cite
3368 …unsafe_impl_for_power_set!(A, B, C, D, E, F, G, H, I, J, K, L -> M => FromZeroes for opt_fn!(...));
3369 …unsafe_impl_for_power_set!(A, B, C, D, E, F, G, H, I, J, K, L -> M => FromZeroes for opt_extern_c_…
3379 /// - `TryFromBytes` (with no validator), `FromZeroes`, `FromBytes`: There
3382 /// - `AsBytes`: Since `PhantomData` has size 0, it contains no padding
3384 /// - `Unaligned`: Per the preceding reference, `PhantomData` has alignment
3387 /// [1] https://doc.rust-lang.org/std/marker/struct.PhantomData.html#layout-1
3403 /// - `TryFromBytes`: The safety requirements for `unsafe_impl!` with an
3405 /// - Given `t: *mut Wrapping<T>` and `let r = *mut T`, `r` refers to an
3408 /// - The alignment of `Wrapping<T>` is equal to the alignment of `T`.
3409 /// - The impl must only return `true` for its argument if the original
3414 /// - `FromBytes`: Since `Wrapping<T>` has the same bit validity as `T`, if
3419 /// - `AsBytes`: Since `Wrapping<T>` has the same bit validity as `T`, if
3424 /// - `Unaligned`: Since `Wrapping<T>` has the same layout as `T`,
3427 /// [1] Per https://doc.rust-lang.org/core/num/struct.NonZeroU16.html:
3434 /// [1] TODO(https://doc.rust-lang.org/nightly/core/num/struct.Wrapping.html#layout-1):
3437 /// [2] https://doc.rust-lang.org/nomicon/other-reprs.html#reprtransparent
3440 // - Since `T` and `Wrapping<T>` have the same layout and bit validity
3445 // - By the same token, since `candidate` is guaranteed to have its
3461 /// - `TryFromBytes` (with no validator), `FromZeroes`, `FromBytes`:
3465 /// Thus, we require `T: Trait` in order to ensure that `T` - and thus
3466 /// `MaybeUninit<T>` - contains to `UnsafeCell`s. Thus, requiring that `T`
3468 /// - `Unaligned`: "MaybeUninit<T> is guaranteed to have the same size,
3471 /// [1] https://doc.rust-lang.org/stable/core/mem/union.MaybeUninit.html#layout-1
3489 /// - `FromZeroes`, `FromBytes`: Since it has the same layout as `T`, any
3494 /// - `AsBytes`: Since it has the same layout as `T`, and since it's unsound
3499 /// - `Unaligned`: `ManuallyDrop` has the same layout (and thus alignment)
3505 /// [1] Per https://doc.rust-lang.org/nightly/core/mem/struct.ManuallyDrop.html:
3508 /// - Add quotes from docs.
3509 /// - Once [1] (added in
3510 /// https://github.com/rust-lang/rust/pull/115522) is available on stable,
3523 /// alignment of `T`. Arrays are laid out so that the zero-based `nth`
3532 /// laid out back-to-back with no bytes in between. Therefore, `[T]` or `[T;
3540 /// [1] https://doc.rust-lang.org/reference/type-layout.html#array-layout
3553 // same alignment of `T`. Arrays are laid out so that the zero-based
3562 // back-to-back with no bytes in between. If all elements in `candidate`
3589 /// - `FromZeroes`: For thin pointers (note that `T: Sized`), the zero
3598 /// [1] TODO(https://github.com/rust-lang/rust/pull/116988): Cite the
3608 // Packed SIMD vector types are `repr(simd)` homogeneous tuple-structs
3609 // containing `N` elements of type `T` where `N` is a power-of-two and the
3614 // struct Vector<T, N>(T_0, ..., T_(N - 1));
3620 // implementation-defined function of `T` and `N` greater than or equal to
3638 // let u = U { vec: Vector<T, N>(t_0, ..., t_(N - 1)) };
3642 // assert_eq!(u.vec.(N - 1), u.arr[N - 1]);
3647 // - The size and bit pattern requirements of a SIMD type are equivalent to the
3651 // - Since no upper bound is placed on the alignment, no SIMD type can be
3666 // [1] https://rust-lang.github.io/unsafe-code-guidelines/layout/packed-simd-vectors.html
3667 // [2] https://github.com/rust-lang/unsafe-code-guidelines/issues/38
3699 #[rustfmt::skip]
3706 #[cfg(all(feature = "simd-nightly", target_arch = "x86"))]
3714 #[cfg(all(feature = "simd-nightly", target_arch = "x86_64"))]
3722 #[cfg(all(feature = "simd-nightly", target_arch = "powerpc"))]
3726 #[cfg(all(feature = "simd-nightly", target_arch = "powerpc64"))]
3740 #[cfg(all(feature = "simd-nightly", target_arch = "arm"))]
3848 /// error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
3849 /// --> src/lib.rs:1524:34
3856 …the expansion of the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for mor…
3907 // - We know that `Src: AsBytes` and `Dst: FromBytes` thanks to the
3909 // - We know that `size_of::<Src>() == size_of::<Dst>()` thanks to
3911 // - We know that `align_of::<Src>() >= align_of::<Dst>()` thanks to
3958 /// error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
3959 /// --> src/lib.rs:1524:34
3966 …the expansion of the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for mor…
4034 // - We know that `Src: FromBytes + AsBytes` and `Dst: FromBytes +
4038 // - We know that `size_of::<Src>() == size_of::<Dst>()` thanks to
4040 // - We know that `align_of::<Src>() >= align_of::<Dst>()` thanks to
4054 /// are found). The provided path is interpreted in a platform-specific way at
4058 /// `include_value!` is ignorant of byte order. For byte order-aware types, see
4126 /// pub fn parse(bytes: B) -> Option<UdpPacket<B>> {
4131 /// pub fn get_src_port(&self) -> [u8; 2] {
4160 pub fn new(bytes: B) -> Option<Ref<B, T>> { in new()
4175 pub fn new_from_prefix(bytes: B) -> Option<(Ref<B, T>, B)> { in new_from_prefix()
4192 pub fn new_from_suffix(bytes: B) -> Option<(B, Ref<B, T>)> { in new_from_suffix()
4216 /// `new_slice` panics if `T` is a zero-sized type.
4218 pub fn new_slice(bytes: B) -> Option<Ref<B, [T]>> { in new_slice()
4222 .expect("Ref::new_slice called on a zero-sized type"); in new_slice()
4240 /// `new_slice_from_prefix` panics if `T` is a zero-sized type.
4242 pub fn new_slice_from_prefix(bytes: B, count: usize) -> Option<(Ref<B, [T]>, B)> { in new_slice_from_prefix()
4265 /// `new_slice_from_suffix` panics if `T` is a zero-sized type.
4267 pub fn new_slice_from_suffix(bytes: B, count: usize) -> Option<(B, Ref<B, [T]>)> { in new_slice_from_suffix()
4278 fn map_zeroed<B: ByteSliceMut, T: ?Sized>(opt: Option<Ref<B, T>>) -> Option<Ref<B, T>> { in map_zeroed()
4290 ) -> Option<(Ref<B, T>, B)> { in map_prefix_tuple_zeroed()
4302 ) -> Option<(B, Ref<B, T>)> { in map_suffix_tuple_zeroed()
4317 /// can be useful when re-using buffers to ensure that sensitive data
4320 pub fn new_zeroed(bytes: B) -> Option<Ref<B, T>> { in new_zeroed()
4334 /// initialized to zero. This can be useful when re-using buffers to ensure
4337 pub fn new_from_prefix_zeroed(bytes: B) -> Option<(Ref<B, T>, B)> { in new_from_prefix_zeroed()
4352 /// initialized to zero. This can be useful when re-using buffers to ensure
4355 pub fn new_from_suffix_zeroed(bytes: B) -> Option<(B, Ref<B, T>)> { in new_from_suffix_zeroed()
4372 /// can be useful when re-using buffers to ensure that sensitive data
4377 /// `new_slice` panics if `T` is a zero-sized type.
4379 pub fn new_slice_zeroed(bytes: B) -> Option<Ref<B, [T]>> { in new_slice_zeroed()
4394 /// initialized to zero. This can be useful when re-using buffers to ensure
4399 /// `new_slice_from_prefix_zeroed` panics if `T` is a zero-sized type.
4401 pub fn new_slice_from_prefix_zeroed(bytes: B, count: usize) -> Option<(Ref<B, [T]>, B)> { in new_slice_from_prefix_zeroed()
4416 /// zero. This can be useful when re-using buffers to ensure that sensitive
4421 /// `new_slice_from_suffix_zeroed` panics if `T` is a zero-sized type.
4423 pub fn new_slice_from_suffix_zeroed(bytes: B, count: usize) -> Option<(B, Ref<B, [T]>)> { in new_slice_from_suffix_zeroed()
4438 pub fn new_unaligned(bytes: B) -> Option<Ref<B, T>> { in new_unaligned()
4450 pub fn new_unaligned_from_prefix(bytes: B) -> Option<(Ref<B, T>, B)> { in new_unaligned_from_prefix()
4462 pub fn new_unaligned_from_suffix(bytes: B) -> Option<(B, Ref<B, T>)> { in new_unaligned_from_suffix()
4480 /// `new_slice` panics if `T` is a zero-sized type.
4482 pub fn new_slice_unaligned(bytes: B) -> Option<Ref<B, [T]>> { in new_slice_unaligned()
4498 /// `new_slice_unaligned_from_prefix` panics if `T` is a zero-sized type.
4500 pub fn new_slice_unaligned_from_prefix(bytes: B, count: usize) -> Option<(Ref<B, [T]>, B)> { in new_slice_unaligned_from_prefix()
4515 /// `new_slice_unaligned_from_suffix` panics if `T` is a zero-sized type.
4517 pub fn new_slice_unaligned_from_suffix(bytes: B, count: usize) -> Option<(B, Ref<B, [T]>)> { in new_slice_unaligned_from_suffix()
4534 /// can be useful when re-using buffers to ensure that sensitive data
4537 pub fn new_unaligned_zeroed(bytes: B) -> Option<Ref<B, T>> { in new_unaligned_zeroed()
4550 /// initialized to zero. This can be useful when re-using buffers to ensure
4553 pub fn new_unaligned_from_prefix_zeroed(bytes: B) -> Option<(Ref<B, T>, B)> { in new_unaligned_from_prefix_zeroed()
4566 /// initialized to zero. This can be useful when re-using buffers to ensure
4569 pub fn new_unaligned_from_suffix_zeroed(bytes: B) -> Option<(B, Ref<B, T>)> { in new_unaligned_from_suffix_zeroed()
4587 /// can be useful when re-using buffers to ensure that sensitive data
4592 /// `new_slice` panics if `T` is a zero-sized type.
4594 pub fn new_slice_unaligned_zeroed(bytes: B) -> Option<Ref<B, [T]>> { in new_slice_unaligned_zeroed()
4609 /// can be useful when re-using buffers to ensure that sensitive data
4614 /// `new_slice_unaligned_from_prefix_zeroed` panics if `T` is a zero-sized
4620 ) -> Option<(Ref<B, [T]>, B)> { in new_slice_unaligned_from_prefix_zeroed()
4634 /// can be useful when re-using buffers to ensure that sensitive data
4639 /// `new_slice_unaligned_from_suffix_zeroed` panics if `T` is a zero-sized
4645 ) -> Option<(B, Ref<B, [T]>)> { in new_slice_unaligned_from_suffix_zeroed()
4659 pub fn into_ref(self) -> &'a T { in into_ref()
4679 pub fn into_mut(mut self) -> &'a mut T { in into_mut()
4700 pub fn into_slice(self) -> &'a [T] { in into_slice()
4721 pub fn into_mut_slice(mut self) -> &'a mut [T] { in into_mut_slice()
4749 unsafe fn deref_helper<'a>(&self) -> &'a T { in deref_helper()
4772 /// and no other references - mutable or immutable - to the same memory may
4774 unsafe fn deref_mut_helper<'a>(&mut self) -> &'a mut T { in deref_mut_helper()
4793 unsafe fn deref_slice_helper<'a>(&self) -> &'a [T] { in deref_slice_helper()
4823 unsafe fn deref_mut_slice_helper<'a>(&mut self) -> &'a mut [T] { in deref_mut_slice_helper()
4849 pub fn bytes(&self) -> &[u8] { in bytes()
4861 pub fn bytes_mut(&mut self) -> &mut [u8] { in bytes_mut()
4873 pub fn read(&self) -> T { in read()
4906 fn deref(&self) -> &T { in deref()
4923 fn deref_mut(&mut self) -> &mut T { in deref_mut()
4941 fn deref(&self) -> &[T] { in deref()
4958 fn deref_mut(&mut self) -> &mut [T] { in deref_mut()
4975 fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { in fmt()
4988 fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { in fmt()
5000 fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { in fmt()
5012 fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { in fmt()
5038 fn eq(&self, other: &Self) -> bool { in eq()
5049 fn eq(&self, other: &Self) -> bool { in eq()
5060 fn cmp(&self, other: &Self) -> Ordering { in cmp()
5073 fn cmp(&self, other: &Self) -> Ordering { in cmp()
5086 fn partial_cmp(&self, other: &Self) -> Option<Ordering> { in partial_cmp()
5099 fn partial_cmp(&self, other: &Self) -> Option<Ordering> { in partial_cmp()
5116 // unsafe code. Thus, we seal them and implement it only for known-good
5133 // breaks. We do this because it simplifies CI - it means that generating docs
5139 doc = "[`Vec<u8>`]: https://doc.rust-lang.org/std/vec/struct.Vec.html"
5152 /// - `Self: 'a`
5153 /// - `bytes: Self`
5154 /// - `let ptr = bytes.as_ptr()`
5157 /// - Using `ptr` to read the memory previously addressed by `bytes` is
5159 /// - If `Self: ByteSliceMut`, using `ptr` to write the memory previously
5167 fn as_ptr(&self) -> *const u8 { in as_ptr()
5178 fn split_at(self, mid: usize) -> (Self, Self); in split_at()
5190 fn as_mut_ptr(&mut self) -> *mut u8 { in as_mut_ptr()
5204 fn split_at(self, mid: usize) -> (Self, Self) { in split_at()
5218 fn split_at(self, mid: usize) -> (Self, Self) { in split_at()
5231 // to succeed. This doesn't represent a soundness hole - it just delays
5238 fn split_at(self, mid: usize) -> (Self, Self) { in split_at()
5251 // to succeed. This doesn't represent a soundness hole - it just delays
5258 fn split_at(self, mid: usize) -> (Self, Self) { in split_at()
5305 // `v.len() - position` cannot overflow because we asserted that in insert_vec_zeroed()
5311 ptr.add(position).copy_to(ptr.add(position + additional), v.len() - position); in insert_vec_zeroed()
5507 // gets a hand-rolled impl, so it doesn't exercise our custom derives.
5513 fn from_mut_slice(slc: &mut [u8]) -> &mut Unsized { in from_mut_slice()
5514 // SAFETY: This *probably* sound - since the layouts of `[u8]` and in from_mut_slice()
5520 // [1] https://github.com/rust-lang/unsafe-code-guidelines/issues/375 in from_mut_slice()
5530 // with a zero-sized trailing field of given alignment `n`. The macro in test_dst_layout_extend_sized_with_sized()
5591 // Test that for all combinations of real-world alignments and in test_dst_layout_extend_sized_with_dst()
5637 // For all valid alignments `align`, construct a one-byte layout aligned in test_dst_layout_pad_to_align_with_sized()
5649 // Test explicitly-provided combinations of unpadded and padded in test_dst_layout_pad_to_align_with_sized()
5690 /// Tests that calling `pad_to_align` on a DST `DstLayout` is a no-op.
5716 fn from(_size: usize) -> SizeInfo { in testvalidate_cast_and_convert_metadata()
5722 fn from((_offset, _elem_size): (usize, usize)) -> SizeInfo { in testvalidate_cast_and_convert_metadata()
5727 fn layout<S: Into<SizeInfo>>(s: S, align: usize) -> DstLayout { in testvalidate_cast_and_convert_metadata()
5735 /// base_size ----+ | | | | | | | in testvalidate_cast_and_convert_metadata()
5736 /// align -----------+ | | | | | | in testvalidate_cast_and_convert_metadata()
5737 /// trailing_size ------+ | | | | | in testvalidate_cast_and_convert_metadata()
5738 /// addr ---------------------------+ | | | | in testvalidate_cast_and_convert_metadata()
5739 /// bytes_len -------------------------+ | | | in testvalidate_cast_and_convert_metadata()
5740 /// cast_type ----------------------------+ | | in testvalidate_cast_and_convert_metadata()
5741 /// elems ---------------------------------------------+ | in testvalidate_cast_and_convert_metadata()
5742 /// split_at ---------------------------------------------+ in testvalidate_cast_and_convert_metadata()
5756 /// - If it is `Ok(pat)`, then the pattern `pat` is supplied to in testvalidate_cast_and_convert_metadata()
5759 /// - If it is `Err(msg)`, then `test!` validates that the call to in testvalidate_cast_and_convert_metadata()
5763 /// Note that the meta-variables that match these variables have the in testvalidate_cast_and_convert_metadata()
5782 // problem, but if a non-caught panic ever happens (ie, in in testvalidate_cast_and_convert_metadata()
5784 // previously-buffered messages will be dumped, hiding the in testvalidate_cast_and_convert_metadata()
5859 // `Err(TRAILING)`, which would run into a subtle Rust footgun - the in testvalidate_cast_and_convert_metadata()
5864 "attempted to cast to slice type with zero-sized element"; in testvalidate_cast_and_convert_metadata()
5934 assert_eq!(split_at, bytes_len - resulting_size, "{}", debug_str); in testvalidate_cast_and_convert_metadata()
5979 // built-in APIs to confirm that Rust makes decisions about type layout in test_validate_rust_layout()
5982 // - it means we're misunderstanding the language's guarantees. in test_validate_rust_layout()
5997 fn test<T: ?Sized, W: Fn(usize) -> NonNull<T>>( in test_validate_rust_layout()
6000 addr_of_slice_field: Option<fn(NonNull<T>) -> NonNull<u8>>, in test_validate_rust_layout()
6059 // - For sized types, `without_padding` is just the size of the in test_validate_rust_layout()
6063 // - For unsized types, `without_padding` is dynamically in test_validate_rust_layout()
6072 // For zero-sized element types, in test_validate_rust_layout()
6096 // of elements that can fit in `size` - in other in test_validate_rust_layout()
6138 // pointers - we just do arithmetic on them - so having a "real" in test_validate_rust_layout()
6139 // block of memory as opposed to a validly-aligned-but-dangling in test_validate_rust_layout()
6150 let f = None::<fn(NonNull<Foo>) -> NonNull<u8>>; in test_validate_rust_layout()
6154 … let f: Option<fn(NonNull<Foo>) -> NonNull<u8>> = Some(|ptr: NonNull<Foo>| unsafe { in test_validate_rust_layout()
6167 // - offset in [0, 4] in test_validate_rust_layout()
6168 // - align in [1, 16] in test_validate_rust_layout()
6169 // - elem_size in [0, 4] (plus no elem_size) in test_validate_rust_layout()
6369 // +------------+--------------------------------------+-----------+ in test_known_layout_derive()
6372 // |------------+----------+----------------+----------+-----------| in test_known_layout_derive()
6389 // +------------+----------+----------------+----------+-----------+ in test_known_layout_derive()
6521 fn _test_kl05<T>(t: T) -> impl KnownLayout { in test_known_layout_derive()
6531 fn _test_kl07<T: KnownLayout>(t: T) -> impl KnownLayout { in test_known_layout_derive()
6669 fn _test_kl15<T: KnownLayout>(t: T) -> impl KnownLayout { in test_known_layout_derive()
6674 // - () in test_known_layout_derive()
6675 // - u8 in test_known_layout_derive()
6676 // - AU16 in test_known_layout_derive()
6677 // - [()] in test_known_layout_derive()
6678 // - [u8] in test_known_layout_derive()
6679 // - [AU16] in test_known_layout_derive()
7069 // Test that a properly-aligned, properly-sized buffer works for new, in test_new_aligned_sized()
7071 // new_from_suffix return empty slices. Test that a properly-aligned in test_new_aligned_sized()
7157 // Test that an unaligned, properly-sized buffer works for in test_new_unaligned_sized()
7242 // Test that a properly-aligned, overly-sized buffer works for in test_new_oversized()
7282 // Test than an unaligned, overly-sized buffer works for in test_new_unaligned_oversized()
7333 // The `[u8:9]` is a non-half size of the full buffer, which would catch in test_ref_from_mut_from()
7486 // Tests for ensuring that, if a ZST is passed into a slice-like function,
7487 // we always panic. Since these tests need to be separate per-function, and
7489 // submodule instead. The submodule ensures that we can just re-use the name
7495 … #[should_panic = concat!("Ref::", $constructor_in_panic_msg, " called on a zero-sized type")]
7543 assert_eq!(t.write_to(&mut vec![0; N - 1][..]), None); in test_as_bytes_methods()
7552 assert_eq!(t.write_to_prefix(&mut vec![0; N - 1][..]), None); in test_as_bytes_methods()
7554 // `write_to_prefix` works with exact-sized slices. in test_as_bytes_methods()
7559 // `write_to_prefix` works with too-large slices, and any bytes past in test_as_bytes_methods()
7568 assert_eq!(t.write_to_suffix(&mut vec![0; N - 1][..]), None); in test_as_bytes_methods()
7570 // `write_to_suffix` works with exact-sized slices. in test_as_bytes_methods()
7575 // `write_to_suffix` works with too-large slices, and any bytes in test_as_bytes_methods()
7811 // - Since `val` is a normal reference, `c` is guranteed to in test_impls()
7814 // - Since `val` is a valid `$ty`, `c`'s referent satisfies in test_impls()
7921 #[rustfmt::skip] in test_impls()
7924 ) -> (NotZerocopy, NotZerocopy); in test_impls()
7928 #[rustfmt::skip] in test_impls()
7931 ) -> (NotZerocopy, NotZerocopy); in test_impls()
7994 #[cfg(all(feature = "simd-nightly", target_arch = "x86"))] in test_impls()
8000 #[cfg(all(feature = "simd-nightly", target_arch = "x86_64"))] in test_impls()
8006 #[cfg(all(feature = "simd-nightly", target_arch = "powerpc"))] in test_impls()
8015 #[cfg(all(feature = "simd-nightly", target_arch = "powerpc64"))] in test_impls()
8024 #[rustfmt::skip] in test_impls()
8034 #[cfg(all(feature = "simd-nightly", target_arch = "arm"))] in test_impls()
8035 #[rustfmt::skip] in test_impls()
8046 fn any() -> Self { in any()
8074 fn any() -> Self { in any()
8091 fn any() -> Self { in any()
8129 // [1] Per https://doc.rust-lang.org/reference/type-layout.html#the-alignment-modifiers: in prove_dst_layout_extend()
8140 // Compute the minimum amount of inter-field padding needed to in prove_dst_layout_extend()
8144 // [1] Per https://doc.rust-lang.org/reference/type-layout.html#the-alignment-modifiers: in prove_dst_layout_extend()
8146 // Inter-field padding is guaranteed to be the minimum required in in prove_dst_layout_extend()
8152 // stand-ins for `DstLayout`, and show that `extend` behaves in prove_dst_layout_extend()
8162 // size of inter-field padding between the two. in prove_dst_layout_extend()