From 9f35f363f2ea4cef3327156e88aa9c80d2243e56 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Tue, 8 Aug 2023 14:12:31 -0700 Subject: [PATCH] Reduce MSRV to 1.61.0 (#234) It turned out that there were only a few lines of code that required our MSRV to be as high as it was before this commit (1.65.0), and those lines were easy to modify to be compatible with this new MSRV. Note that this requires introducing defensive code to `FromZeroes::new_box_slice_zeroed` in order to sidestep a bug in `Layout::from_size_align` that was present through 1.64.0. --- Cargo.toml | 2 +- src/lib.rs | 92 +++++++++---------- tests/trybuild.rs | 6 +- tests/ui-msrv/transmute-illegal.stderr | 19 ++-- zerocopy-derive/Cargo.toml | 2 +- zerocopy-derive/src/repr.rs | 4 +- zerocopy-derive/tests/trybuild.rs | 6 +- .../tests/ui-msrv/derive_transparent.stderr | 80 ++++------------ zerocopy-derive/tests/ui-msrv/enum.stderr | 2 - .../tests/ui-msrv/late_compile_pass.stderr | 70 -------------- zerocopy-derive/tests/ui-msrv/struct.stderr | 3 +- zerocopy-derive/tests/ui-msrv/union.stderr | 3 +- 12 files changed, 81 insertions(+), 208 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 46a613741a..2fd90097fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ authors = ["Joshua Liebow-Feeser "] description = "Utilities for zero-copy parsing and serialization" license = "BSD-2-Clause" repository = "https://github.com/google/zerocopy" -rust-version = "1.65.0" +rust-version = "1.61.0" exclude = [".*"] diff --git a/src/lib.rs b/src/lib.rs index 9d04049010..981cc74dee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -334,15 +334,23 @@ pub unsafe trait FromZeroes { where Self: Sized, { + let size = mem::size_of::() + .checked_mul(len) + .expect("mem::size_of::() * len overflows `usize`"); + let align = mem::align_of::(); + // On stable Rust versions <= 1.64.0, `Layout::from_size_align` has a + // bug in which sufficiently-large allocations (those which, when + // rounded up to the alignment, overflow `isize`) are not rejected, + // which can cause undefined behavior. See #64 for details. + // + // TODO(#67): Once our MSRV is > 1.64.0, remove this assertion. + #[allow(clippy::as_conversions)] + let max_alloc = (isize::MAX as usize).saturating_sub(align); + assert!(size <= max_alloc); // TODO(#2): Use `Layout::repeat` when `alloc_layout_extra` is // stabilized. - let layout = Layout::from_size_align( - mem::size_of::() - .checked_mul(len) - .expect("mem::size_of::() * len overflows `usize`"), - mem::align_of::(), - ) - .expect("total allocation size overflows `isize`"); + let layout = + Layout::from_size_align(size, align).expect("total allocation size overflows `isize`"); // TODO(#61): Add a "SAFETY" comment and remove this `allow`. #[allow(clippy::undocumented_unsafe_blocks)] @@ -1265,12 +1273,16 @@ impl Unalign { /// If `self` does not satisfy `mem::align_of::()`, then /// `self.deref_unchecked()` may cause undefined behavior. pub const unsafe fn deref_unchecked(&self) -> &T { - // SAFETY: `self.get_ptr()` returns a raw pointer to a valid `T` at the - // same memory location as `self`. It has no alignment guarantee, but - // the caller has promised that `self` is properly aligned, so we know - // that the pointer itself is aligned, and thus that it is sound to - // create a reference to a `T` at this memory location. - unsafe { &*self.get_ptr() } + // SAFETY: `Unalign` is `repr(transparent)`, so there is a valid `T` + // at the same memory location as `self`. It has no alignment guarantee, + // but the caller has promised that `self` is properly aligned, so we + // know that it is sound to create a reference to `T` at this memory + // location. + // + // We use `mem::transmute` instead of `&*self.get_ptr()` because + // dereferencing pointers is not stable in `const` on our current MSRV + // (1.56 as of this writing). + unsafe { mem::transmute(self) } } /// Returns a mutable reference to the wrapped `T` without checking @@ -1518,6 +1530,10 @@ macro_rules! transmute { // were to use `core::mem::transmute`, this macro would not work in // `std` contexts in which `core` was not manually imported. This is // not a problem for 2018 edition crates. + // + // Some older versions of Clippy have a bug in which they don't + // recognize the preceding safety comment. + #[allow(clippy::undocumented_unsafe_blocks)] unsafe { $crate::__real_transmute(e) } } }} @@ -2782,17 +2798,12 @@ mod alloc_support { #[cfg(test)] mod tests { - use core::convert::TryFrom as _; - use super::*; #[test] fn test_extend_vec_zeroed() { // Test extending when there is an existing allocation. - let mut v: Vec = Vec::with_capacity(3); - v.push(100); - v.push(200); - v.push(300); + let mut v = vec![100u64, 200, 300]; extend_vec_zeroed(&mut v, 3); assert_eq!(v.len(), 6); assert_eq!(&*v, &[100, 200, 300, 0, 0, 0]); @@ -2809,10 +2820,7 @@ mod alloc_support { #[test] fn test_extend_vec_zeroed_zst() { // Test extending when there is an existing (fake) allocation. - let mut v: Vec<()> = Vec::with_capacity(3); - v.push(()); - v.push(()); - v.push(()); + let mut v = vec![(), (), ()]; extend_vec_zeroed(&mut v, 3); assert_eq!(v.len(), 6); assert_eq!(&*v, &[(), (), (), (), (), ()]); @@ -2835,30 +2843,21 @@ mod alloc_support { drop(v); // Insert at start. - let mut v: Vec = Vec::with_capacity(3); - v.push(100); - v.push(200); - v.push(300); + let mut v = vec![100u64, 200, 300]; insert_vec_zeroed(&mut v, 0, 2); assert_eq!(v.len(), 5); assert_eq!(&*v, &[0, 0, 100, 200, 300]); drop(v); // Insert at middle. - let mut v: Vec = Vec::with_capacity(3); - v.push(100); - v.push(200); - v.push(300); + let mut v = vec![100u64, 200, 300]; insert_vec_zeroed(&mut v, 1, 1); assert_eq!(v.len(), 4); assert_eq!(&*v, &[100, 0, 200, 300]); drop(v); // Insert at end. - let mut v: Vec = Vec::with_capacity(3); - v.push(100); - v.push(200); - v.push(300); + let mut v = vec![100u64, 200, 300]; insert_vec_zeroed(&mut v, 3, 1); assert_eq!(v.len(), 4); assert_eq!(&*v, &[100, 200, 300, 0]); @@ -2875,30 +2874,21 @@ mod alloc_support { drop(v); // Insert at start. - let mut v: Vec<()> = Vec::with_capacity(3); - v.push(()); - v.push(()); - v.push(()); + let mut v = vec![(), (), ()]; insert_vec_zeroed(&mut v, 0, 2); assert_eq!(v.len(), 5); assert_eq!(&*v, &[(), (), (), (), ()]); drop(v); // Insert at middle. - let mut v: Vec<()> = Vec::with_capacity(3); - v.push(()); - v.push(()); - v.push(()); + let mut v = vec![(), (), ()]; insert_vec_zeroed(&mut v, 1, 1); assert_eq!(v.len(), 4); assert_eq!(&*v, &[(), (), (), ()]); drop(v); // Insert at end. - let mut v: Vec<()> = Vec::with_capacity(3); - v.push(()); - v.push(()); - v.push(()); + let mut v = vec![(), (), ()]; insert_vec_zeroed(&mut v, 3, 1); assert_eq!(v.len(), 4); assert_eq!(&*v, &[(), (), (), ()]); @@ -2967,7 +2957,7 @@ mod alloc_support { } #[test] - #[should_panic(expected = "total allocation size overflows `isize`: LayoutError")] + #[should_panic(expected = "assertion failed: size <= max_alloc")] fn test_new_box_slice_zeroed_panics_isize_overflow() { let max = usize::try_from(isize::MAX).unwrap(); let _ = u16::new_box_slice_zeroed((max / mem::size_of::()) + 1); @@ -3758,7 +3748,7 @@ mod tests { /// has had its bits flipped (by applying `^= 0xFF`). /// /// `N` is the size of `t` in bytes. - fn test( + fn test( t: &mut T, bytes: &[u8], post_mutation: &T, @@ -3830,12 +3820,12 @@ mod tests { }; let post_mutation_expected_a = if cfg!(target_endian = "little") { 0x00_00_00_FE } else { 0xFF_00_00_01 }; - test::<12, _>( + test::<_, 12>( &mut Foo { a: 1, b: Wrapping(2), c: None }, expected_bytes.as_bytes(), &Foo { a: post_mutation_expected_a, b: Wrapping(2), c: None }, ); - test::<3, _>( + test::<_, 3>( Unsized::from_mut_slice(&mut [1, 2, 3]), &[1, 2, 3], Unsized::from_mut_slice(&mut [0xFE, 2, 3]), diff --git a/tests/trybuild.rs b/tests/trybuild.rs index 36ce5dcdbb..32f38cc94a 100644 --- a/tests/trybuild.rs +++ b/tests/trybuild.rs @@ -15,11 +15,11 @@ // - `tests/ui-msrv` - Contains symlinks to the `.rs` files in // `tests/ui-nightly`, and contains `.err` and `.out` files for MSRV -#[rustversion::any(nightly)] +#[rustversion::nightly] const SOURCE_FILES_GLOB: &str = "tests/ui-nightly/*.rs"; -#[rustversion::all(stable, not(stable(1.65.0)))] +#[rustversion::stable(1.69.0)] const SOURCE_FILES_GLOB: &str = "tests/ui-stable/*.rs"; -#[rustversion::stable(1.65.0)] +#[rustversion::stable(1.61.0)] const SOURCE_FILES_GLOB: &str = "tests/ui-msrv/*.rs"; #[test] diff --git a/tests/ui-msrv/transmute-illegal.stderr b/tests/ui-msrv/transmute-illegal.stderr index 731134d479..37c124ad95 100644 --- a/tests/ui-msrv/transmute-illegal.stderr +++ b/tests/ui-msrv/transmute-illegal.stderr @@ -2,20 +2,13 @@ error[E0277]: the trait bound `*const usize: AsBytes` is not satisfied --> tests/ui-msrv/transmute-illegal.rs:10:30 | 10 | const POINTER_VALUE: usize = zerocopy::transmute!(&0usize as *const usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the trait `AsBytes` is not implemented for `*const usize` - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `*const usize` | - = help: the following other types implement trait `AsBytes`: - f32 - f64 - i128 - i16 - i32 - i64 - i8 - isize + = help: the following implementations were found: + + + + and $N others note: required by a bound in `POINTER_VALUE::transmute` --> tests/ui-msrv/transmute-illegal.rs:10:30 diff --git a/zerocopy-derive/Cargo.toml b/zerocopy-derive/Cargo.toml index 3ec45a01f9..8806869b35 100644 --- a/zerocopy-derive/Cargo.toml +++ b/zerocopy-derive/Cargo.toml @@ -10,7 +10,7 @@ authors = ["Joshua Liebow-Feeser "] description = "Custom derive for traits from the zerocopy crate" license = "BSD-2-Clause" repository = "https://github.com/google/zerocopy" -rust-version = "1.65.0" +rust-version = "1.61.0" exclude = [".*"] diff --git a/zerocopy-derive/src/repr.rs b/zerocopy-derive/src/repr.rs index b7ba6fd85f..5bd4a8a911 100644 --- a/zerocopy-derive/src/repr.rs +++ b/zerocopy-derive/src/repr.rs @@ -191,7 +191,7 @@ impl Repr { let ident = path .get_ident() .ok_or_else(|| Error::new_spanned(meta, "unrecognized representation hint"))?; - match format!("{ident}").as_str() { + match format!("{}", ident).as_str() { "u8" => return Ok(Repr::U8), "u16" => return Ok(Repr::U16), "u32" => return Ok(Repr::U32), @@ -221,7 +221,7 @@ impl Repr { impl Display for Repr { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> { if let Repr::Align(n) = self { - return write!(f, "repr(align({n}))"); + return write!(f, "repr(align({}))", n); } write!( f, diff --git a/zerocopy-derive/tests/trybuild.rs b/zerocopy-derive/tests/trybuild.rs index 36ce5dcdbb..32f38cc94a 100644 --- a/zerocopy-derive/tests/trybuild.rs +++ b/zerocopy-derive/tests/trybuild.rs @@ -15,11 +15,11 @@ // - `tests/ui-msrv` - Contains symlinks to the `.rs` files in // `tests/ui-nightly`, and contains `.err` and `.out` files for MSRV -#[rustversion::any(nightly)] +#[rustversion::nightly] const SOURCE_FILES_GLOB: &str = "tests/ui-nightly/*.rs"; -#[rustversion::all(stable, not(stable(1.65.0)))] +#[rustversion::stable(1.69.0)] const SOURCE_FILES_GLOB: &str = "tests/ui-stable/*.rs"; -#[rustversion::stable(1.65.0)] +#[rustversion::stable(1.61.0)] const SOURCE_FILES_GLOB: &str = "tests/ui-msrv/*.rs"; #[test] diff --git a/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr b/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr index 316bc0b3d7..32184460e8 100644 --- a/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr +++ b/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr @@ -1,20 +1,10 @@ error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied - --> tests/ui-msrv/derive_transparent.rs:33:18 + --> tests/ui-msrv/derive_transparent.rs:33:1 | 33 | assert_impl_all!(TransparentStruct: FromZeroes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy` - | - = help: the following other types implement trait `FromZeroes`: - () - AU16 - F32 - F64 - I128 - I16 - I32 - I64 - and $N others -note: required for `TransparentStruct` to implement `FromZeroes` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy` + | +note: required because of the requirements on the impl of `FromZeroes` for `TransparentStruct` --> tests/ui-msrv/derive_transparent.rs:23:19 | 23 | #[derive(AsBytes, FromZeroes, FromBytes, Unaligned)] @@ -24,25 +14,15 @@ note: required by a bound in `_::{closure#0}::assert_impl_all` | 33 | assert_impl_all!(TransparentStruct: FromZeroes); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` - = note: this error originates in the derive macro `FromZeroes` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) + = 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:34:18 + --> tests/ui-msrv/derive_transparent.rs:34:1 | 34 | assert_impl_all!(TransparentStruct: FromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy` - | - = help: the following other types implement trait `FromBytes`: - () - AU16 - F32 - F64 - I128 - I16 - I32 - I64 - and $N others -note: required for `TransparentStruct` to implement `FromBytes` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:23:31 | 23 | #[derive(AsBytes, FromZeroes, FromBytes, Unaligned)] @@ -52,25 +32,15 @@ note: required by a bound in `_::{closure#0}::assert_impl_all` | 34 | assert_impl_all!(TransparentStruct: FromBytes); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` - = note: this error originates in the derive macro `FromBytes` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) + = 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:35:18 + --> tests/ui-msrv/derive_transparent.rs:35:1 | 35 | assert_impl_all!(TransparentStruct: AsBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy` - | - = help: the following other types implement trait `AsBytes`: - () - AU16 - F32 - F64 - I128 - I16 - I32 - I64 - and $N others -note: required for `TransparentStruct` to implement `AsBytes` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:23:10 | 23 | #[derive(AsBytes, FromZeroes, FromBytes, Unaligned)] @@ -80,25 +50,15 @@ note: required by a bound in `_::{closure#0}::assert_impl_all` | 35 | assert_impl_all!(TransparentStruct: AsBytes); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` - = note: this error originates in the derive macro `AsBytes` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) + = 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:36:18 + --> tests/ui-msrv/derive_transparent.rs:36:1 | 36 | assert_impl_all!(TransparentStruct: Unaligned); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unaligned` is not implemented for `NotZerocopy` - | - = help: the following other types implement trait `Unaligned`: - () - F32 - F64 - I128 - I16 - I32 - I64 - ManuallyDrop - and $N others -note: required for `TransparentStruct` to implement `Unaligned` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:23:42 | 23 | #[derive(AsBytes, FromZeroes, FromBytes, Unaligned)] @@ -108,4 +68,4 @@ note: required by a bound in `_::{closure#0}::assert_impl_all` | 36 | assert_impl_all!(TransparentStruct: Unaligned); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all` - = note: this error originates in the derive macro `Unaligned` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) + = 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/enum.stderr b/zerocopy-derive/tests/ui-msrv/enum.stderr index 7617f9c07e..a71b0722ca 100644 --- a/zerocopy-derive/tests/ui-msrv/enum.stderr +++ b/zerocopy-derive/tests/ui-msrv/enum.stderr @@ -187,8 +187,6 @@ error[E0552]: unrecognized representation hint | 21 | #[repr(foo)] | ^^^ - | - = help: valid reprs are `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` error[E0566]: conflicting representation hints --> tests/ui-msrv/enum.rs:33:8 diff --git a/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr b/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr index 7bda5d0011..29d20e4e7f 100644 --- a/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr +++ b/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr @@ -4,16 +4,6 @@ error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied 23 | #[derive(FromZeroes)] | ^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy` | - = help: the following other types implement trait `FromZeroes`: - () - AU16 - F32 - F64 - FromZeroes1 - I128 - I16 - I32 - and $N others = help: see issue #48214 = note: this error originates in the derive macro `FromZeroes` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -23,16 +13,6 @@ error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied 32 | #[derive(FromBytes)] | ^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy` | - = help: the following other types implement trait `FromBytes`: - () - AU16 - F32 - F64 - FromBytes1 - I128 - I16 - I32 - and $N others = help: see issue #48214 = note: this error originates in the derive macro `FromBytes` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -42,16 +22,6 @@ error[E0277]: the trait bound `FromBytes1: FromZeroes` is not satisfied 32 | #[derive(FromBytes)] | ^^^^^^^^^ the trait `FromZeroes` is not implemented for `FromBytes1` | - = help: the following other types implement trait `FromZeroes`: - () - AU16 - F32 - F64 - FromZeroes1 - I128 - I16 - I32 - and $N others note: required by a bound in `FromBytes` --> $WORKSPACE/src/lib.rs | @@ -65,16 +35,6 @@ error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied 41 | #[derive(AsBytes)] | ^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy` | - = help: the following other types implement trait `AsBytes`: - () - AU16 - AsBytes1 - F32 - F64 - I128 - I16 - I32 - and $N others = help: see issue #48214 = note: this error originates in the derive macro `AsBytes` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -84,16 +44,6 @@ error[E0277]: the trait bound `AU16: Unaligned` is not satisfied 51 | #[derive(Unaligned)] | ^^^^^^^^^ the trait `Unaligned` is not implemented for `AU16` | - = help: the following other types implement trait `Unaligned`: - () - F32 - F64 - I128 - I16 - I32 - I64 - ManuallyDrop - and $N others = help: see issue #48214 = note: this error originates in the derive macro `Unaligned` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -103,16 +53,6 @@ error[E0277]: the trait bound `AU16: Unaligned` is not satisfied 59 | #[derive(Unaligned)] | ^^^^^^^^^ the trait `Unaligned` is not implemented for `AU16` | - = help: the following other types implement trait `Unaligned`: - () - F32 - F64 - I128 - I16 - I32 - I64 - ManuallyDrop - and $N others = help: see issue #48214 = note: this error originates in the derive macro `Unaligned` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -122,15 +62,5 @@ error[E0277]: the trait bound `AU16: Unaligned` is not satisfied 66 | #[derive(Unaligned)] | ^^^^^^^^^ the trait `Unaligned` is not implemented for `AU16` | - = help: the following other types implement trait `Unaligned`: - () - F32 - F64 - I128 - I16 - I32 - I64 - ManuallyDrop - and $N others = help: see issue #48214 = note: this error originates in the derive macro `Unaligned` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/zerocopy-derive/tests/ui-msrv/struct.stderr b/zerocopy-derive/tests/ui-msrv/struct.stderr index 1a88f84519..fe73b80fd0 100644 --- a/zerocopy-derive/tests/ui-msrv/struct.stderr +++ b/zerocopy-derive/tests/ui-msrv/struct.stderr @@ -48,6 +48,7 @@ error[E0277]: the trait bound `HasPadding: ShouldBe` is n 23 | #[derive(AsBytes)] | ^^^^^^^ the trait `ShouldBe` is not implemented for `HasPadding` | - = help: the trait `ShouldBe` is implemented for `HasPadding` + = help: the following implementations were found: + as ShouldBe> = help: see issue #48214 = note: this error originates in the derive macro `AsBytes` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/zerocopy-derive/tests/ui-msrv/union.stderr b/zerocopy-derive/tests/ui-msrv/union.stderr index 2dab3caacc..711b8e26a9 100644 --- a/zerocopy-derive/tests/ui-msrv/union.stderr +++ b/zerocopy-derive/tests/ui-msrv/union.stderr @@ -36,6 +36,7 @@ error[E0277]: the trait bound `HasPadding: ShouldBe` is n 26 | #[derive(AsBytes)] | ^^^^^^^ the trait `ShouldBe` is not implemented for `HasPadding` | - = help: the trait `ShouldBe` is implemented for `HasPadding` + = help: the following implementations were found: + as ShouldBe> = help: see issue #48214 = note: this error originates in the derive macro `AsBytes` (in Nightly builds, run with -Z macro-backtrace for more info)