diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0f7a53a455..609269fcdd4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: matrix: # See `INTERNAL.md` for an explanation of these pinned toolchain # versions. - toolchain: [ "msrv", "stable", "nightly", "zerocopy-aarch64-simd", "zerocopy-generic-bounds-in-const-fn" ] + toolchain: [ "msrv", "stable", "nightly", "zerocopy-generic-bounds-in-const-fn", "zerocopy-aarch64-simd", "zerocopy-panic-in-const", ] target: [ "i686-unknown-linux-gnu", "x86_64-unknown-linux-gnu", @@ -59,10 +59,13 @@ jobs: features: "--all-features" - toolchain: "stable" features: "--all-features" + - toolchain: "zerocopy-generic-bounds-in-const-fn" + features: "--all-features" - toolchain: "zerocopy-aarch64-simd" features: "--all-features" - - toolchain: "zerocopy-generic-bounds-in-const-fn" + - toolchain: "zerocopy-panic-in-const" features: "--all-features" + # Exclude any combination for the zerocopy-derive crate which # uses zerocopy features. - crate: "zerocopy-derive" @@ -75,10 +78,12 @@ jobs: # other than "msrv", "stable", and "nightly". These other versions # exist to exercise zerocopy behavior which differs by toolchain; # zerocopy-derive doesn't behave different on these toolchains. + - crate: "zerocopy-derive" + toolchain: "zerocopy-generic-bounds-in-const-fn" - crate: "zerocopy-derive" toolchain: "zerocopy-aarch64-simd" - crate: "zerocopy-derive" - toolchain: "zerocopy-generic-bounds-in-const-fn" + toolchain: "zerocopy-panic-in-const" name: Build & Test (crate:${{ matrix.crate }}, toolchain:${{ matrix.toolchain }}, target:${{ matrix.target }}, features:${{ matrix.features }}) diff --git a/Cargo.toml b/Cargo.toml index db69c2372ef..4c0e187e181 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ authors = ["Joshua Liebow-Feeser "] description = "Utilities for zero-copy parsing and serialization" license = "BSD-2-Clause OR Apache-2.0 OR MIT" repository = "https://github.com/google/zerocopy" -rust-version = "1.57.0" +rust-version = "1.56.0" exclude = [".*"] @@ -30,13 +30,16 @@ exclude = [".*"] # as high as the specified version. In the emitted `--cfg`, dashes are replaced # by underscores. +# From 1.61.0, Rust supports generic types with trait bounds in `const fn`. +zerocopy-generic-bounds-in-const-fn = "1.61.0" + # When the "simd" feature is enabled, include SIMD types from the # `core::arch::aarch64` module, which was stabilized in 1.59.0. On earlier Rust # versions, these types require the "simd-nightly" feature. zerocopy-aarch64-simd = "1.59.0" -# From 1.61.0, Rust supports generic types with trait bounds in `const fn`. -zerocopy-generic-bounds-in-const-fn = "1.61.0" +# Permit panicking in `const fn`s. +zerocopy-panic-in-const = "1.57.0" [package.metadata.ci] # The versions of the stable and nightly compiler toolchains to use in CI. diff --git a/src/lib.rs b/src/lib.rs index 7d12522f4cb..a617162931a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -363,13 +363,15 @@ pub struct DstLayout { size_info: SizeInfo, } -#[cfg_attr(any(kani, test), derive(Copy, Clone, Debug, PartialEq, Eq))] +#[cfg_attr(any(kani, test), derive(Debug, PartialEq, Eq))] +#[derive(Copy, Clone)] enum SizeInfo { Sized { _size: usize }, SliceDst(TrailingSliceLayout), } -#[cfg_attr(any(kani, test), derive(Copy, Clone, Debug, PartialEq, Eq))] +#[cfg_attr(any(kani, test), derive(Debug, PartialEq, Eq))] +#[derive(Copy, Clone)] struct TrailingSliceLayout { // The offset of the first byte of the trailing slice field. Note that this // is NOT the same as the minimum size of the type. For example, consider @@ -419,7 +421,7 @@ impl DstLayout { /// The minimum possible alignment of a type. const MIN_ALIGN: NonZeroUsize = match NonZeroUsize::new(1) { Some(min_align) => min_align, - None => unreachable!(), + None => const_unreachable!(), }; /// The maximum theoretic possible alignment of a type. @@ -430,7 +432,7 @@ impl DstLayout { const THEORETICAL_MAX_ALIGN: NonZeroUsize = match NonZeroUsize::new(1 << (POINTER_WIDTH_BITS - 1)) { Some(max_align) => max_align, - None => unreachable!(), + None => const_unreachable!(), }; /// The current, documented max alignment of a type \[1\]. @@ -442,7 +444,7 @@ impl DstLayout { #[cfg(not(kani))] const CURRENT_MAX_ALIGN: NonZeroUsize = match NonZeroUsize::new(1 << 28) { Some(max_align) => max_align, - None => unreachable!(), + None => const_unreachable!(), }; /// Constructs a `DstLayout` for a zero-sized type with `repr_align` @@ -464,7 +466,7 @@ impl DstLayout { None => Self::MIN_ALIGN, }; - assert!(align.get().is_power_of_two()); + const_assert!(align.get().is_power_of_two()); DstLayout { align, size_info: SizeInfo::Sized { _size: 0 } } } @@ -483,7 +485,7 @@ impl DstLayout { DstLayout { align: match NonZeroUsize::new(mem::align_of::()) { Some(align) => align, - None => unreachable!(), + None => const_unreachable!(), }, size_info: SizeInfo::Sized { _size: mem::size_of::() }, } @@ -506,7 +508,7 @@ impl DstLayout { DstLayout { align: match NonZeroUsize::new(mem::align_of::()) { Some(align) => align, - None => unreachable!(), + None => const_unreachable!(), }, size_info: SizeInfo::SliceDst(TrailingSliceLayout { _offset: 0, @@ -552,17 +554,17 @@ impl DstLayout { None => Self::THEORETICAL_MAX_ALIGN, }; - assert!(max_align.get().is_power_of_two()); + const_assert!(max_align.get().is_power_of_two()); // We use Kani to prove that this method is robust to future increases // in Rust's maximum allowed alignment. However, if such a change ever // actually occurs, we'd like to be notified via assertion failures. #[cfg(not(kani))] { - debug_assert!(self.align.get() <= DstLayout::CURRENT_MAX_ALIGN.get()); - debug_assert!(field.align.get() <= DstLayout::CURRENT_MAX_ALIGN.get()); + const_debug_assert!(self.align.get() <= DstLayout::CURRENT_MAX_ALIGN.get()); + const_debug_assert!(field.align.get() <= DstLayout::CURRENT_MAX_ALIGN.get()); if let Some(repr_packed) = repr_packed { - debug_assert!(repr_packed.get() <= DstLayout::CURRENT_MAX_ALIGN.get()); + const_debug_assert!(repr_packed.get() <= DstLayout::CURRENT_MAX_ALIGN.get()); } } @@ -583,7 +585,7 @@ impl DstLayout { let size_info = match self.size_info { // If the layout is already a DST, we panic; DSTs cannot be extended // with additional fields. - SizeInfo::SliceDst(..) => panic!("Cannot extend a DST with additional fields."), + SizeInfo::SliceDst(..) => const_panic!("Cannot extend a DST with additional fields."), SizeInfo::Sized { _size: preceding_size } => { // Compute the minimum amount of inter-field padding needed to @@ -604,7 +606,7 @@ impl DstLayout { // exceeding `isize::MAX`). let offset = match preceding_size.checked_add(padding) { Some(offset) => offset, - None => panic!("Adding padding to `self`'s size overflows `usize`."), + None => const_panic!("Adding padding to `self`'s size overflows `usize`."), }; match field.size_info { @@ -622,7 +624,7 @@ impl DstLayout { // `usize::MAX`). let size = match offset.checked_add(field_size) { Some(size) => size, - None => panic!("`field` cannot be appended without the total size overflowing `usize`"), + None => const_panic!("`field` cannot be appended without the total size overflowing `usize`"), }; SizeInfo::Sized { _size: size } } @@ -644,7 +646,7 @@ impl DstLayout { // `usize::MAX`). let offset = match offset.checked_add(trailing_offset) { Some(offset) => offset, - None => panic!("`field` cannot be appended without the total size overflowing `usize`"), + None => const_panic!("`field` cannot be appended without the total size overflowing `usize`"), }; SizeInfo::SliceDst(TrailingSliceLayout { _offset: offset, _elem_size }) } @@ -691,7 +693,7 @@ impl DstLayout { let padding = padding_needed_for(unpadded_size, self.align); let size = match unpadded_size.checked_add(padding) { Some(size) => size, - None => panic!("Adding padding caused size to overflow `usize`."), + None => const_panic!("Adding padding caused size to overflow `usize`."), }; SizeInfo::Sized { _size: size } } @@ -777,9 +779,9 @@ impl DstLayout { cast_type: _CastType, ) -> Option<(usize, usize)> { // `debug_assert!`, but with `#[allow(clippy::arithmetic_side_effects)]`. - macro_rules! __debug_assert { + macro_rules! __const_debug_assert { ($e:expr $(, $msg:expr)?) => { - debug_assert!({ + const_debug_assert!({ #[allow(clippy::arithmetic_side_effects)] let e = $e; e @@ -798,11 +800,14 @@ impl DstLayout { // https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html#let-else-statements let size_info = match self.size_info.try_to_nonzero_elem_size() { Some(size_info) => size_info, - None => panic!("attempted to cast to slice type with zero-sized element"), + None => const_panic!("attempted to cast to slice type with zero-sized element"), }; // Precondition - __debug_assert!(addr.checked_add(bytes_len).is_some(), "`addr` + `bytes_len` > usize::MAX"); + __const_debug_assert!( + addr.checked_add(bytes_len).is_some(), + "`addr` + `bytes_len` > usize::MAX" + ); // Alignment checks go in their own block to avoid introducing variables // into the top-level scope. @@ -898,7 +903,7 @@ impl DstLayout { } }; - __debug_assert!(self_bytes <= bytes_len); + __const_debug_assert!(self_bytes <= bytes_len); let split_at = match cast_type { _CastType::_Prefix => self_bytes, @@ -3951,7 +3956,7 @@ macro_rules! transmute_ref { // `t` is inferred to have type `T` because it's assigned to `e` (of // type `&T`) as `&t`. - let mut t = unreachable!(); + let mut t = loop {}; e = &t; // `u` is inferred to have type `U` because it's used as `&u` as the @@ -4096,7 +4101,7 @@ macro_rules! transmute_mut { // `t` is inferred to have type `T` because it's assigned to `e` (of // type `&mut T`) as `&mut t`. - let mut t = unreachable!(); + let mut t = loop {}; e = &mut t; // `u` is inferred to have type `U` because it's used as `&mut u` as @@ -5324,7 +5329,7 @@ impl<'a> sealed::ByteSliceSealed for cell::Ref<'a, [u8]> {} #[allow(clippy::undocumented_unsafe_blocks)] unsafe impl<'a> ByteSlice for cell::Ref<'a, [u8]> { const INTO_REF_INTO_MUT_ARE_SOUND: bool = if !cfg!(doc) { - panic!("Ref::into_ref and Ref::into_mut are unsound when used with core::cell::Ref; see https://github.com/google/zerocopy/issues/716") + const_panic!("Ref::into_ref and Ref::into_mut are unsound when used with core::cell::Ref; see https://github.com/google/zerocopy/issues/716") } else { // When compiling documentation, allow the evaluation of this constant // to succeed. This doesn't represent a soundness hole - it just delays @@ -5344,7 +5349,7 @@ impl<'a> sealed::ByteSliceSealed for RefMut<'a, [u8]> {} #[allow(clippy::undocumented_unsafe_blocks)] unsafe impl<'a> ByteSlice for RefMut<'a, [u8]> { const INTO_REF_INTO_MUT_ARE_SOUND: bool = if !cfg!(doc) { - panic!("Ref::into_ref and Ref::into_mut are unsound when used with core::cell::RefMut; see https://github.com/google/zerocopy/issues/716") + const_panic!("Ref::into_ref and Ref::into_mut are unsound when used with core::cell::RefMut; see https://github.com/google/zerocopy/issues/716") } else { // When compiling documentation, allow the evaluation of this constant // to succeed. This doesn't represent a soundness hole - it just delays @@ -5810,7 +5815,7 @@ mod tests { // attempt to expose UB. #[test] #[cfg_attr(miri, ignore)] - fn testvalidate_cast_and_convert_metadata() { + fn test_validate_cast_and_convert_metadata() { impl From for SizeInfo { fn from(_size: usize) -> SizeInfo { SizeInfo::Sized { _size } @@ -5855,9 +5860,16 @@ mod tests { /// - If it is `Ok(pat)`, then the pattern `pat` is supplied to /// `assert_matches!` to validate the computed result for each /// combination of input values. - /// - If it is `Err(msg)`, then `test!` validates that the call to - /// `validate_cast_and_convert_metadata` panics with the given panic - /// message. + /// - If it is `Err(Some(msg) | None)`, then `test!` validates that the + /// call to `validate_cast_and_convert_metadata` panics with the given + /// panic message or, if the current Rust toolchain version is too + /// early to support panicking in `const fn`s, panics with *some* + /// message. In the latter case, the `const_panic!` macro is used, + /// which emits code which causes a non-panicking error at const eval + /// time, but which does panic when invoked at runtime. Thus, it is + /// merely difficult to predict the *value* of this panic. We deem + /// that testing against the real panic strings on stable and nightly + /// toolchains is enough to ensure correctness. /// /// Note that the meta-variables that match these variables have the /// `tt` type, and some valid expressions are not valid `tt`s (such as @@ -5889,7 +5901,9 @@ mod tests { let actual = std::panic::catch_unwind(|| { layout(size_info, align).validate_cast_and_convert_metadata(addr, bytes_len, cast_type) }).map_err(|d| { - *d.downcast::<&'static str>().expect("expected string panic message").as_ref() + let msg = d.downcast::<&'static str>().ok().map(|s| *s.as_ref()); + assert!(msg.is_some() || cfg!(zerocopy_panic_in_const), "non-string panic messages are only permitted when `--cfg zerocopy_panic_in_const`"); + msg }); std::panic::set_hook(previous_hook); @@ -5965,18 +5979,18 @@ mod tests { } // casts with ZST trailing element types are unsupported - test!(layout((_, [0]), _).validate(_, _, _), Err(msgs::TRAILING),); + test!(layout((_, [0]), _).validate(_, _, _), Err(Some(msgs::TRAILING) | None),); // addr + bytes_len must not overflow usize - test!(layout(_, _).validate([usize::MAX], (1..100), _), Err(msgs::OVERFLOW)); - test!(layout(_, _).validate((1..100), [usize::MAX], _), Err(msgs::OVERFLOW)); + test!(layout(_, _).validate([usize::MAX], (1..100), _), Err(Some(msgs::OVERFLOW) | None)); + test!(layout(_, _).validate((1..100), [usize::MAX], _), Err(Some(msgs::OVERFLOW) | None)); test!( layout(_, _).validate( [usize::MAX / 2 + 1, usize::MAX], [usize::MAX / 2 + 1, usize::MAX], _ ), - Err(msgs::OVERFLOW) + Err(Some(msgs::OVERFLOW) | None) ); // Validates that `validate_cast_and_convert_metadata` satisfies its own diff --git a/src/macros.rs b/src/macros.rs index f516d73b792..e926163ed5a 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -433,3 +433,75 @@ macro_rules! maybe_const_trait_bounded_fn { $(#[$attr])* $vis fn $name($($args $(: $arg_tys)?),*) $(-> $ret_ty)? $body }; } + +/// Either panic (if the current Rust toolchain supports panicking in `const +/// fn`) or evaluate a constant that will cause an array indexing error whose +/// error message will include the format string. +/// +/// The type that this expression evaluates to must be `Copy`, or else the +/// non-panicking desugaring will fail to compile. +macro_rules! const_panic { + ($fmt:literal) => {{ + #[cfg(zerocopy_panic_in_const)] + panic!($fmt); + #[cfg(not(zerocopy_panic_in_const))] + const_panic!(@non_panic $fmt) + }}; + (@non_panic $fmt:expr) => {{ + // This will type check to whatever type is expected based on the call + // site. + let panic: [_; 0] = []; + // This will always fail (since we're indexing into an array of size 0. + #[allow(unconditional_panic)] + panic[0] + }} +} + +/// Either assert (if the current Rust toolchain supports panicking in `const +/// fn`) or evaluate the expression and, if it evaluates to `false`, call +/// `const_panic!`. +macro_rules! const_assert { + ($e:expr) => {{ + #[cfg(zerocopy_panic_in_const)] + assert!($e); + #[cfg(not(zerocopy_panic_in_const))] + { + let e = $e; + if !e { + let _: () = const_panic!(@non_panic concat!("assertion failed: ", stringify!($e))); + } + } + }} +} + +/// Like `const_assert!`, but relative to `debug_assert!`. +macro_rules! const_debug_assert { + ($e:expr $(, $msg:expr)?) => {{ + #[cfg(zerocopy_panic_in_const)] + debug_assert!($e $(, $msg)?); + #[cfg(not(zerocopy_panic_in_const))] + { + // Use this (rather than `#[cfg(debug_assertions)]`) to ensure that + // `$e` is always compiled even if it will never be evaluated at + // runtime. + if cfg!(debug_assertions) { + let e = $e; + if !e { + let _: () = const_panic!(@non_panic concat!("assertion failed: ", stringify!($e) $(, ": ", $msg)?)); + } + } + } + }} +} + +/// Either invoke `unreachable!()` or `loop {}` depending on whether the Rust +/// toolchain supports panicking in `const fn`. +macro_rules! const_unreachable { + () => {{ + #[cfg(zerocopy_panic_in_const)] + unreachable!(); + + #[cfg(not(zerocopy_panic_in_const))] + loop {} + }}; +} diff --git a/src/util.rs b/src/util.rs index 2ba2f94b48c..0d3474b74a4 100644 --- a/src/util.rs +++ b/src/util.rs @@ -129,6 +129,7 @@ pub(crate) const fn round_down_to_next_multiple_of_alignment( align: NonZeroUsize, ) -> usize { let align = align.get(); + #[cfg(zerocopy_panic_in_const)] debug_assert!(align.is_power_of_two()); // Subtraction can't underflow because `align.get() >= 1`. @@ -275,6 +276,13 @@ mod tests { } } } + + #[rustversion::since(1.57.0)] + #[test] + #[should_panic] + fn test_round_down_to_next_multiple_of_alignment_panic_in_const() { + round_down_to_next_multiple_of_alignment(0, NonZeroUsize::new(3).unwrap()); + } } #[cfg(kani)] diff --git a/src/wrappers.rs b/src/wrappers.rs index be5e0fedc18..bca70c9a84c 100644 --- a/src/wrappers.rs +++ b/src/wrappers.rs @@ -477,7 +477,7 @@ mod tests { let au64 = unsafe { x.t.deref_unchecked() }; match au64 { AU64(123) => {} - _ => unreachable!(), + _ => const_unreachable!(), } }; } diff --git a/tests/ui-msrv/invalid-impls/invalid-impls.stderr b/tests/ui-msrv/invalid-impls/invalid-impls.stderr index e4656f92792..cc0a4eafeae 100644 --- a/tests/ui-msrv/invalid-impls/invalid-impls.stderr +++ b/tests/ui-msrv/invalid-impls/invalid-impls.stderr @@ -7,7 +7,7 @@ error[E0277]: the trait bound `T: zerocopy::TryFromBytes` is not satisfied ::: tests/ui-msrv/invalid-impls/invalid-impls.rs:26:1 | 26 | impl_or_verify!(T => TryFromBytes for Foo); - | --------------------------------------------- in this macro invocation + | ---------------------------------------------- in this macro invocation | note: required because of the requirements on the impl of `zerocopy::TryFromBytes` for `Foo` --> tests/ui-msrv/invalid-impls/invalid-impls.rs:22:10 @@ -23,7 +23,7 @@ note: required by a bound in `_::Subtrait` ::: tests/ui-msrv/invalid-impls/invalid-impls.rs:26:1 | 26 | impl_or_verify!(T => TryFromBytes for Foo); - | --------------------------------------------- in this macro invocation + | ---------------------------------------------- in this macro invocation = note: this error originates in the macro `impl_or_verify` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `T` | @@ -39,7 +39,7 @@ error[E0277]: the trait bound `T: FromZeroes` is not satisfied ::: tests/ui-msrv/invalid-impls/invalid-impls.rs:27:1 | 27 | impl_or_verify!(T => FromZeros for Foo); - | ------------------------------------------ in this macro invocation + | ------------------------------------------- in this macro invocation | note: required because of the requirements on the impl of `FromZeroes` for `Foo` --> tests/ui-msrv/invalid-impls/invalid-impls.rs:22:24 @@ -55,7 +55,7 @@ note: required by a bound in `_::Subtrait` ::: tests/ui-msrv/invalid-impls/invalid-impls.rs:27:1 | 27 | impl_or_verify!(T => FromZeros for Foo); - | ------------------------------------------ in this macro invocation + | ------------------------------------------- in this macro invocation = note: this error originates in the macro `impl_or_verify` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `T` | @@ -71,7 +71,7 @@ error[E0277]: the trait bound `T: zerocopy::FromBytes` is not satisfied ::: tests/ui-msrv/invalid-impls/invalid-impls.rs:28:1 | 28 | impl_or_verify!(T => FromBytes for Foo); - | ------------------------------------------ in this macro invocation + | ------------------------------------------- in this macro invocation | note: required because of the requirements on the impl of `zerocopy::FromBytes` for `Foo` --> tests/ui-msrv/invalid-impls/invalid-impls.rs:22:35 @@ -87,7 +87,7 @@ note: required by a bound in `_::Subtrait` ::: tests/ui-msrv/invalid-impls/invalid-impls.rs:28:1 | 28 | impl_or_verify!(T => FromBytes for Foo); - | ------------------------------------------ in this macro invocation + | ------------------------------------------- in this macro invocation = note: this error originates in the macro `impl_or_verify` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `T` | @@ -103,7 +103,7 @@ error[E0277]: the trait bound `T: AsBytes` is not satisfied ::: tests/ui-msrv/invalid-impls/invalid-impls.rs:29:1 | 29 | impl_or_verify!(T => IntoBytes for Foo); - | ------------------------------------------ in this macro invocation + | ------------------------------------------- in this macro invocation | note: required because of the requirements on the impl of `AsBytes` for `Foo` --> tests/ui-msrv/invalid-impls/invalid-impls.rs:22:46 @@ -119,7 +119,7 @@ note: required by a bound in `_::Subtrait` ::: tests/ui-msrv/invalid-impls/invalid-impls.rs:29:1 | 29 | impl_or_verify!(T => IntoBytes for Foo); - | ------------------------------------------ in this macro invocation + | ------------------------------------------- in this macro invocation = note: this error originates in the macro `impl_or_verify` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `T` | @@ -135,7 +135,7 @@ error[E0277]: the trait bound `T: zerocopy::Unaligned` is not satisfied ::: tests/ui-msrv/invalid-impls/invalid-impls.rs:30:1 | 30 | impl_or_verify!(T => Unaligned for Foo); - | ------------------------------------------ in this macro invocation + | ------------------------------------------- in this macro invocation | note: required because of the requirements on the impl of `zerocopy::Unaligned` for `Foo` --> tests/ui-msrv/invalid-impls/invalid-impls.rs:22:57 @@ -151,7 +151,7 @@ note: required by a bound in `_::Subtrait` ::: tests/ui-msrv/invalid-impls/invalid-impls.rs:30:1 | 30 | impl_or_verify!(T => Unaligned for Foo); - | ------------------------------------------ in this macro invocation + | ------------------------------------------- in this macro invocation = note: this error originates in the macro `impl_or_verify` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `T` | diff --git a/tests/ui-msrv/transmute-mut-dst-not-intobytes.stderr b/tests/ui-msrv/transmute-mut-dst-not-intobytes.stderr index 50a7afc279f..4ceffcd0103 100644 --- a/tests/ui-msrv/transmute-mut-dst-not-intobytes.stderr +++ b/tests/ui-msrv/transmute-mut-dst-not-intobytes.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `Dst: AsBytes` is not satisfied +error[E0277]: the trait bound `Dst: IntoBytes` is not satisfied --> tests/ui-msrv/transmute-mut-dst-not-intobytes.rs:24:36 | 24 | const DST_NOT_AS_BYTES: &mut Dst = transmute_mut!(&mut Src); - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `Dst` + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `Dst` | note: required by `AssertDstIsIntoBytes` --> tests/ui-msrv/transmute-mut-dst-not-intobytes.rs:24:36 diff --git a/tests/ui-msrv/transmute-mut-src-dst-unsized.stderr b/tests/ui-msrv/transmute-mut-src-dst-unsized.stderr index 2f0d8962c0b..81f11d0376c 100644 --- a/tests/ui-msrv/transmute-mut-src-dst-unsized.stderr +++ b/tests/ui-msrv/transmute-mut-src-dst-unsized.stderr @@ -2,10 +2,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-mut-src-dst-unsized.rs:17:36 | 17 | const SRC_DST_UNSIZED: &mut [u8] = transmute_mut!(&mut [0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by `AssertSrcIsSized` @@ -58,10 +55,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-mut-src-dst-unsized.rs:17:36 | 17 | const SRC_DST_UNSIZED: &mut [u8] = transmute_mut!(&mut [0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `transmute` @@ -150,10 +144,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-mut-src-dst-unsized.rs:17:36 | 17 | const SRC_DST_UNSIZED: &mut [u8] = transmute_mut!(&mut [0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `AlignOf` @@ -206,10 +197,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-mut-src-dst-unsized.rs:17:36 | 17 | const SRC_DST_UNSIZED: &mut [u8] = transmute_mut!(&mut [0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `transmute_mut` diff --git a/tests/ui-msrv/transmute-mut-src-not-frombytes.stderr b/tests/ui-msrv/transmute-mut-src-not-frombytes.stderr index 5d627b79871..ebb8e0bafe7 100644 --- a/tests/ui-msrv/transmute-mut-src-not-frombytes.stderr +++ b/tests/ui-msrv/transmute-mut-src-not-frombytes.stderr @@ -2,10 +2,7 @@ error[E0277]: the trait bound `Src: FromBytes` is not satisfied --> tests/ui-msrv/transmute-mut-src-not-frombytes.rs:24:38 | 24 | const SRC_NOT_FROM_BYTES: &mut Dst = transmute_mut!(&mut Src); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the trait `FromBytes` is not implemented for `Src` - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `Src` | note: required by `AssertSrcIsFromBytes` --> tests/ui-msrv/transmute-mut-src-not-frombytes.rs:24:38 diff --git a/tests/ui-msrv/transmute-mut-src-not-intobytes.stderr b/tests/ui-msrv/transmute-mut-src-not-intobytes.stderr index 44df4ba6895..36be71417b6 100644 --- a/tests/ui-msrv/transmute-mut-src-not-intobytes.stderr +++ b/tests/ui-msrv/transmute-mut-src-not-intobytes.stderr @@ -2,10 +2,7 @@ error[E0277]: the trait bound `Src: AsBytes` is not satisfied --> tests/ui-msrv/transmute-mut-src-not-intobytes.rs:24:36 | 24 | const SRC_NOT_AS_BYTES: &mut Dst = transmute_mut!(&mut Src); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the trait `AsBytes` is not implemented for `Src` - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `Src` | note: required by `AssertSrcIsIntoBytes` --> tests/ui-msrv/transmute-mut-src-not-intobytes.rs:24:36 diff --git a/tests/ui-msrv/transmute-mut-src-not-nocell.stderr b/tests/ui-msrv/transmute-mut-src-not-nocell.stderr index 677eb750a23..ae4bef1a56a 100644 --- a/tests/ui-msrv/transmute-mut-src-not-nocell.stderr +++ b/tests/ui-msrv/transmute-mut-src-not-nocell.stderr @@ -2,10 +2,7 @@ error[E0277]: the trait bound `Src: NoCell` is not satisfied --> tests/ui-msrv/transmute-mut-src-not-nocell.rs:24:35 | 24 | const SRC_NOT_NO_CELL: &mut Dst = transmute_mut!(&mut Src); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the trait `NoCell` is not implemented for `Src` - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NoCell` is not implemented for `Src` | note: required by `AssertSrcIsNoCell` --> tests/ui-msrv/transmute-mut-src-not-nocell.rs:24:35 diff --git a/tests/ui-msrv/transmute-mut-src-unsized.stderr b/tests/ui-msrv/transmute-mut-src-unsized.stderr index feb2180c44b..dcdfd9d53cb 100644 --- a/tests/ui-msrv/transmute-mut-src-unsized.stderr +++ b/tests/ui-msrv/transmute-mut-src-unsized.stderr @@ -2,10 +2,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-mut-src-unsized.rs:16:35 | 16 | const SRC_UNSIZED: &mut [u8; 1] = transmute_mut!(&mut [0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by `AssertSrcIsSized` @@ -44,10 +41,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-mut-src-unsized.rs:16:35 | 16 | const SRC_UNSIZED: &mut [u8; 1] = transmute_mut!(&mut [0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `transmute` @@ -136,10 +130,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-mut-src-unsized.rs:16:35 | 16 | const SRC_UNSIZED: &mut [u8; 1] = transmute_mut!(&mut [0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `AlignOf` @@ -167,10 +158,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-mut-src-unsized.rs:16:35 | 16 | const SRC_UNSIZED: &mut [u8; 1] = transmute_mut!(&mut [0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `transmute_mut` @@ -179,3 +167,13 @@ note: required by a bound in `transmute_mut` | pub unsafe fn transmute_mut<'dst, 'src: 'dst, Src: 'src, Dst: 'dst>( | ^^^ required by this bound in `transmute_mut` = note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> tests/ui-msrv/transmute-mut-src-unsized.rs:16:35 + | +16 | const SRC_UNSIZED: &mut [u8; 1] = transmute_mut!(&mut [0u8][..]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: all function arguments must have a statically known size + = note: this error originates in the macro `$crate::assert_size_eq` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-msrv/transmute-ptr-to-usize.stderr b/tests/ui-msrv/transmute-ptr-to-usize.stderr index cf40e57471b..81d60c71a1d 100644 --- a/tests/ui-msrv/transmute-ptr-to-usize.stderr +++ b/tests/ui-msrv/transmute-ptr-to-usize.stderr @@ -1,11 +1,8 @@ -error[E0277]: the trait bound `*const usize: AsBytes` is not satisfied +error[E0277]: the trait bound `*const usize: IntoBytes` is not satisfied --> tests/ui-msrv/transmute-ptr-to-usize.rs:20:30 | 20 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the trait `AsBytes` is not implemented for `*const usize` - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `*const usize` | note: required by `AssertIsIntoBytes` --> tests/ui-msrv/transmute-ptr-to-usize.rs:20:30 @@ -14,11 +11,11 @@ note: required by `AssertIsIntoBytes` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `*const usize: AsBytes` is not satisfied +error[E0277]: the trait bound `*const usize: IntoBytes` is not satisfied --> tests/ui-msrv/transmute-ptr-to-usize.rs:20:30 | 20 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `*const usize` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `*const usize` | note: required by a bound in `AssertIsIntoBytes` --> tests/ui-msrv/transmute-ptr-to-usize.rs:20:30 diff --git a/tests/ui-msrv/transmute-ref-src-dst-unsized.stderr b/tests/ui-msrv/transmute-ref-src-dst-unsized.stderr index 40e1deca529..77c833386b8 100644 --- a/tests/ui-msrv/transmute-ref-src-dst-unsized.stderr +++ b/tests/ui-msrv/transmute-ref-src-dst-unsized.stderr @@ -2,10 +2,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-ref-src-dst-unsized.rs:17:32 | 17 | const SRC_DST_UNSIZED: &[u8] = transmute_ref!(&[0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by `AssertSrcIsSized` @@ -58,10 +55,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-ref-src-dst-unsized.rs:17:32 | 17 | const SRC_DST_UNSIZED: &[u8] = transmute_ref!(&[0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `transmute` @@ -150,10 +144,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-ref-src-dst-unsized.rs:17:32 | 17 | const SRC_DST_UNSIZED: &[u8] = transmute_ref!(&[0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `AlignOf` @@ -206,10 +197,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-ref-src-dst-unsized.rs:17:32 | 17 | const SRC_DST_UNSIZED: &[u8] = transmute_ref!(&[0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `transmute_ref` diff --git a/tests/ui-msrv/transmute-ref-src-not-intobytes.stderr b/tests/ui-msrv/transmute-ref-src-not-intobytes.stderr index c07849d1f26..d48a73aebbf 100644 --- a/tests/ui-msrv/transmute-ref-src-not-intobytes.stderr +++ b/tests/ui-msrv/transmute-ref-src-not-intobytes.stderr @@ -1,11 +1,8 @@ -error[E0277]: the trait bound `Src: AsBytes` is not satisfied +error[E0277]: the trait bound `Src: IntoBytes` is not satisfied --> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:22:33 | 22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the trait `AsBytes` is not implemented for `Src` - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `Src` | note: required by `AssertSrcIsIntoBytes` --> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:22:33 @@ -14,11 +11,11 @@ note: required by `AssertSrcIsIntoBytes` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `Src: AsBytes` is not satisfied +error[E0277]: the trait bound `Src: IntoBytes` is not satisfied --> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:22:33 | 22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `Src` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `Src` | note: required by a bound in `AssertSrcIsIntoBytes` --> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:22:33 diff --git a/tests/ui-msrv/transmute-ref-src-not-nocell.stderr b/tests/ui-msrv/transmute-ref-src-not-nocell.stderr index b4c7a1eaaac..f2315b6d3b0 100644 --- a/tests/ui-msrv/transmute-ref-src-not-nocell.stderr +++ b/tests/ui-msrv/transmute-ref-src-not-nocell.stderr @@ -2,10 +2,7 @@ error[E0277]: the trait bound `Src: NoCell` is not satisfied --> tests/ui-msrv/transmute-ref-src-not-nocell.rs:22:32 | 22 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | expected an implementor of trait `NoCell` - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an implementor of trait `NoCell` | note: required by `AssertSrcIsNoCell` --> tests/ui-msrv/transmute-ref-src-not-nocell.rs:22:32 diff --git a/tests/ui-msrv/transmute-ref-src-unsized.stderr b/tests/ui-msrv/transmute-ref-src-unsized.stderr index 641a8b0c34f..1621797c126 100644 --- a/tests/ui-msrv/transmute-ref-src-unsized.stderr +++ b/tests/ui-msrv/transmute-ref-src-unsized.stderr @@ -2,10 +2,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-ref-src-unsized.rs:16:31 | 16 | const SRC_UNSIZED: &[u8; 1] = transmute_ref!(&[0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by `AssertSrcIsSized` @@ -44,10 +41,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-ref-src-unsized.rs:16:31 | 16 | const SRC_UNSIZED: &[u8; 1] = transmute_ref!(&[0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `transmute` @@ -136,10 +130,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-ref-src-unsized.rs:16:31 | 16 | const SRC_UNSIZED: &[u8; 1] = transmute_ref!(&[0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `AlignOf` @@ -167,10 +158,7 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation --> tests/ui-msrv/transmute-ref-src-unsized.rs:16:31 | 16 | const SRC_UNSIZED: &[u8; 1] = transmute_ref!(&[0u8][..]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | doesn't have a size known at compile-time - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `transmute_ref` @@ -179,3 +167,13 @@ note: required by a bound in `transmute_ref` | pub const unsafe fn transmute_ref<'dst, 'src: 'dst, Src: 'src, Dst: 'dst>( | ^^^ required by this bound in `transmute_ref` = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> tests/ui-msrv/transmute-ref-src-unsized.rs:16:31 + | +16 | const SRC_UNSIZED: &[u8; 1] = transmute_ref!(&[0u8][..]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: all function arguments must have a statically known size + = note: this error originates in the macro `$crate::assert_size_eq` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-msrv/transmute-src-not-intobytes.stderr b/tests/ui-msrv/transmute-src-not-intobytes.stderr index be1837610d5..4c870655929 100644 --- a/tests/ui-msrv/transmute-src-not-intobytes.stderr +++ b/tests/ui-msrv/transmute-src-not-intobytes.stderr @@ -1,11 +1,8 @@ -error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied +error[E0277]: the trait bound `NotZerocopy: IntoBytes` is not satisfied --> tests/ui-msrv/transmute-src-not-intobytes.rs:18:32 | 18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the trait `AsBytes` is not implemented for `NotZerocopy` - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `NotZerocopy` | note: required by `AssertIsIntoBytes` --> tests/ui-msrv/transmute-src-not-intobytes.rs:18:32 @@ -14,11 +11,11 @@ note: required by `AssertIsIntoBytes` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied +error[E0277]: the trait bound `NotZerocopy: IntoBytes` is not satisfied --> tests/ui-msrv/transmute-src-not-intobytes.rs:18:32 | 18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `NotZerocopy` | note: required by a bound in `AssertIsIntoBytes` --> tests/ui-msrv/transmute-src-not-intobytes.rs:18:32 diff --git a/zerocopy-derive/Cargo.toml b/zerocopy-derive/Cargo.toml index c4218d32af2..18319a858a2 100644 --- a/zerocopy-derive/Cargo.toml +++ b/zerocopy-derive/Cargo.toml @@ -14,7 +14,7 @@ authors = ["Joshua Liebow-Feeser "] description = "Custom derive for traits from the zerocopy crate" license = "BSD-2-Clause OR Apache-2.0 OR MIT" repository = "https://github.com/google/zerocopy" -rust-version = "1.57.0" +rust-version = "1.56.0" # We prefer to include tests when publishing to crates.io so that Crater [1] can # detect regressions in our test suite. These two tests are excessively large, diff --git a/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr b/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr index a2dc6e71bf3..eaebb22ef01 100644 --- a/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr +++ b/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied --> tests/ui-msrv/derive_transparent.rs:37:1 | 37 | assert_impl_all!(TransparentStruct: TryFromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy` | note: required because of the requirements on the impl of `TryFromBytes` for `TransparentStruct` --> tests/ui-msrv/derive_transparent.rs:27:21 @@ -13,16 +13,16 @@ note: required by a bound in `_::{closure#0}::assert_impl_all` --> tests/ui-msrv/derive_transparent.rs:37:1 | 37 | assert_impl_all!(TransparentStruct: TryFromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` = note: this error originates in the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied +error[E0277]: the trait bound `NotZerocopy: FromZeros` is not satisfied --> tests/ui-msrv/derive_transparent.rs:38:1 | 38 | assert_impl_all!(TransparentStruct: FromZeros); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromZeros` is not implemented for `NotZerocopy` | -note: required because of the requirements on the impl of `FromZeroes` for `TransparentStruct` +note: required because of the requirements on the impl of `FromZeros` for `TransparentStruct` --> tests/ui-msrv/derive_transparent.rs:27:35 | 27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] @@ -31,14 +31,14 @@ note: required by a bound in `_::{closure#0}::assert_impl_all` --> tests/ui-msrv/derive_transparent.rs:38:1 | 38 | assert_impl_all!(TransparentStruct: FromZeros); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` = note: this error originates in the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied --> tests/ui-msrv/derive_transparent.rs:39:1 | 39 | assert_impl_all!(TransparentStruct: FromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy` | note: required because of the requirements on the impl of `FromBytes` for `TransparentStruct` --> tests/ui-msrv/derive_transparent.rs:27:46 @@ -49,14 +49,14 @@ note: required by a bound in `_::{closure#0}::assert_impl_all` --> tests/ui-msrv/derive_transparent.rs:39:1 | 39 | assert_impl_all!(TransparentStruct: FromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` = note: this error originates in the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied --> tests/ui-msrv/derive_transparent.rs:40:1 | 40 | assert_impl_all!(TransparentStruct: IntoBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy` | note: required because of the requirements on the impl of `AsBytes` for `TransparentStruct` --> tests/ui-msrv/derive_transparent.rs:27:10 @@ -67,14 +67,14 @@ note: required by a bound in `_::{closure#0}::assert_impl_all` --> tests/ui-msrv/derive_transparent.rs:40:1 | 40 | assert_impl_all!(TransparentStruct: IntoBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` = note: this error originates in the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `NotZerocopy: Unaligned` is not satisfied --> tests/ui-msrv/derive_transparent.rs:41:1 | 41 | assert_impl_all!(TransparentStruct: Unaligned); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unaligned` is not implemented for `NotZerocopy` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unaligned` is not implemented for `NotZerocopy` | note: required because of the requirements on the impl of `Unaligned` for `TransparentStruct` --> tests/ui-msrv/derive_transparent.rs:27:57 @@ -85,5 +85,5 @@ note: required by a bound in `_::{closure#0}::assert_impl_all` --> tests/ui-msrv/derive_transparent.rs:41:1 | 41 | assert_impl_all!(TransparentStruct: Unaligned); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` = note: this error originates in the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr b/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr index bc86c9b2c9b..3e47653b70e 100644 --- a/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr +++ b/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr @@ -15,11 +15,11 @@ error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied = help: see issue #48214 = note: this error originates in the derive macro `TryFromBytes` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied +error[E0277]: the trait bound `NotZerocopy: FromZeros` is not satisfied --> tests/ui-msrv/late_compile_pass.rs:37:10 | 37 | #[derive(FromZeros)] - | ^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy` + | ^^^^^^^^^ the trait `FromZeros` is not implemented for `NotZerocopy` | = help: see issue #48214 = note: this error originates in the derive macro `FromZeros` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -33,11 +33,11 @@ error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied = help: see issue #48214 = note: this error originates in the derive macro `FromBytes` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `FromBytes1: FromZeroes` is not satisfied +error[E0277]: the trait bound `FromBytes1: FromZeros` is not satisfied --> tests/ui-msrv/late_compile_pass.rs:46:10 | 46 | #[derive(FromBytes)] - | ^^^^^^^^^ the trait `FromZeroes` is not implemented for `FromBytes1` + | ^^^^^^^^^ the trait `FromZeros` is not implemented for `FromBytes1` | note: required by a bound in `FromBytes` --> $WORKSPACE/src/lib.rs @@ -46,11 +46,11 @@ note: required by a bound in `FromBytes` | ^^^^^^^^^ required by this bound in `FromBytes` = note: this error originates in the derive macro `FromBytes` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied +error[E0277]: the trait bound `NotZerocopy: IntoBytes` is not satisfied --> tests/ui-msrv/late_compile_pass.rs:55:10 | 55 | #[derive(IntoBytes)] - | ^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy` + | ^^^^^^^^^ the trait `IntoBytes` is not implemented for `NotZerocopy` | = help: see issue #48214 = note: this error originates in the derive macro `IntoBytes` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/zerocopy-derive/tests/ui-msrv/mid_compile_pass.stderr b/zerocopy-derive/tests/ui-msrv/mid_compile_pass.stderr index 5aa2cde0aad..1d6d22df3f2 100644 --- a/zerocopy-derive/tests/ui-msrv/mid_compile_pass.stderr +++ b/zerocopy-derive/tests/ui-msrv/mid_compile_pass.stderr @@ -21,9 +21,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim 30 | fn test_kl04(kl: &KL04) { | - this type parameter needs to be `std::marker::Sized` 31 | assert_kl(kl); - | --------- ^^ doesn't have a size known at compile-time - | | - | required by a bound introduced by this call + | ^^ doesn't have a size known at compile-time | note: required because it appears within the type `KL04` --> tests/ui-msrv/mid_compile_pass.rs:28:8 @@ -53,9 +51,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim 39 | fn test_kl06(kl: &KL06) { | - this type parameter needs to be `std::marker::Sized` 40 | assert_kl(kl); - | --------- ^^ doesn't have a size known at compile-time - | | - | required by a bound introduced by this call + | ^^ doesn't have a size known at compile-time | note: required because it appears within the type `KL06` --> tests/ui-msrv/mid_compile_pass.rs:37:8 @@ -83,9 +79,7 @@ error[E0277]: the trait bound `T: KnownLayout` is not satisfied --> tests/ui-msrv/mid_compile_pass.rs:50:15 | 50 | assert_kl(kl) - | --------- ^^ the trait `KnownLayout` is not implemented for `T` - | | - | required by a bound introduced by this call + | ^^ the trait `KnownLayout` is not implemented for `T` | note: required because of the requirements on the impl of `KnownLayout` for `KL12` --> tests/ui-msrv/mid_compile_pass.rs:45:10