diff --git a/src/macro_util.rs b/src/macro_util.rs index be2cd31b52..c892eb3223 100644 --- a/src/macro_util.rs +++ b/src/macro_util.rs @@ -262,7 +262,7 @@ macro_rules! align_of { #[macro_export] macro_rules! struct_has_padding { ($t:ty, $($ts:ty),*) => { - core::mem::size_of::<$t>() > 0 $(+ core::mem::size_of::<$ts>())* + ::zerocopy::macro_util::core_reexport::mem::size_of::<$t>() > 0 $(+ ::zerocopy::macro_util::core_reexport::mem::size_of::<$ts>())* }; } @@ -282,7 +282,7 @@ macro_rules! struct_has_padding { #[macro_export] macro_rules! union_has_padding { ($t:ty, $($ts:ty),*) => { - false $(|| core::mem::size_of::<$t>() != core::mem::size_of::<$ts>())* + false $(|| ::zerocopy::macro_util::core_reexport::mem::size_of::<$t>() != ::zerocopy::macro_util::core_reexport::mem::size_of::<$ts>())* }; } diff --git a/tests/ui-msrv/include_value_not_from_bytes.stderr b/tests/ui-msrv/include_value_not_from_bytes.stderr index fa219b444d..75a6f56931 100644 --- a/tests/ui-msrv/include_value_not_from_bytes.stderr +++ b/tests/ui-msrv/include_value_not_from_bytes.stderr @@ -1,12 +1,12 @@ -error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied - --> tests/ui-msrv/include_value_not_from_bytes.rs:13:42 +error[E0277]: the trait bound `NotZerocopy: zerocopy::FromBytes` is not satisfied + --> tests/ui-msrv/include_value_not_from_bytes.rs:15:42 | -13 | const NOT_FROM_BYTES: NotZerocopy = include_value!("../../testdata/include_value/data"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy` +15 | const NOT_FROM_BYTES: NotZerocopy = include_value!("../../testdata/include_value/data"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::FromBytes` is not implemented for `NotZerocopy` | note: required by `AssertIsFromBytes` - --> tests/ui-msrv/include_value_not_from_bytes.rs:13:42 + --> tests/ui-msrv/include_value_not_from_bytes.rs:15:42 | -13 | const NOT_FROM_BYTES: NotZerocopy = include_value!("../../testdata/include_value/data"); +15 | const NOT_FROM_BYTES: NotZerocopy = include_value!("../../testdata/include_value/data"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::transmute` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-msrv/transmute-dst-not-frombytes.stderr b/tests/ui-msrv/transmute-dst-not-frombytes.stderr index 2f12460133..744cb48da0 100644 --- a/tests/ui-msrv/transmute-dst-not-frombytes.stderr +++ b/tests/ui-msrv/transmute-dst-not-frombytes.stderr @@ -1,12 +1,12 @@ -error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied - --> tests/ui-msrv/transmute-dst-not-frombytes.rs:18:41 +error[E0277]: the trait bound `NotZerocopy: zerocopy::FromBytes` is not satisfied + --> tests/ui-msrv/transmute-dst-not-frombytes.rs:19:41 | -18 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0)); - | ^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy` +19 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0)); + | ^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::FromBytes` is not implemented for `NotZerocopy` | note: required by `AssertIsFromBytes` - --> tests/ui-msrv/transmute-dst-not-frombytes.rs:18:41 + --> tests/ui-msrv/transmute-dst-not-frombytes.rs:19:41 | -18 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0)); +19 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0)); | ^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-msrv/transmute-mut-alignment-increase.stderr b/tests/ui-msrv/transmute-mut-alignment-increase.stderr index c1c430c39b..7b771b8521 100644 --- a/tests/ui-msrv/transmute-mut-alignment-increase.stderr +++ b/tests/ui-msrv/transmute-mut-alignment-increase.stderr @@ -1,7 +1,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> tests/ui-msrv/transmute-mut-alignment-increase.rs:19:39 + --> tests/ui-msrv/transmute-mut-alignment-increase.rs:20:39 | -19 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); +20 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: source type: `AlignOf<[u8; 2]>` (8 bits) @@ -9,25 +9,25 @@ error[E0512]: cannot transmute between types of different sizes, or dependently- = note: this error originates in the macro `$crate::assert_align_gt_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0658]: mutable references are not allowed in constants - --> tests/ui-msrv/transmute-mut-alignment-increase.rs:19:54 + --> tests/ui-msrv/transmute-mut-alignment-increase.rs:20:54 | -19 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); +20 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); | ^^^^^^^^^^^^^ | = note: see issue #57349 for more information error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants - --> tests/ui-msrv/transmute-mut-alignment-increase.rs:19:39 + --> tests/ui-msrv/transmute-mut-alignment-increase.rs:20:39 | -19 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); +20 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0716]: temporary value dropped while borrowed - --> tests/ui-msrv/transmute-mut-alignment-increase.rs:19:59 + --> tests/ui-msrv/transmute-mut-alignment-increase.rs:20:59 | -19 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); +20 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); | --------------------^^^^^^^^- | | | | | creates a temporary which is freed while still in use diff --git a/tests/ui-msrv/transmute-ref-alignment-increase.stderr b/tests/ui-msrv/transmute-ref-alignment-increase.stderr index 72864e144d..bbf5058287 100644 --- a/tests/ui-msrv/transmute-ref-alignment-increase.stderr +++ b/tests/ui-msrv/transmute-ref-alignment-increase.stderr @@ -1,7 +1,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> tests/ui-msrv/transmute-ref-alignment-increase.rs:19:35 + --> tests/ui-msrv/transmute-ref-alignment-increase.rs:20:35 | -19 | const INCREASE_ALIGNMENT: &AU16 = transmute_ref!(&[0u8; 2]); +20 | const INCREASE_ALIGNMENT: &AU16 = transmute_ref!(&[0u8; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: source type: `AlignOf<[u8; 2]>` (8 bits) diff --git a/tests/ui-msrv/transmute-ref-dst-not-frombytes.stderr b/tests/ui-msrv/transmute-ref-dst-not-frombytes.stderr index 356a1e6b38..9cdc03ef84 100644 --- a/tests/ui-msrv/transmute-ref-dst-not-frombytes.stderr +++ b/tests/ui-msrv/transmute-ref-dst-not-frombytes.stderr @@ -1,12 +1,12 @@ -error[E0277]: the trait bound `Dst: FromBytes` is not satisfied - --> tests/ui-msrv/transmute-ref-dst-not-frombytes.rs:22:34 +error[E0277]: the trait bound `Dst: zerocopy::FromBytes` is not satisfied + --> tests/ui-msrv/transmute-ref-dst-not-frombytes.rs:23:34 | -22 | const DST_NOT_FROM_BYTES: &Dst = transmute_ref!(&AU16(0)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `Dst` +23 | const DST_NOT_FROM_BYTES: &Dst = transmute_ref!(&AU16(0)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::FromBytes` is not implemented for `Dst` | note: required by `AssertDstIsFromBytes` - --> tests/ui-msrv/transmute-ref-dst-not-frombytes.rs:22:34 + --> tests/ui-msrv/transmute-ref-dst-not-frombytes.rs:23:34 | -22 | const DST_NOT_FROM_BYTES: &Dst = transmute_ref!(&AU16(0)); +23 | const DST_NOT_FROM_BYTES: &Dst = transmute_ref!(&AU16(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-msrv/transmute-ref-dst-not-nocell.stderr b/tests/ui-msrv/transmute-ref-dst-not-nocell.stderr index 5b064f7e2b..ef804729b9 100644 --- a/tests/ui-msrv/transmute-ref-dst-not-nocell.stderr +++ b/tests/ui-msrv/transmute-ref-dst-not-nocell.stderr @@ -1,12 +1,12 @@ -error[E0277]: the trait bound `Dst: NoCell` is not satisfied - --> tests/ui-msrv/transmute-ref-dst-not-nocell.rs:22:31 +error[E0277]: the trait bound `Dst: zerocopy::NoCell` is not satisfied + --> tests/ui-msrv/transmute-ref-dst-not-nocell.rs:23:31 | -22 | const DST_NOT_NO_CELL: &Dst = transmute_ref!(&AU16(0)); - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NoCell` is not implemented for `Dst` +23 | const DST_NOT_NO_CELL: &Dst = transmute_ref!(&AU16(0)); + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::NoCell` is not implemented for `Dst` | note: required by `AssertDstIsNoCell` - --> tests/ui-msrv/transmute-ref-dst-not-nocell.rs:22:31 + --> tests/ui-msrv/transmute-ref-dst-not-nocell.rs:23:31 | -22 | const DST_NOT_NO_CELL: &Dst = transmute_ref!(&AU16(0)); +23 | const DST_NOT_NO_CELL: &Dst = transmute_ref!(&AU16(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-msrv/transmute-ref-src-not-intobytes.stderr b/tests/ui-msrv/transmute-ref-src-not-intobytes.stderr index d48a73aebb..e1a2f6a769 100644 --- a/tests/ui-msrv/transmute-ref-src-not-intobytes.stderr +++ b/tests/ui-msrv/transmute-ref-src-not-intobytes.stderr @@ -1,25 +1,25 @@ -error[E0277]: the trait bound `Src: IntoBytes` is not satisfied - --> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:22:33 +error[E0277]: the trait bound `Src: AsBytes` is not satisfied + --> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:23:33 | -22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `Src` +23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `Src` | note: required by `AssertSrcIsIntoBytes` - --> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:22:33 + --> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:23:33 | -22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = 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: IntoBytes` is not satisfied - --> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:22:33 +error[E0277]: the trait bound `Src: AsBytes` is not satisfied + --> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:23:33 | -22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `Src` +23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `Src` | note: required by a bound in `AssertSrcIsIntoBytes` - --> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:22:33 + --> tests/ui-msrv/transmute-ref-src-not-intobytes.rs:23:33 | -22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsIntoBytes` = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-msrv/transmute-ref-src-not-nocell.stderr b/tests/ui-msrv/transmute-ref-src-not-nocell.stderr index f2315b6d3b..3d9d881b57 100644 --- a/tests/ui-msrv/transmute-ref-src-not-nocell.stderr +++ b/tests/ui-msrv/transmute-ref-src-not-nocell.stderr @@ -1,25 +1,25 @@ -error[E0277]: the trait bound `Src: NoCell` is not satisfied - --> tests/ui-msrv/transmute-ref-src-not-nocell.rs:22:32 +error[E0277]: the trait bound `Src: zerocopy::NoCell` is not satisfied + --> tests/ui-msrv/transmute-ref-src-not-nocell.rs:23:32 | -22 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an implementor of trait `NoCell` +23 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an implementor of trait `zerocopy::NoCell` | note: required by `AssertSrcIsNoCell` - --> tests/ui-msrv/transmute-ref-src-not-nocell.rs:22:32 + --> tests/ui-msrv/transmute-ref-src-not-nocell.rs:23:32 | -22 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = 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: NoCell` is not satisfied - --> tests/ui-msrv/transmute-ref-src-not-nocell.rs:22:32 +error[E0277]: the trait bound `Src: zerocopy::NoCell` is not satisfied + --> tests/ui-msrv/transmute-ref-src-not-nocell.rs:23:32 | -22 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NoCell` is not implemented for `Src` +23 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::NoCell` is not implemented for `Src` | note: required by a bound in `AssertSrcIsNoCell` - --> tests/ui-msrv/transmute-ref-src-not-nocell.rs:22:32 + --> tests/ui-msrv/transmute-ref-src-not-nocell.rs:23:32 | -22 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsNoCell` = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-msrv/transmute-size-decrease.stderr b/tests/ui-msrv/transmute-size-decrease.stderr index ffa5688485..33f9cf2ee7 100644 --- a/tests/ui-msrv/transmute-size-decrease.stderr +++ b/tests/ui-msrv/transmute-size-decrease.stderr @@ -1,7 +1,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> tests/ui-msrv/transmute-size-decrease.rs:19:27 + --> tests/ui-msrv/transmute-size-decrease.rs:20:27 | -19 | const DECREASE_SIZE: u8 = transmute!(AU16(0)); +20 | const DECREASE_SIZE: u8 = transmute!(AU16(0)); | ^^^^^^^^^^^^^^^^^^^ | = note: source type: `AU16` (16 bits) diff --git a/tests/ui-msrv/transmute-size-increase.stderr b/tests/ui-msrv/transmute-size-increase.stderr index 865d0caf9e..64aa798f9d 100644 --- a/tests/ui-msrv/transmute-size-increase.stderr +++ b/tests/ui-msrv/transmute-size-increase.stderr @@ -1,7 +1,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> tests/ui-msrv/transmute-size-increase.rs:19:29 + --> tests/ui-msrv/transmute-size-increase.rs:20:29 | -19 | const INCREASE_SIZE: AU16 = transmute!(0u8); +20 | const INCREASE_SIZE: AU16 = transmute!(0u8); | ^^^^^^^^^^^^^^^ | = note: source type: `u8` (8 bits) diff --git a/tests/ui-msrv/transmute-src-not-intobytes.stderr b/tests/ui-msrv/transmute-src-not-intobytes.stderr index d467aa7989..f5aecafc3a 100644 --- a/tests/ui-msrv/transmute-src-not-intobytes.stderr +++ b/tests/ui-msrv/transmute-src-not-intobytes.stderr @@ -1,25 +1,25 @@ error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied - --> tests/ui-msrv/transmute-src-not-intobytes.rs:18:32 + --> tests/ui-msrv/transmute-src-not-intobytes.rs:19:32 | -18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); +19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy` | note: required by `AssertIsIntoBytes` - --> tests/ui-msrv/transmute-src-not-intobytes.rs:18:32 + --> tests/ui-msrv/transmute-src-not-intobytes.rs:19:32 | -18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); +19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = 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 - --> tests/ui-msrv/transmute-src-not-intobytes.rs:18:32 + --> tests/ui-msrv/transmute-src-not-intobytes.rs:19:32 | -18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); +19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy` | note: required by a bound in `AssertIsIntoBytes` - --> tests/ui-msrv/transmute-src-not-intobytes.rs:18:32 + --> tests/ui-msrv/transmute-src-not-intobytes.rs:19:32 | -18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); +19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertIsIntoBytes` = note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-nightly/include_value_not_from_bytes.rs b/tests/ui-nightly/include_value_not_from_bytes.rs index 9f0bb6f1d1..ddf94727f9 100644 --- a/tests/ui-nightly/include_value_not_from_bytes.rs +++ b/tests/ui-nightly/include_value_not_from_bytes.rs @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -include!("../../zerocopy-derive/tests/util.rs"); +include!("../../zerocopy-derive/tests/include.rs"); #[macro_use] extern crate zerocopy; +use util::NotZerocopy; + fn main() {} // Should fail because `NotZerocopy: !FromBytes`. diff --git a/tests/ui-nightly/include_value_not_from_bytes.stderr b/tests/ui-nightly/include_value_not_from_bytes.stderr index 544c3916a0..2d222913d0 100644 --- a/tests/ui-nightly/include_value_not_from_bytes.stderr +++ b/tests/ui-nightly/include_value_not_from_bytes.stderr @@ -1,13 +1,13 @@ -error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied - --> tests/ui-nightly/include_value_not_from_bytes.rs:13:42 +error[E0277]: the trait bound `NotZerocopy: zerocopy::FromBytes` is not satisfied + --> tests/ui-nightly/include_value_not_from_bytes.rs:15:42 | -13 | const NOT_FROM_BYTES: NotZerocopy = include_value!("../../testdata/include_value/data"); +15 | const NOT_FROM_BYTES: NotZerocopy = include_value!("../../testdata/include_value/data"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | the trait `FromBytes` is not implemented for `NotZerocopy` + | the trait `zerocopy::FromBytes` is not implemented for `NotZerocopy` | required by a bound introduced by this call | - = help: the following other types implement trait `FromBytes`: + = help: the following other types implement trait `zerocopy::FromBytes`: isize i8 i16 @@ -18,8 +18,8 @@ error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied u8 and $N others note: required by a bound in `AssertIsFromBytes` - --> tests/ui-nightly/include_value_not_from_bytes.rs:13:42 + --> tests/ui-nightly/include_value_not_from_bytes.rs:15:42 | -13 | const NOT_FROM_BYTES: NotZerocopy = include_value!("../../testdata/include_value/data"); +15 | const NOT_FROM_BYTES: NotZerocopy = include_value!("../../testdata/include_value/data"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertIsFromBytes` = note: this error originates in the macro `$crate::transmute` which comes from the expansion of the macro `include_value` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-nightly/transmute-dst-not-frombytes.rs b/tests/ui-nightly/transmute-dst-not-frombytes.rs index c4caaff917..7b5098e58d 100644 --- a/tests/ui-nightly/transmute-dst-not-frombytes.rs +++ b/tests/ui-nightly/transmute-dst-not-frombytes.rs @@ -6,10 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. -include!("../../zerocopy-derive/tests/util.rs"); +include!("../../zerocopy-derive/tests/include.rs"); extern crate zerocopy; +use util::{NotZerocopy, AU16}; use zerocopy::transmute; fn main() {} diff --git a/tests/ui-nightly/transmute-dst-not-frombytes.stderr b/tests/ui-nightly/transmute-dst-not-frombytes.stderr index a9f1f7becf..8326b7de91 100644 --- a/tests/ui-nightly/transmute-dst-not-frombytes.stderr +++ b/tests/ui-nightly/transmute-dst-not-frombytes.stderr @@ -1,13 +1,13 @@ -error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied - --> tests/ui-nightly/transmute-dst-not-frombytes.rs:18:41 +error[E0277]: the trait bound `NotZerocopy: zerocopy::FromBytes` is not satisfied + --> tests/ui-nightly/transmute-dst-not-frombytes.rs:19:41 | -18 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0)); +19 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0)); | ^^^^^^^^^^^^^^^^^^^ | | - | the trait `FromBytes` is not implemented for `NotZerocopy` + | the trait `zerocopy::FromBytes` is not implemented for `NotZerocopy` | required by a bound introduced by this call | - = help: the following other types implement trait `FromBytes`: + = help: the following other types implement trait `zerocopy::FromBytes`: isize i8 i16 @@ -18,8 +18,8 @@ error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied u8 and $N others note: required by a bound in `AssertIsFromBytes` - --> tests/ui-nightly/transmute-dst-not-frombytes.rs:18:41 + --> tests/ui-nightly/transmute-dst-not-frombytes.rs:19:41 | -18 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0)); +19 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0)); | ^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertIsFromBytes` = note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-nightly/transmute-mut-alignment-increase.rs b/tests/ui-nightly/transmute-mut-alignment-increase.rs index 0928564dd5..daf2ed1d02 100644 --- a/tests/ui-nightly/transmute-mut-alignment-increase.rs +++ b/tests/ui-nightly/transmute-mut-alignment-increase.rs @@ -6,10 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. -include!("../../zerocopy-derive/tests/util.rs"); +include!("../../zerocopy-derive/tests/include.rs"); extern crate zerocopy; +use util::AU16; use zerocopy::transmute_mut; fn main() {} diff --git a/tests/ui-nightly/transmute-mut-alignment-increase.stderr b/tests/ui-nightly/transmute-mut-alignment-increase.stderr index 0666f8b526..e0b418058f 100644 --- a/tests/ui-nightly/transmute-mut-alignment-increase.stderr +++ b/tests/ui-nightly/transmute-mut-alignment-increase.stderr @@ -1,7 +1,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> tests/ui-nightly/transmute-mut-alignment-increase.rs:19:39 + --> tests/ui-nightly/transmute-mut-alignment-increase.rs:20:39 | -19 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); +20 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: source type: `AlignOf<[u8; 2]>` (8 bits) diff --git a/tests/ui-nightly/transmute-mut-const.rs b/tests/ui-nightly/transmute-mut-const.rs index 021b562f18..47372b1be4 100644 --- a/tests/ui-nightly/transmute-mut-const.rs +++ b/tests/ui-nightly/transmute-mut-const.rs @@ -6,7 +6,7 @@ // This file may not be copied, modified, or distributed except according to // those terms. -include!("../../zerocopy-derive/tests/util.rs"); +include!("../../zerocopy-derive/tests/include.rs"); extern crate zerocopy; diff --git a/tests/ui-nightly/transmute-ref-alignment-increase.rs b/tests/ui-nightly/transmute-ref-alignment-increase.rs index bf1988c66b..7d202d51d1 100644 --- a/tests/ui-nightly/transmute-ref-alignment-increase.rs +++ b/tests/ui-nightly/transmute-ref-alignment-increase.rs @@ -6,10 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. -include!("../../zerocopy-derive/tests/util.rs"); +include!("../../zerocopy-derive/tests/include.rs"); extern crate zerocopy; +use util::AU16; use zerocopy::transmute_ref; fn main() {} diff --git a/tests/ui-nightly/transmute-ref-alignment-increase.stderr b/tests/ui-nightly/transmute-ref-alignment-increase.stderr index 1cef246bc3..30fabe5a66 100644 --- a/tests/ui-nightly/transmute-ref-alignment-increase.stderr +++ b/tests/ui-nightly/transmute-ref-alignment-increase.stderr @@ -1,7 +1,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> tests/ui-nightly/transmute-ref-alignment-increase.rs:19:35 + --> tests/ui-nightly/transmute-ref-alignment-increase.rs:20:35 | -19 | const INCREASE_ALIGNMENT: &AU16 = transmute_ref!(&[0u8; 2]); +20 | const INCREASE_ALIGNMENT: &AU16 = transmute_ref!(&[0u8; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: source type: `AlignOf<[u8; 2]>` (8 bits) diff --git a/tests/ui-nightly/transmute-ref-dst-not-frombytes.rs b/tests/ui-nightly/transmute-ref-dst-not-frombytes.rs index 6251323b2a..8882521dc1 100644 --- a/tests/ui-nightly/transmute-ref-dst-not-frombytes.rs +++ b/tests/ui-nightly/transmute-ref-dst-not-frombytes.rs @@ -6,10 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. -include!("../../zerocopy-derive/tests/util.rs"); +include!("../../zerocopy-derive/tests/include.rs"); extern crate zerocopy; +use util::AU16; use zerocopy::transmute_ref; fn main() {} diff --git a/tests/ui-nightly/transmute-ref-dst-not-frombytes.stderr b/tests/ui-nightly/transmute-ref-dst-not-frombytes.stderr index 83f69bcc02..e23723bbd3 100644 --- a/tests/ui-nightly/transmute-ref-dst-not-frombytes.stderr +++ b/tests/ui-nightly/transmute-ref-dst-not-frombytes.stderr @@ -1,13 +1,13 @@ -error[E0277]: the trait bound `Dst: FromBytes` is not satisfied - --> tests/ui-nightly/transmute-ref-dst-not-frombytes.rs:22:34 +error[E0277]: the trait bound `Dst: zerocopy::FromBytes` is not satisfied + --> tests/ui-nightly/transmute-ref-dst-not-frombytes.rs:23:34 | -22 | const DST_NOT_FROM_BYTES: &Dst = transmute_ref!(&AU16(0)); +23 | const DST_NOT_FROM_BYTES: &Dst = transmute_ref!(&AU16(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ | | - | the trait `FromBytes` is not implemented for `Dst` + | the trait `zerocopy::FromBytes` is not implemented for `Dst` | required by a bound introduced by this call | - = help: the following other types implement trait `FromBytes`: + = help: the following other types implement trait `zerocopy::FromBytes`: isize i8 i16 @@ -18,8 +18,8 @@ error[E0277]: the trait bound `Dst: FromBytes` is not satisfied u8 and $N others note: required by a bound in `AssertDstIsFromBytes` - --> tests/ui-nightly/transmute-ref-dst-not-frombytes.rs:22:34 + --> tests/ui-nightly/transmute-ref-dst-not-frombytes.rs:23:34 | -22 | const DST_NOT_FROM_BYTES: &Dst = transmute_ref!(&AU16(0)); +23 | const DST_NOT_FROM_BYTES: &Dst = transmute_ref!(&AU16(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertDstIsFromBytes` = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-nightly/transmute-ref-dst-not-nocell.rs b/tests/ui-nightly/transmute-ref-dst-not-nocell.rs index 014bd86271..64f6c21636 100644 --- a/tests/ui-nightly/transmute-ref-dst-not-nocell.rs +++ b/tests/ui-nightly/transmute-ref-dst-not-nocell.rs @@ -6,10 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. -include!("../../zerocopy-derive/tests/util.rs"); +include!("../../zerocopy-derive/tests/include.rs"); extern crate zerocopy; +use util::AU16; use zerocopy::transmute_ref; fn main() {} diff --git a/tests/ui-nightly/transmute-ref-dst-not-nocell.stderr b/tests/ui-nightly/transmute-ref-dst-not-nocell.stderr index b11951242a..a49b933a8b 100644 --- a/tests/ui-nightly/transmute-ref-dst-not-nocell.stderr +++ b/tests/ui-nightly/transmute-ref-dst-not-nocell.stderr @@ -1,13 +1,13 @@ -error[E0277]: the trait bound `Dst: NoCell` is not satisfied - --> tests/ui-nightly/transmute-ref-dst-not-nocell.rs:22:31 +error[E0277]: the trait bound `Dst: zerocopy::NoCell` is not satisfied + --> tests/ui-nightly/transmute-ref-dst-not-nocell.rs:23:31 | -22 | const DST_NOT_NO_CELL: &Dst = transmute_ref!(&AU16(0)); +23 | const DST_NOT_NO_CELL: &Dst = transmute_ref!(&AU16(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ | | - | the trait `NoCell` is not implemented for `Dst` + | the trait `zerocopy::NoCell` is not implemented for `Dst` | required by a bound introduced by this call | - = help: the following other types implement trait `NoCell`: + = help: the following other types implement trait `zerocopy::NoCell`: bool char isize @@ -18,8 +18,8 @@ error[E0277]: the trait bound `Dst: NoCell` is not satisfied i128 and $N others note: required by a bound in `AssertDstIsNoCell` - --> tests/ui-nightly/transmute-ref-dst-not-nocell.rs:22:31 + --> tests/ui-nightly/transmute-ref-dst-not-nocell.rs:23:31 | -22 | const DST_NOT_NO_CELL: &Dst = transmute_ref!(&AU16(0)); +23 | const DST_NOT_NO_CELL: &Dst = transmute_ref!(&AU16(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertDstIsNoCell` = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-nightly/transmute-ref-src-not-intobytes.rs b/tests/ui-nightly/transmute-ref-src-not-intobytes.rs index e6eabcfcb4..04012f09c0 100644 --- a/tests/ui-nightly/transmute-ref-src-not-intobytes.rs +++ b/tests/ui-nightly/transmute-ref-src-not-intobytes.rs @@ -6,10 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. -include!("../../zerocopy-derive/tests/util.rs"); +include!("../../zerocopy-derive/tests/include.rs"); extern crate zerocopy; +use util::AU16; use zerocopy::transmute_ref; fn main() {} diff --git a/tests/ui-nightly/transmute-ref-src-not-intobytes.stderr b/tests/ui-nightly/transmute-ref-src-not-intobytes.stderr index ad7893013c..5a3c5b6954 100644 --- a/tests/ui-nightly/transmute-ref-src-not-intobytes.stderr +++ b/tests/ui-nightly/transmute-ref-src-not-intobytes.stderr @@ -1,7 +1,7 @@ error[E0277]: the trait bound `Src: AsBytes` is not satisfied - --> tests/ui-nightly/transmute-ref-src-not-intobytes.rs:22:33 + --> tests/ui-nightly/transmute-ref-src-not-intobytes.rs:23:33 | -22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | the trait `AsBytes` is not implemented for `Src` @@ -18,16 +18,16 @@ error[E0277]: the trait bound `Src: AsBytes` is not satisfied i128 and $N others note: required by a bound in `AssertSrcIsIntoBytes` - --> tests/ui-nightly/transmute-ref-src-not-intobytes.rs:22:33 + --> tests/ui-nightly/transmute-ref-src-not-intobytes.rs:23:33 | -22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `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 - --> tests/ui-nightly/transmute-ref-src-not-intobytes.rs:22:33 + --> tests/ui-nightly/transmute-ref-src-not-intobytes.rs:23:33 | -22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `Src` | = help: the following other types implement trait `AsBytes`: @@ -41,8 +41,8 @@ error[E0277]: the trait bound `Src: AsBytes` is not satisfied i128 and $N others note: required by a bound in `AssertSrcIsIntoBytes` - --> tests/ui-nightly/transmute-ref-src-not-intobytes.rs:22:33 + --> tests/ui-nightly/transmute-ref-src-not-intobytes.rs:23:33 | -22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsIntoBytes` = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-nightly/transmute-ref-src-not-nocell.rs b/tests/ui-nightly/transmute-ref-src-not-nocell.rs index 2c1330302c..aea6f137f0 100644 --- a/tests/ui-nightly/transmute-ref-src-not-nocell.rs +++ b/tests/ui-nightly/transmute-ref-src-not-nocell.rs @@ -6,10 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. -include!("../../zerocopy-derive/tests/util.rs"); +include!("../../zerocopy-derive/tests/include.rs"); extern crate zerocopy; +use util::AU16; use zerocopy::transmute_ref; fn main() {} diff --git a/tests/ui-nightly/transmute-ref-src-not-nocell.stderr b/tests/ui-nightly/transmute-ref-src-not-nocell.stderr index 4a2f1d8c43..f813777e10 100644 --- a/tests/ui-nightly/transmute-ref-src-not-nocell.stderr +++ b/tests/ui-nightly/transmute-ref-src-not-nocell.stderr @@ -1,13 +1,13 @@ -error[E0277]: the trait bound `Src: NoCell` is not satisfied - --> tests/ui-nightly/transmute-ref-src-not-nocell.rs:22:32 +error[E0277]: the trait bound `Src: zerocopy::NoCell` is not satisfied + --> tests/ui-nightly/transmute-ref-src-not-nocell.rs:23:32 | -22 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | the trait `NoCell` is not implemented for `Src` + | the trait `zerocopy::NoCell` is not implemented for `Src` | required by a bound introduced by this call | - = help: the following other types implement trait `NoCell`: + = help: the following other types implement trait `zerocopy::NoCell`: bool char isize @@ -18,19 +18,19 @@ error[E0277]: the trait bound `Src: NoCell` is not satisfied i128 and $N others note: required by a bound in `AssertSrcIsNoCell` - --> tests/ui-nightly/transmute-ref-src-not-nocell.rs:22:32 + --> tests/ui-nightly/transmute-ref-src-not-nocell.rs:23:32 | -22 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsNoCell` = 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: NoCell` is not satisfied - --> tests/ui-nightly/transmute-ref-src-not-nocell.rs:22:32 +error[E0277]: the trait bound `Src: zerocopy::NoCell` is not satisfied + --> tests/ui-nightly/transmute-ref-src-not-nocell.rs:23:32 | -22 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NoCell` is not implemented for `Src` +23 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::NoCell` is not implemented for `Src` | - = help: the following other types implement trait `NoCell`: + = help: the following other types implement trait `zerocopy::NoCell`: bool char isize @@ -41,8 +41,8 @@ error[E0277]: the trait bound `Src: NoCell` is not satisfied i128 and $N others note: required by a bound in `AssertSrcIsNoCell` - --> tests/ui-nightly/transmute-ref-src-not-nocell.rs:22:32 + --> tests/ui-nightly/transmute-ref-src-not-nocell.rs:23:32 | -22 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsNoCell` = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-nightly/transmute-size-decrease.rs b/tests/ui-nightly/transmute-size-decrease.rs index 1d56831f22..567b6733f7 100644 --- a/tests/ui-nightly/transmute-size-decrease.rs +++ b/tests/ui-nightly/transmute-size-decrease.rs @@ -6,10 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. -include!("../../zerocopy-derive/tests/util.rs"); +include!("../../zerocopy-derive/tests/include.rs"); extern crate zerocopy; +use util::AU16; use zerocopy::transmute; fn main() {} diff --git a/tests/ui-nightly/transmute-size-decrease.stderr b/tests/ui-nightly/transmute-size-decrease.stderr index 83742d7824..fcd8e05724 100644 --- a/tests/ui-nightly/transmute-size-decrease.stderr +++ b/tests/ui-nightly/transmute-size-decrease.stderr @@ -1,7 +1,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> tests/ui-nightly/transmute-size-decrease.rs:19:27 + --> tests/ui-nightly/transmute-size-decrease.rs:20:27 | -19 | const DECREASE_SIZE: u8 = transmute!(AU16(0)); +20 | const DECREASE_SIZE: u8 = transmute!(AU16(0)); | ^^^^^^^^^^^^^^^^^^^ | = note: source type: `AU16` (16 bits) diff --git a/tests/ui-nightly/transmute-size-increase.rs b/tests/ui-nightly/transmute-size-increase.rs index 32f9363089..35dc780eae 100644 --- a/tests/ui-nightly/transmute-size-increase.rs +++ b/tests/ui-nightly/transmute-size-increase.rs @@ -6,10 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. -include!("../../zerocopy-derive/tests/util.rs"); +include!("../../zerocopy-derive/tests/include.rs"); extern crate zerocopy; +use util::AU16; use zerocopy::transmute; fn main() {} diff --git a/tests/ui-nightly/transmute-size-increase.stderr b/tests/ui-nightly/transmute-size-increase.stderr index 230bb17a77..38dd5901eb 100644 --- a/tests/ui-nightly/transmute-size-increase.stderr +++ b/tests/ui-nightly/transmute-size-increase.stderr @@ -1,7 +1,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> tests/ui-nightly/transmute-size-increase.rs:19:29 + --> tests/ui-nightly/transmute-size-increase.rs:20:29 | -19 | const INCREASE_SIZE: AU16 = transmute!(0u8); +20 | const INCREASE_SIZE: AU16 = transmute!(0u8); | ^^^^^^^^^^^^^^^ | = note: source type: `u8` (8 bits) diff --git a/tests/ui-nightly/transmute-src-not-intobytes.rs b/tests/ui-nightly/transmute-src-not-intobytes.rs index ff9d22beec..73be6c1b74 100644 --- a/tests/ui-nightly/transmute-src-not-intobytes.rs +++ b/tests/ui-nightly/transmute-src-not-intobytes.rs @@ -6,10 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. -include!("../../zerocopy-derive/tests/util.rs"); +include!("../../zerocopy-derive/tests/include.rs"); extern crate zerocopy; +use util::{NotZerocopy, AU16}; use zerocopy::transmute; fn main() {} diff --git a/tests/ui-nightly/transmute-src-not-intobytes.stderr b/tests/ui-nightly/transmute-src-not-intobytes.stderr index ffbe1be140..5c05439ae4 100644 --- a/tests/ui-nightly/transmute-src-not-intobytes.stderr +++ b/tests/ui-nightly/transmute-src-not-intobytes.stderr @@ -1,7 +1,7 @@ error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied - --> tests/ui-nightly/transmute-src-not-intobytes.rs:18:32 + --> tests/ui-nightly/transmute-src-not-intobytes.rs:19:32 | -18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); +19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | the trait `AsBytes` is not implemented for `NotZerocopy` @@ -18,16 +18,16 @@ error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied i128 and $N others note: required by a bound in `AssertIsIntoBytes` - --> tests/ui-nightly/transmute-src-not-intobytes.rs:18:32 + --> tests/ui-nightly/transmute-src-not-intobytes.rs:19:32 | -18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); +19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `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 - --> tests/ui-nightly/transmute-src-not-intobytes.rs:18:32 + --> tests/ui-nightly/transmute-src-not-intobytes.rs:19:32 | -18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); +19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy` | = help: the following other types implement trait `AsBytes`: @@ -41,8 +41,8 @@ error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied i128 and $N others note: required by a bound in `AssertIsIntoBytes` - --> tests/ui-nightly/transmute-src-not-intobytes.rs:18:32 + --> tests/ui-nightly/transmute-src-not-intobytes.rs:19:32 | -18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); +19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertIsIntoBytes` = note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-stable/include_value_not_from_bytes.stderr b/tests/ui-stable/include_value_not_from_bytes.stderr index 40f9439185..a3e7d184a0 100644 --- a/tests/ui-stable/include_value_not_from_bytes.stderr +++ b/tests/ui-stable/include_value_not_from_bytes.stderr @@ -1,13 +1,13 @@ -error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied - --> tests/ui-stable/include_value_not_from_bytes.rs:13:42 +error[E0277]: the trait bound `NotZerocopy: zerocopy::FromBytes` is not satisfied + --> tests/ui-stable/include_value_not_from_bytes.rs:15:42 | -13 | const NOT_FROM_BYTES: NotZerocopy = include_value!("../../testdata/include_value/data"); +15 | const NOT_FROM_BYTES: NotZerocopy = include_value!("../../testdata/include_value/data"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | the trait `FromBytes` is not implemented for `NotZerocopy` + | the trait `zerocopy::FromBytes` is not implemented for `NotZerocopy` | required by a bound introduced by this call | - = help: the following other types implement trait `FromBytes`: + = help: the following other types implement trait `zerocopy::FromBytes`: isize i8 i16 @@ -18,8 +18,8 @@ error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied u8 and $N others note: required by a bound in `AssertIsFromBytes` - --> tests/ui-stable/include_value_not_from_bytes.rs:13:42 + --> tests/ui-stable/include_value_not_from_bytes.rs:15:42 | -13 | const NOT_FROM_BYTES: NotZerocopy = include_value!("../../testdata/include_value/data"); +15 | const NOT_FROM_BYTES: NotZerocopy = include_value!("../../testdata/include_value/data"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertIsFromBytes` = note: this error originates in the macro `$crate::transmute` which comes from the expansion of the macro `include_value` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-stable/transmute-dst-not-frombytes.stderr b/tests/ui-stable/transmute-dst-not-frombytes.stderr index b008bcdb10..7eb282039a 100644 --- a/tests/ui-stable/transmute-dst-not-frombytes.stderr +++ b/tests/ui-stable/transmute-dst-not-frombytes.stderr @@ -1,13 +1,13 @@ -error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied - --> tests/ui-stable/transmute-dst-not-frombytes.rs:18:41 +error[E0277]: the trait bound `NotZerocopy: zerocopy::FromBytes` is not satisfied + --> tests/ui-stable/transmute-dst-not-frombytes.rs:19:41 | -18 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0)); +19 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0)); | ^^^^^^^^^^^^^^^^^^^ | | - | the trait `FromBytes` is not implemented for `NotZerocopy` + | the trait `zerocopy::FromBytes` is not implemented for `NotZerocopy` | required by a bound introduced by this call | - = help: the following other types implement trait `FromBytes`: + = help: the following other types implement trait `zerocopy::FromBytes`: isize i8 i16 @@ -18,8 +18,8 @@ error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied u8 and $N others note: required by a bound in `AssertIsFromBytes` - --> tests/ui-stable/transmute-dst-not-frombytes.rs:18:41 + --> tests/ui-stable/transmute-dst-not-frombytes.rs:19:41 | -18 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0)); +19 | const DST_NOT_FROM_BYTES: NotZerocopy = transmute!(AU16(0)); | ^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertIsFromBytes` = note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-stable/transmute-mut-alignment-increase.stderr b/tests/ui-stable/transmute-mut-alignment-increase.stderr index 252fec9ef8..2b02f27c90 100644 --- a/tests/ui-stable/transmute-mut-alignment-increase.stderr +++ b/tests/ui-stable/transmute-mut-alignment-increase.stderr @@ -1,7 +1,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> tests/ui-stable/transmute-mut-alignment-increase.rs:19:39 + --> tests/ui-stable/transmute-mut-alignment-increase.rs:20:39 | -19 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); +20 | const INCREASE_ALIGNMENT: &mut AU16 = transmute_mut!(&mut [0u8; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: source type: `AlignOf<[u8; 2]>` (8 bits) diff --git a/tests/ui-stable/transmute-ref-alignment-increase.stderr b/tests/ui-stable/transmute-ref-alignment-increase.stderr index a34c4065d1..cd99ff2ec2 100644 --- a/tests/ui-stable/transmute-ref-alignment-increase.stderr +++ b/tests/ui-stable/transmute-ref-alignment-increase.stderr @@ -1,7 +1,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> tests/ui-stable/transmute-ref-alignment-increase.rs:19:35 + --> tests/ui-stable/transmute-ref-alignment-increase.rs:20:35 | -19 | const INCREASE_ALIGNMENT: &AU16 = transmute_ref!(&[0u8; 2]); +20 | const INCREASE_ALIGNMENT: &AU16 = transmute_ref!(&[0u8; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: source type: `AlignOf<[u8; 2]>` (8 bits) diff --git a/tests/ui-stable/transmute-ref-dst-not-frombytes.stderr b/tests/ui-stable/transmute-ref-dst-not-frombytes.stderr index 5f292d286b..738158df30 100644 --- a/tests/ui-stable/transmute-ref-dst-not-frombytes.stderr +++ b/tests/ui-stable/transmute-ref-dst-not-frombytes.stderr @@ -1,13 +1,13 @@ -error[E0277]: the trait bound `Dst: FromBytes` is not satisfied - --> tests/ui-stable/transmute-ref-dst-not-frombytes.rs:22:34 +error[E0277]: the trait bound `Dst: zerocopy::FromBytes` is not satisfied + --> tests/ui-stable/transmute-ref-dst-not-frombytes.rs:23:34 | -22 | const DST_NOT_FROM_BYTES: &Dst = transmute_ref!(&AU16(0)); +23 | const DST_NOT_FROM_BYTES: &Dst = transmute_ref!(&AU16(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ | | - | the trait `FromBytes` is not implemented for `Dst` + | the trait `zerocopy::FromBytes` is not implemented for `Dst` | required by a bound introduced by this call | - = help: the following other types implement trait `FromBytes`: + = help: the following other types implement trait `zerocopy::FromBytes`: isize i8 i16 @@ -18,8 +18,8 @@ error[E0277]: the trait bound `Dst: FromBytes` is not satisfied u8 and $N others note: required by a bound in `AssertDstIsFromBytes` - --> tests/ui-stable/transmute-ref-dst-not-frombytes.rs:22:34 + --> tests/ui-stable/transmute-ref-dst-not-frombytes.rs:23:34 | -22 | const DST_NOT_FROM_BYTES: &Dst = transmute_ref!(&AU16(0)); +23 | const DST_NOT_FROM_BYTES: &Dst = transmute_ref!(&AU16(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertDstIsFromBytes` = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-stable/transmute-ref-dst-not-nocell.stderr b/tests/ui-stable/transmute-ref-dst-not-nocell.stderr index 09f6a9609d..5dddc63f4d 100644 --- a/tests/ui-stable/transmute-ref-dst-not-nocell.stderr +++ b/tests/ui-stable/transmute-ref-dst-not-nocell.stderr @@ -1,13 +1,13 @@ -error[E0277]: the trait bound `Dst: NoCell` is not satisfied - --> tests/ui-stable/transmute-ref-dst-not-nocell.rs:22:31 +error[E0277]: the trait bound `Dst: zerocopy::NoCell` is not satisfied + --> tests/ui-stable/transmute-ref-dst-not-nocell.rs:23:31 | -22 | const DST_NOT_NO_CELL: &Dst = transmute_ref!(&AU16(0)); +23 | const DST_NOT_NO_CELL: &Dst = transmute_ref!(&AU16(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ | | - | the trait `NoCell` is not implemented for `Dst` + | the trait `zerocopy::NoCell` is not implemented for `Dst` | required by a bound introduced by this call | - = help: the following other types implement trait `NoCell`: + = help: the following other types implement trait `zerocopy::NoCell`: bool char isize @@ -18,8 +18,8 @@ error[E0277]: the trait bound `Dst: NoCell` is not satisfied i128 and $N others note: required by a bound in `AssertDstIsNoCell` - --> tests/ui-stable/transmute-ref-dst-not-nocell.rs:22:31 + --> tests/ui-stable/transmute-ref-dst-not-nocell.rs:23:31 | -22 | const DST_NOT_NO_CELL: &Dst = transmute_ref!(&AU16(0)); +23 | const DST_NOT_NO_CELL: &Dst = transmute_ref!(&AU16(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertDstIsNoCell` = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-stable/transmute-ref-src-not-intobytes.stderr b/tests/ui-stable/transmute-ref-src-not-intobytes.stderr index b446fa11db..6f5f2426a4 100644 --- a/tests/ui-stable/transmute-ref-src-not-intobytes.stderr +++ b/tests/ui-stable/transmute-ref-src-not-intobytes.stderr @@ -1,7 +1,7 @@ error[E0277]: the trait bound `Src: AsBytes` is not satisfied - --> tests/ui-stable/transmute-ref-src-not-intobytes.rs:22:33 + --> tests/ui-stable/transmute-ref-src-not-intobytes.rs:23:33 | -22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | the trait `AsBytes` is not implemented for `Src` @@ -18,16 +18,16 @@ error[E0277]: the trait bound `Src: AsBytes` is not satisfied i128 and $N others note: required by a bound in `AssertSrcIsIntoBytes` - --> tests/ui-stable/transmute-ref-src-not-intobytes.rs:22:33 + --> tests/ui-stable/transmute-ref-src-not-intobytes.rs:23:33 | -22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `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 - --> tests/ui-stable/transmute-ref-src-not-intobytes.rs:22:33 + --> tests/ui-stable/transmute-ref-src-not-intobytes.rs:23:33 | -22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `Src` | = help: the following other types implement trait `AsBytes`: @@ -41,8 +41,8 @@ error[E0277]: the trait bound `Src: AsBytes` is not satisfied i128 and $N others note: required by a bound in `AssertSrcIsIntoBytes` - --> tests/ui-stable/transmute-ref-src-not-intobytes.rs:22:33 + --> tests/ui-stable/transmute-ref-src-not-intobytes.rs:23:33 | -22 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_AS_BYTES: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsIntoBytes` = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-stable/transmute-ref-src-not-nocell.stderr b/tests/ui-stable/transmute-ref-src-not-nocell.stderr index 115a32cc9d..13f30a0842 100644 --- a/tests/ui-stable/transmute-ref-src-not-nocell.stderr +++ b/tests/ui-stable/transmute-ref-src-not-nocell.stderr @@ -1,13 +1,13 @@ -error[E0277]: the trait bound `Src: NoCell` is not satisfied - --> tests/ui-stable/transmute-ref-src-not-nocell.rs:22:32 +error[E0277]: the trait bound `Src: zerocopy::NoCell` is not satisfied + --> tests/ui-stable/transmute-ref-src-not-nocell.rs:23:32 | -22 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | the trait `NoCell` is not implemented for `Src` + | the trait `zerocopy::NoCell` is not implemented for `Src` | required by a bound introduced by this call | - = help: the following other types implement trait `NoCell`: + = help: the following other types implement trait `zerocopy::NoCell`: bool char isize @@ -18,19 +18,19 @@ error[E0277]: the trait bound `Src: NoCell` is not satisfied i128 and $N others note: required by a bound in `AssertSrcIsNoCell` - --> tests/ui-stable/transmute-ref-src-not-nocell.rs:22:32 + --> tests/ui-stable/transmute-ref-src-not-nocell.rs:23:32 | -22 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsNoCell` = 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: NoCell` is not satisfied - --> tests/ui-stable/transmute-ref-src-not-nocell.rs:22:32 +error[E0277]: the trait bound `Src: zerocopy::NoCell` is not satisfied + --> tests/ui-stable/transmute-ref-src-not-nocell.rs:23:32 | -22 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NoCell` is not implemented for `Src` +23 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::NoCell` is not implemented for `Src` | - = help: the following other types implement trait `NoCell`: + = help: the following other types implement trait `zerocopy::NoCell`: bool char isize @@ -41,8 +41,8 @@ error[E0277]: the trait bound `Src: NoCell` is not satisfied i128 and $N others note: required by a bound in `AssertSrcIsNoCell` - --> tests/ui-stable/transmute-ref-src-not-nocell.rs:22:32 + --> tests/ui-stable/transmute-ref-src-not-nocell.rs:23:32 | -22 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); +23 | const SRC_NOT_NO_CELL: &AU16 = transmute_ref!(&Src(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertSrcIsNoCell` = note: this error originates in the macro `transmute_ref` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui-stable/transmute-size-decrease.stderr b/tests/ui-stable/transmute-size-decrease.stderr index 0241662fdf..e749222b8f 100644 --- a/tests/ui-stable/transmute-size-decrease.stderr +++ b/tests/ui-stable/transmute-size-decrease.stderr @@ -1,7 +1,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> tests/ui-stable/transmute-size-decrease.rs:19:27 + --> tests/ui-stable/transmute-size-decrease.rs:20:27 | -19 | const DECREASE_SIZE: u8 = transmute!(AU16(0)); +20 | const DECREASE_SIZE: u8 = transmute!(AU16(0)); | ^^^^^^^^^^^^^^^^^^^ | = note: source type: `AU16` (16 bits) diff --git a/tests/ui-stable/transmute-size-increase.stderr b/tests/ui-stable/transmute-size-increase.stderr index 87d82a208c..08d4c75c60 100644 --- a/tests/ui-stable/transmute-size-increase.stderr +++ b/tests/ui-stable/transmute-size-increase.stderr @@ -1,7 +1,7 @@ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types - --> tests/ui-stable/transmute-size-increase.rs:19:29 + --> tests/ui-stable/transmute-size-increase.rs:20:29 | -19 | const INCREASE_SIZE: AU16 = transmute!(0u8); +20 | const INCREASE_SIZE: AU16 = transmute!(0u8); | ^^^^^^^^^^^^^^^ | = note: source type: `u8` (8 bits) diff --git a/tests/ui-stable/transmute-src-not-intobytes.stderr b/tests/ui-stable/transmute-src-not-intobytes.stderr index 5fd73a6382..d3727ed828 100644 --- a/tests/ui-stable/transmute-src-not-intobytes.stderr +++ b/tests/ui-stable/transmute-src-not-intobytes.stderr @@ -1,7 +1,7 @@ error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied - --> tests/ui-stable/transmute-src-not-intobytes.rs:18:32 + --> tests/ui-stable/transmute-src-not-intobytes.rs:19:32 | -18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); +19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | the trait `AsBytes` is not implemented for `NotZerocopy` @@ -18,16 +18,16 @@ error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied i128 and $N others note: required by a bound in `AssertIsIntoBytes` - --> tests/ui-stable/transmute-src-not-intobytes.rs:18:32 + --> tests/ui-stable/transmute-src-not-intobytes.rs:19:32 | -18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); +19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `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 - --> tests/ui-stable/transmute-src-not-intobytes.rs:18:32 + --> tests/ui-stable/transmute-src-not-intobytes.rs:19:32 | -18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); +19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy` | = help: the following other types implement trait `AsBytes`: @@ -41,8 +41,8 @@ error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied i128 and $N others note: required by a bound in `AssertIsIntoBytes` - --> tests/ui-stable/transmute-src-not-intobytes.rs:18:32 + --> tests/ui-stable/transmute-src-not-intobytes.rs:19:32 | -18 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); +19 | const SRC_NOT_AS_BYTES: AU16 = transmute!(NotZerocopy(AU16(0))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `AssertIsIntoBytes` = note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/zerocopy-derive/src/lib.rs b/zerocopy-derive/src/lib.rs index 75799e8cb2..1cfcc3113c 100644 --- a/zerocopy-derive/src/lib.rs +++ b/zerocopy-derive/src/lib.rs @@ -96,6 +96,7 @@ pub fn derive_known_layout(ts: proc_macro::TokenStream) -> proc_macro::TokenStre let (_name, trailing_field_ty) = trailing_field; let leading_fields_tys = leading_fields.iter().map(|(_name, ty)| ty); + let core_path = quote!(::zerocopy::macro_util::core_reexport); let repr_align = reprs .iter() .find_map( @@ -107,8 +108,8 @@ pub fn derive_known_layout(ts: proc_macro::TokenStream) -> proc_macro::TokenStre } }, ) - .map(|repr_align| quote!(NonZeroUsize::new(#repr_align as usize))) - .unwrap_or(quote!(None)); + .map(|repr_align| quote!(#core_path::num::NonZeroUsize::new(#repr_align as usize))) + .unwrap_or(quote!(#core_path::option::Option::None)); let repr_packed = reprs .iter() @@ -117,8 +118,8 @@ pub fn derive_known_layout(ts: proc_macro::TokenStream) -> proc_macro::TokenStre Repr::PackedN(repr_packed) => Some(*repr_packed), _ => None, }) - .map(|repr_packed| quote!(NonZeroUsize::new(#repr_packed as usize))) - .unwrap_or(quote!(None)); + .map(|repr_packed| quote!(#core_path::num::NonZeroUsize::new(#repr_packed as usize))) + .unwrap_or(quote!(#core_path::option::Option::None)); ( SelfBounds::None, @@ -358,18 +359,18 @@ fn derive_try_from_bytes_struct(ast: &DeriveInput, strct: &DataStruct) -> proc_m // validity of a struct is just the composition of the bit // validities of its fields, so this is a sound implementation of // `is_bit_valid`. - fn is_bit_valid(candidate: zerocopy::Maybe) -> bool { + fn is_bit_valid(candidate: ::zerocopy::Maybe) -> bool { true #(&& { // SAFETY: `project` is a field projection of `candidate`, // and `Self` is a struct type. let field_candidate = unsafe { let project = |slf: *mut Self| - ::core::ptr::addr_of_mut!((*slf).#field_names); + ::zerocopy::macro_util::core_reexport::ptr::addr_of_mut!((*slf).#field_names); candidate.project(project) }; - <#field_tys as zerocopy::TryFromBytes>::is_bit_valid(field_candidate) + <#field_tys as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) })* } ) @@ -399,18 +400,18 @@ fn derive_try_from_bytes_union(ast: &DeriveInput, unn: &DataUnion) -> proc_macro // bit validity of a union is not yet well defined in Rust, but it // is guaranteed to be no more strict than this definition. See #696 // for a more in-depth discussion. - fn is_bit_valid(candidate: zerocopy::Maybe) -> bool { + fn is_bit_valid(candidate: ::zerocopy::Maybe) -> bool { false #(|| { // SAFETY: `project` is a field projection of `candidate`, // and `Self` is a union type. let field_candidate = unsafe { let project = |slf: *mut Self| - ::core::ptr::addr_of_mut!((*slf).#field_names); + ::zerocopy::macro_util::core_reexport::ptr::addr_of_mut!((*slf).#field_names); candidate.project(project) }; - <#field_tys as zerocopy::TryFromBytes>::is_bit_valid(field_candidate) + <#field_tys as ::zerocopy::TryFromBytes>::is_bit_valid(field_candidate) })* } ) diff --git a/zerocopy-derive/tests/enum_from_bytes.rs b/zerocopy-derive/tests/enum_from_bytes.rs index 4ca4391c03..48278b51c5 100644 --- a/zerocopy-derive/tests/enum_from_bytes.rs +++ b/zerocopy-derive/tests/enum_from_bytes.rs @@ -6,14 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -mod util; - -use { - static_assertions::assert_impl_all, - zerocopy::{FromBytes, FromZeros}, -}; +include!("include.rs"); // An enum is `FromBytes` if: // - `repr(uN)` or `repr(iN)` @@ -32,7 +29,7 @@ use { // `Variant128` has a discriminant of -128) since Rust won't automatically wrap // a signed discriminant around without you explicitly telling it to. -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] #[repr(u8)] enum FooU8 { Variant0, @@ -293,9 +290,9 @@ enum FooU8 { Variant255, } -assert_impl_all!(FooU8: FromBytes); +util_assert_impl_all!(FooU8: imp::FromBytes); -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] #[repr(i8)] enum FooI8 { Variant0, @@ -556,9 +553,9 @@ enum FooI8 { Variant255, } -assert_impl_all!(FooI8: FromBytes); +util_assert_impl_all!(FooI8: imp::FromBytes); -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] #[repr(u8, align(2))] enum FooU8Align { Variant0, @@ -819,9 +816,9 @@ enum FooU8Align { Variant255, } -assert_impl_all!(FooU8Align: FromBytes); +util_assert_impl_all!(FooU8Align: imp::FromBytes); -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] #[repr(i8, align(2))] enum FooI8Align { Variant0, @@ -1082,9 +1079,9 @@ enum FooI8Align { Variant255, } -assert_impl_all!(FooI8Align: FromBytes); +util_assert_impl_all!(FooI8Align: imp::FromBytes); -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] #[repr(u16)] enum FooU16 { Variant0, @@ -66625,9 +66622,9 @@ enum FooU16 { Variant65535, } -assert_impl_all!(FooU16: FromBytes); +util_assert_impl_all!(FooU16: imp::FromBytes); -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] #[repr(i16)] enum FooI16 { Variant0, @@ -132168,4 +132165,4 @@ enum FooI16 { Variant65535, } -assert_impl_all!(FooI16: FromBytes); +util_assert_impl_all!(FooI16: imp::FromBytes); diff --git a/zerocopy-derive/tests/enum_from_zeros.rs b/zerocopy-derive/tests/enum_from_zeros.rs index df64e4d240..0e2ead1590 100644 --- a/zerocopy-derive/tests/enum_from_zeros.rs +++ b/zerocopy-derive/tests/enum_from_zeros.rs @@ -6,33 +6,33 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -mod util; +include!("include.rs"); -use {static_assertions::assert_impl_all, zerocopy::FromZeros}; - -#[derive(FromZeros)] +#[derive(imp::FromZeros)] #[repr(C)] enum Foo { A, } -assert_impl_all!(Foo: FromZeros); +util_assert_impl_all!(Foo: imp::FromZeros); -#[derive(FromZeros)] +#[derive(imp::FromZeros)] #[repr(C)] enum Bar { A = 0, } -assert_impl_all!(Bar: FromZeros); +util_assert_impl_all!(Bar: imp::FromZeros); -#[derive(FromZeros)] +#[derive(imp::FromZeros)] #[repr(C)] enum Baz { A = 1, B = 0, } -assert_impl_all!(Baz: FromZeros); +util_assert_impl_all!(Baz: imp::FromZeros); diff --git a/zerocopy-derive/tests/enum_known_layout.rs b/zerocopy-derive/tests/enum_known_layout.rs index 98fc8c7bbe..e167f7d922 100644 --- a/zerocopy-derive/tests/enum_known_layout.rs +++ b/zerocopy-derive/tests/enum_known_layout.rs @@ -2,45 +2,45 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -mod util; +include!("include.rs"); -use {core::marker::PhantomData, static_assertions::assert_impl_all, zerocopy::KnownLayout}; - -#[derive(KnownLayout)] +#[derive(imp::KnownLayout)] enum Foo { A, } -assert_impl_all!(Foo: KnownLayout); +util_assert_impl_all!(Foo: imp::KnownLayout); -#[derive(KnownLayout)] +#[derive(imp::KnownLayout)] enum Bar { A = 0, } -assert_impl_all!(Bar: KnownLayout); +util_assert_impl_all!(Bar: imp::KnownLayout); -#[derive(KnownLayout)] +#[derive(imp::KnownLayout)] enum Baz { A = 1, B = 0, } -assert_impl_all!(Baz: KnownLayout); +util_assert_impl_all!(Baz: imp::KnownLayout); // Deriving `KnownLayout` should work if the enum has bounded parameters. -#[derive(KnownLayout)] +#[derive(imp::KnownLayout)] #[repr(C)] -enum WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + KnownLayout, const N: usize> +enum WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::KnownLayout, const N: usize> where 'a: 'b, 'b: 'a, - T: 'a + 'b + KnownLayout, + T: 'a + 'b + imp::KnownLayout, { - Variant([T; N], PhantomData<&'a &'b ()>), + Variant([T; N], imp::PhantomData<&'a &'b ()>), } -assert_impl_all!(WithParams<'static, 'static, u8, 42>: KnownLayout); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::KnownLayout); diff --git a/zerocopy-derive/tests/enum_no_cell.rs b/zerocopy-derive/tests/enum_no_cell.rs index 97bb0a5b2d..1cbaa0e572 100644 --- a/zerocopy-derive/tests/enum_no_cell.rs +++ b/zerocopy-derive/tests/enum_no_cell.rs @@ -2,49 +2,46 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -mod util; +include!("include.rs"); -use { - core::cell::UnsafeCell, core::marker::PhantomData, static_assertions::assert_impl_all, - zerocopy::NoCell, -}; - -#[derive(NoCell)] +#[derive(imp::NoCell)] enum Foo { A, } -assert_impl_all!(Foo: NoCell); +util_assert_impl_all!(Foo: imp::NoCell); -#[derive(NoCell)] +#[derive(imp::NoCell)] enum Bar { A = 0, } -assert_impl_all!(Bar: NoCell); +util_assert_impl_all!(Bar: imp::NoCell); -#[derive(NoCell)] +#[derive(imp::NoCell)] enum Baz { A = 1, B = 0, } -assert_impl_all!(Baz: NoCell); +util_assert_impl_all!(Baz: imp::NoCell); // Deriving `NoCell` should work if the enum has bounded parameters. -#[derive(NoCell)] +#[derive(imp::NoCell)] #[repr(C)] -enum WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + NoCell, const N: usize> +enum WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::NoCell, const N: ::core::primitive::usize> where 'a: 'b, 'b: 'a, - T: 'a + 'b + NoCell, + T: 'a + 'b + imp::NoCell, { - Variant([T; N], PhantomData<&'a &'b ()>), - UnsafeCell(PhantomData>, &'a UnsafeCell<()>), + Variant([T; N], imp::PhantomData<&'a &'b ()>), + UnsafeCell(imp::PhantomData>, &'a imp::UnsafeCell<()>), } -assert_impl_all!(WithParams<'static, 'static, u8, 42>: NoCell); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::NoCell); diff --git a/zerocopy-derive/tests/enum_to_bytes.rs b/zerocopy-derive/tests/enum_to_bytes.rs index bed5a07694..d455fcad79 100644 --- a/zerocopy-derive/tests/enum_to_bytes.rs +++ b/zerocopy-derive/tests/enum_to_bytes.rs @@ -6,96 +6,98 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -use {static_assertions::assert_impl_all, zerocopy::IntoBytes}; +include!("include.rs"); // An enum is `IntoBytes` if if has a defined repr. -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(C)] enum C { A, } -assert_impl_all!(C: IntoBytes); +util_assert_impl_all!(C: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(u8)] enum U8 { A, } -assert_impl_all!(U8: IntoBytes); +util_assert_impl_all!(U8: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(u16)] enum U16 { A, } -assert_impl_all!(U16: IntoBytes); +util_assert_impl_all!(U16: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(u32)] enum U32 { A, } -assert_impl_all!(U32: IntoBytes); +util_assert_impl_all!(U32: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(u64)] enum U64 { A, } -assert_impl_all!(U64: IntoBytes); +util_assert_impl_all!(U64: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(usize)] enum Usize { A, } -assert_impl_all!(Usize: IntoBytes); +util_assert_impl_all!(Usize: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(i8)] enum I8 { A, } -assert_impl_all!(I8: IntoBytes); +util_assert_impl_all!(I8: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(i16)] enum I16 { A, } -assert_impl_all!(I16: IntoBytes); +util_assert_impl_all!(I16: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(i32)] enum I32 { A, } -assert_impl_all!(I32: IntoBytes); +util_assert_impl_all!(I32: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(i64)] enum I64 { A, } -assert_impl_all!(I64: IntoBytes); +util_assert_impl_all!(I64: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(isize)] enum Isize { A, } -assert_impl_all!(Isize: IntoBytes); +util_assert_impl_all!(Isize: imp::IntoBytes); diff --git a/zerocopy-derive/tests/enum_try_from_bytes.rs b/zerocopy-derive/tests/enum_try_from_bytes.rs index 3609e62be4..91bf3f50b3 100644 --- a/zerocopy-derive/tests/enum_try_from_bytes.rs +++ b/zerocopy-derive/tests/enum_try_from_bytes.rs @@ -6,79 +6,78 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -use std::convert::TryFrom; +include!("include.rs"); -use syn::Field; - -mod util; - -use { - static_assertions::assert_impl_all, - zerocopy::{IntoBytes, KnownLayout, TryFromBytes}, -}; - -#[derive(Eq, PartialEq, Debug, KnownLayout, TryFromBytes)] +#[derive(Eq, PartialEq, Debug, imp::KnownLayout, imp::TryFromBytes)] #[repr(u8)] enum Foo { A, } -assert_impl_all!(Foo: TryFromBytes); +util_assert_impl_all!(Foo: imp::TryFromBytes); #[test] fn test_foo() { - assert_eq!(Foo::try_read_from(&[0]), Some(Foo::A)); - assert_eq!(Foo::try_read_from(&[]), None); - assert_eq!(Foo::try_read_from(&[1]), None); - assert_eq!(Foo::try_read_from(&[0, 0]), None); + imp::assert_eq!(::try_read_from(&[0]), imp::Some(Foo::A)); + imp::assert_eq!(::try_read_from(&[]), imp::None); + imp::assert_eq!(::try_read_from(&[1]), imp::None); + imp::assert_eq!(::try_read_from(&[0, 0]), imp::None); } -#[derive(Eq, PartialEq, Debug, KnownLayout, TryFromBytes)] +#[derive(Eq, PartialEq, Debug, imp::KnownLayout, imp::TryFromBytes)] #[repr(u16)] enum Bar { A = 0, } -assert_impl_all!(Bar: TryFromBytes); +util_assert_impl_all!(Bar: imp::TryFromBytes); #[test] fn test_bar() { - assert_eq!(Bar::try_read_from(&[0, 0]), Some(Bar::A)); - assert_eq!(Bar::try_read_from(&[]), None); - assert_eq!(Bar::try_read_from(&[0]), None); - assert_eq!(Bar::try_read_from(&[0, 1]), None); - assert_eq!(Bar::try_read_from(&[0, 0, 0]), None); + imp::assert_eq!(::try_read_from(&[0, 0]), imp::Some(Bar::A)); + imp::assert_eq!(::try_read_from(&[]), imp::None); + imp::assert_eq!(::try_read_from(&[0]), imp::None); + imp::assert_eq!(::try_read_from(&[0, 1]), imp::None); + imp::assert_eq!(::try_read_from(&[0, 0, 0]), imp::None); } -#[derive(Eq, PartialEq, Debug, KnownLayout, TryFromBytes)] +#[derive(Eq, PartialEq, Debug, imp::KnownLayout, imp::TryFromBytes)] #[repr(u32)] enum Baz { A = 1, B = 0, } -assert_impl_all!(Baz: TryFromBytes); +util_assert_impl_all!(Baz: imp::TryFromBytes); #[test] fn test_baz() { - assert_eq!(Baz::try_read_from(1u32.as_bytes()), Some(Baz::A)); - assert_eq!(Baz::try_read_from(0u32.as_bytes()), Some(Baz::B)); - assert_eq!(Baz::try_read_from(&[]), None); - assert_eq!(Baz::try_read_from(&[0]), None); - assert_eq!(Baz::try_read_from(&[0, 0]), None); - assert_eq!(Baz::try_read_from(&[0, 0, 0]), None); - assert_eq!(Baz::try_read_from(&[0, 0, 0, 0, 0]), None); + imp::assert_eq!( + ::try_read_from(imp::AsBytes::as_bytes(&1u32)), + imp::Some(Baz::A) + ); + imp::assert_eq!( + ::try_read_from(imp::AsBytes::as_bytes(&0u32)), + imp::Some(Baz::B) + ); + imp::assert_eq!(::try_read_from(&[]), imp::None); + imp::assert_eq!(::try_read_from(&[0]), imp::None); + imp::assert_eq!(::try_read_from(&[0, 0]), imp::None); + imp::assert_eq!(::try_read_from(&[0, 0, 0]), imp::None); + imp::assert_eq!(::try_read_from(&[0, 0, 0, 0, 0]), imp::None); } // Test hygiene - make sure that `i8` being shadowed doesn't cause problems for // the code emitted by the derive. type i8 = bool; -const THREE: core::primitive::i8 = 3; +const THREE: ::core::primitive::i8 = 3; -#[derive(Eq, PartialEq, Debug, KnownLayout, TryFromBytes)] +#[derive(Eq, PartialEq, Debug, imp::KnownLayout, imp::TryFromBytes)] #[repr(i8)] enum Blah { A = 1, @@ -87,20 +86,32 @@ enum Blah { D = 3 + THREE, } -assert_impl_all!(Blah: TryFromBytes); +util_assert_impl_all!(Blah: imp::TryFromBytes); #[test] fn test_blah() { - assert_eq!(Blah::try_read_from(1i8.as_bytes()), Some(Blah::A)); - assert_eq!(Blah::try_read_from(0i8.as_bytes()), Some(Blah::B)); - assert_eq!(Blah::try_read_from(3i8.as_bytes()), Some(Blah::C)); - assert_eq!(Blah::try_read_from(6i8.as_bytes()), Some(Blah::D)); - assert_eq!(Blah::try_read_from(&[]), None); - assert_eq!(Blah::try_read_from(&[4]), None); - assert_eq!(Blah::try_read_from(&[0, 0]), None); + imp::assert_eq!( + ::try_read_from(imp::AsBytes::as_bytes(&1i8)), + imp::Some(Blah::A) + ); + imp::assert_eq!( + ::try_read_from(imp::AsBytes::as_bytes(&0i8)), + imp::Some(Blah::B) + ); + imp::assert_eq!( + ::try_read_from(imp::AsBytes::as_bytes(&3i8)), + imp::Some(Blah::C) + ); + imp::assert_eq!( + ::try_read_from(imp::AsBytes::as_bytes(&6i8)), + imp::Some(Blah::D) + ); + imp::assert_eq!(::try_read_from(&[]), imp::None); + imp::assert_eq!(::try_read_from(&[4]), imp::None); + imp::assert_eq!(::try_read_from(&[0, 0]), imp::None); } -#[derive(Eq, PartialEq, Debug, KnownLayout, TryFromBytes, IntoBytes)] +#[derive(Eq, PartialEq, Debug, imp::KnownLayout, imp:: TryFromBytes, imp::IntoBytes)] #[repr(C)] enum FieldlessButNotUnitOnly { A, @@ -110,23 +121,29 @@ enum FieldlessButNotUnitOnly { #[test] fn test_fieldless_but_not_unit_only() { - const SIZE: usize = core::mem::size_of::(); - let disc: [u8; SIZE] = zerocopy::transmute!(FieldlessButNotUnitOnly::A); - assert_eq!(FieldlessButNotUnitOnly::try_read_from(&disc[..]), Some(FieldlessButNotUnitOnly::A)); - let disc: [u8; SIZE] = zerocopy::transmute!(FieldlessButNotUnitOnly::B()); - assert_eq!( - FieldlessButNotUnitOnly::try_read_from(&disc[..]), - Some(FieldlessButNotUnitOnly::B()) + const SIZE: usize = ::core::mem::size_of::(); + let disc: [u8; SIZE] = ::zerocopy::transmute!(FieldlessButNotUnitOnly::A); + imp::assert_eq!( + ::try_read_from(&disc[..]), + imp::Some(FieldlessButNotUnitOnly::A) + ); + let disc: [u8; SIZE] = ::zerocopy::transmute!(FieldlessButNotUnitOnly::B()); + imp::assert_eq!( + ::try_read_from(&disc[..]), + imp::Some(FieldlessButNotUnitOnly::B()) ); - let disc: [u8; SIZE] = zerocopy::transmute!(FieldlessButNotUnitOnly::C {}); - assert_eq!( - FieldlessButNotUnitOnly::try_read_from(&disc[..]), - Some(FieldlessButNotUnitOnly::C {}) + let disc: [u8; SIZE] = ::zerocopy::transmute!(FieldlessButNotUnitOnly::C {}); + imp::assert_eq!( + ::try_read_from(&disc[..]), + imp::Some(FieldlessButNotUnitOnly::C {}) + ); + imp::assert_eq!( + ::try_read_from(&[0xFF; SIZE][..]), + imp::None ); - assert_eq!(FieldlessButNotUnitOnly::try_read_from(&[0xFF; SIZE][..]), None); } -#[derive(Eq, PartialEq, Debug, KnownLayout, TryFromBytes, IntoBytes)] +#[derive(Eq, PartialEq, Debug, imp::KnownLayout, imp::TryFromBytes, imp::IntoBytes)] #[repr(C)] enum WeirdDiscriminants { A = -7, @@ -136,12 +153,24 @@ enum WeirdDiscriminants { #[test] fn test_weird_discriminants() { - const SIZE: usize = core::mem::size_of::(); - let disc: [u8; SIZE] = zerocopy::transmute!(WeirdDiscriminants::A); - assert_eq!(WeirdDiscriminants::try_read_from(&disc[..]), Some(WeirdDiscriminants::A)); - let disc: [u8; SIZE] = zerocopy::transmute!(WeirdDiscriminants::B); - assert_eq!(WeirdDiscriminants::try_read_from(&disc[..]), Some(WeirdDiscriminants::B)); - let disc: [u8; SIZE] = zerocopy::transmute!(WeirdDiscriminants::C); - assert_eq!(WeirdDiscriminants::try_read_from(&disc[..]), Some(WeirdDiscriminants::C)); - assert_eq!(WeirdDiscriminants::try_read_from(&[0xFF; SIZE][..]), None); + const SIZE: usize = ::core::mem::size_of::(); + let disc: [u8; SIZE] = ::zerocopy::transmute!(WeirdDiscriminants::A); + imp::assert_eq!( + ::try_read_from(&disc[..]), + imp::Some(WeirdDiscriminants::A) + ); + let disc: [u8; SIZE] = ::zerocopy::transmute!(WeirdDiscriminants::B); + imp::assert_eq!( + ::try_read_from(&disc[..]), + imp::Some(WeirdDiscriminants::B) + ); + let disc: [u8; SIZE] = ::zerocopy::transmute!(WeirdDiscriminants::C); + imp::assert_eq!( + ::try_read_from(&disc[..]), + imp::Some(WeirdDiscriminants::C) + ); + imp::assert_eq!( + ::try_read_from(&[0xFF; SIZE][..]), + imp::None + ); } diff --git a/zerocopy-derive/tests/enum_unaligned.rs b/zerocopy-derive/tests/enum_unaligned.rs index 152ce276b8..2d8f510f98 100644 --- a/zerocopy-derive/tests/enum_unaligned.rs +++ b/zerocopy-derive/tests/enum_unaligned.rs @@ -6,42 +6,44 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -use {static_assertions::assert_impl_all, zerocopy::Unaligned}; +include!("include.rs"); // An enum is `Unaligned` if: // - No `repr(align(N > 1))` // - `repr(u8)` or `repr(i8)` -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(u8)] enum Foo { A, } -assert_impl_all!(Foo: Unaligned); +util_assert_impl_all!(Foo: imp::Unaligned); -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(i8)] enum Bar { A, } -assert_impl_all!(Bar: Unaligned); +util_assert_impl_all!(Bar: imp::Unaligned); -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(u8, align(1))] enum Baz { A, } -assert_impl_all!(Baz: Unaligned); +util_assert_impl_all!(Baz: imp::Unaligned); -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(i8, align(1))] enum Blah { B, } -assert_impl_all!(Blah: Unaligned); +util_assert_impl_all!(Blah: imp::Unaligned); diff --git a/zerocopy-derive/tests/hygiene.rs b/zerocopy-derive/tests/hygiene.rs index 5795ede17b..344be994ee 100644 --- a/zerocopy-derive/tests/hygiene.rs +++ b/zerocopy-derive/tests/hygiene.rs @@ -10,32 +10,34 @@ // that will work properly even if they've renamed the crate and have not // imported its traits. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -extern crate zerocopy as _zerocopy; +include!("include.rs"); -#[macro_use] -mod util; +extern crate zerocopy as _zerocopy; -use std::{marker::PhantomData, option::IntoIter}; +// #[macro_use] +// mod util; -use static_assertions::assert_impl_all; +// use std::{marker::PhantomData, option::IntoIter}; #[derive( _zerocopy::KnownLayout, _zerocopy::FromZeros, _zerocopy::FromBytes, _zerocopy::Unaligned, )] #[repr(C)] -struct TypeParams<'a, T, I: Iterator> { +struct TypeParams<'a, T, I: imp::Iterator> { a: T, c: I::Item, d: u8, - e: PhantomData<&'a [u8]>, - f: PhantomData<&'static str>, - g: PhantomData, + e: imp::PhantomData<&'a [::core::primitive::u8]>, + f: imp::PhantomData<&'static ::core::primitive::str>, + g: imp::PhantomData, } -assert_impl_all!( - TypeParams<'static, (), IntoIter<()>>: +util_assert_impl_all!( + TypeParams<'static, (), imp::IntoIter<()>>: _zerocopy::KnownLayout, _zerocopy::FromZeros, _zerocopy::FromBytes, diff --git a/zerocopy-derive/tests/include.rs b/zerocopy-derive/tests/include.rs new file mode 100644 index 0000000000..c732f72312 --- /dev/null +++ b/zerocopy-derive/tests/include.rs @@ -0,0 +1,85 @@ +// Copyright 2019 The Fuchsia Authors +// +// Licensed under a BSD-style license , Apache License, Version 2.0 +// , or the MIT +// license , at your option. +// This file may not be copied, modified, or distributed except according to +// those terms. + +// ON THE PRELUDE: All of the tests in this directory (excepting UI tests) +// disable the prelude via `#![no_implicit_prelude]`. This ensures that all code +// emitted by our derives doesn't accidentally assume that the prelude is +// included, which helps ensure that items are referred to by absolute path, +// which in turn ensures that these items can't accidentally refer to names +// which have been shadowed. For example, the code `x == None` could behave +// incorrectly if, in the scope in which the derive is invoked, `None` has been +// shadowed by `CONST None: Option = Some(1)`. +// +// `mod imp` allows us to import items and refer to them in this module without +// introducing the risk that this hides bugs in which derive-emitted code uses +// names which are not fully-qualified. For such a bug to manifest, it would +// need to be of the form `imp::Foo`, which is unlikely to happen by accident. +mod imp { + // Since this file is included in every test file, and since not every test + // file uses every item here, we allow unused imports to avoid generating + // warnings. + #[allow(unused)] + pub use { + ::core::{ + assert_eq, cell::UnsafeCell, convert::TryFrom, marker::PhantomData, mem::ManuallyDrop, + option::IntoIter, prelude::v1::*, primitive::*, + }, + ::std::prelude::v1::*, + ::zerocopy::*, + }; +} + +// These items go in their own module (rather than the top level) for the same +// reason that we use `mod imp` above. See its comment for more details. +pub mod util { + /// A type that doesn't implement any zerocopy traits. + pub struct NotZerocopy(pub T); + + /// A `u16` with alignment 2. + /// + /// Though `u16` has alignment 2 on some platforms, it's not guaranteed. By + /// contrast, `util::AU16` is guaranteed to have alignment 2. + #[derive( + super::imp::KnownLayout, + super::imp::NoCell, + super::imp::TryFromBytes, + super::imp::FromZeros, + super::imp::FromBytes, + super::imp::IntoBytes, + Copy, + Clone, + )] + #[repr(C, align(2))] + pub struct AU16(pub u16); + + // Since we can't import these by path (ie, `util::assert_impl_all!`), use a + // name prefix to ensure our derive-emitted code isn't accidentally relying + // on `assert_impl_all!` being in scope. + #[macro_export] + macro_rules! util_assert_impl_all { + ($type:ty: $($trait:path),+ $(,)?) => { + const _: fn() = || { + use ::core::prelude::v1::*; + ::static_assertions::assert_impl_all!($type: $($trait),+); + }; + }; + } + + // Since we can't import these by path (ie, `util::assert_not_impl_any!`), + // use a name prefix to ensure our derive-emitted code isn't accidentally + // relying on `assert_not_impl_any!` being in scope. + #[macro_export] + macro_rules! util_assert_not_impl_any { + ($x:ty: $($t:path),+ $(,)?) => { + const _: fn() = || { + use ::core::prelude::v1::*; + ::static_assertions::assert_not_impl_any!($x: $($t),+); + }; + }; + } +} diff --git a/zerocopy-derive/tests/paths_and_modules.rs b/zerocopy-derive/tests/paths_and_modules.rs index 0c173369d0..34f4067603 100644 --- a/zerocopy-derive/tests/paths_and_modules.rs +++ b/zerocopy-derive/tests/paths_and_modules.rs @@ -6,22 +6,24 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -use zerocopy::{FromBytes, FromZeros, IntoBytes, Unaligned}; +include!("include.rs"); // Ensure that types that are use'd and types that are referenced by path work. mod foo { - use zerocopy::{FromBytes, FromZeros, IntoBytes, Unaligned}; + use super::*; - #[derive(FromZeros, FromBytes, IntoBytes, Unaligned)] + #[derive(imp::FromZeros, imp::FromBytes, imp::IntoBytes, imp::Unaligned)] #[repr(C)] pub struct Foo { foo: u8, } - #[derive(FromZeros, FromBytes, IntoBytes, Unaligned)] + #[derive(imp::FromZeros, imp::FromBytes, imp::IntoBytes, imp::Unaligned)] #[repr(C)] pub struct Bar { bar: u8, @@ -30,7 +32,7 @@ mod foo { use foo::Foo; -#[derive(FromZeros, FromBytes, IntoBytes, Unaligned)] +#[derive(imp::FromZeros, imp::FromBytes, imp::IntoBytes, imp::Unaligned)] #[repr(C)] struct Baz { foo: Foo, diff --git a/zerocopy-derive/tests/priv_in_pub.rs b/zerocopy-derive/tests/priv_in_pub.rs index 009d4201e0..5d73ee0d5d 100644 --- a/zerocopy-derive/tests/priv_in_pub.rs +++ b/zerocopy-derive/tests/priv_in_pub.rs @@ -6,10 +6,16 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] +#![allow(warnings)] + +include!("include.rs"); + // TODO(#847): Make this test succeed on earlier Rust versions. -#[rustversion::stable(1.59)] +#[::rustversion::stable(1.59)] mod test { - use zerocopy::{FromBytes, FromZeros, IntoBytes, KnownLayout, Unaligned}; + use super::*; // These derives do not result in E0446 as of Rust 1.59.0, because of // https://github.com/rust-lang/rust/pull/90586. @@ -18,11 +24,11 @@ mod test { // bounds for field types (i.e., the emission of E0446 for private field // types). - #[derive(KnownLayout, IntoBytes, FromZeros, FromBytes, Unaligned)] + #[derive(imp::KnownLayout, imp::IntoBytes, imp::FromZeros, imp::FromBytes, imp::Unaligned)] #[repr(C)] pub struct Public(Private); - #[derive(KnownLayout, IntoBytes, FromZeros, FromBytes, Unaligned)] + #[derive(imp::KnownLayout, imp::IntoBytes, imp::FromZeros, imp::FromBytes, imp::Unaligned)] #[repr(C)] struct Private(()); } diff --git a/zerocopy-derive/tests/struct_from_bytes.rs b/zerocopy-derive/tests/struct_from_bytes.rs index 234805dd24..4a27752cc3 100644 --- a/zerocopy-derive/tests/struct_from_bytes.rs +++ b/zerocopy-derive/tests/struct_from_bytes.rs @@ -6,74 +6,67 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -mod util; - -use std::{marker::PhantomData, option::IntoIter}; - -use { - static_assertions::assert_impl_all, - zerocopy::{FromBytes, FromZeros}, -}; - -use crate::util::AU16; +include!("include.rs"); // A struct is `FromBytes` if: // - all fields are `FromBytes` -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] struct Zst; -assert_impl_all!(Zst: FromBytes); +util_assert_impl_all!(Zst: imp::FromBytes); -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] struct One { a: u8, } -assert_impl_all!(One: FromBytes); +util_assert_impl_all!(One: imp::FromBytes); -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] struct Two { a: u8, b: Zst, } -assert_impl_all!(Two: FromBytes); +util_assert_impl_all!(Two: imp::FromBytes); -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] struct Unsized { a: [u8], } -assert_impl_all!(Unsized: FromBytes); +util_assert_impl_all!(Unsized: imp::FromBytes); -#[derive(FromZeros, FromBytes)] -struct TypeParams<'a, T: ?Sized, I: Iterator> { +#[derive(imp::FromZeros, imp::FromBytes)] +struct TypeParams<'a, T: ?imp::Sized, I: imp::Iterator> { a: I::Item, b: u8, - c: PhantomData<&'a [u8]>, - d: PhantomData<&'static str>, - e: PhantomData, + c: imp::PhantomData<&'a [::core::primitive::u8]>, + d: imp::PhantomData<&'static ::core::primitive::str>, + e: imp::PhantomData, f: T, } -assert_impl_all!(TypeParams<'static, (), IntoIter<()>>: FromBytes); -assert_impl_all!(TypeParams<'static, AU16, IntoIter<()>>: FromBytes); -assert_impl_all!(TypeParams<'static, [AU16], IntoIter<()>>: FromBytes); +util_assert_impl_all!(TypeParams<'static, (), imp::IntoIter<()>>: imp::FromBytes); +util_assert_impl_all!(TypeParams<'static, util::AU16, imp::IntoIter<()>>: imp::FromBytes); +util_assert_impl_all!(TypeParams<'static, [util::AU16], imp::IntoIter<()>>: imp::FromBytes); // Deriving `FromBytes` should work if the struct has bounded parameters. -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] #[repr(transparent)] -struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + FromBytes, const N: usize>( +struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::FromBytes, const N: usize>( [T; N], - PhantomData<&'a &'b ()>, + imp::PhantomData<&'a &'b ()>, ) where 'a: 'b, 'b: 'a, - T: 'a + 'b + FromBytes; + T: 'a + 'b + imp::FromBytes; -assert_impl_all!(WithParams<'static, 'static, u8, 42>: FromBytes); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::FromBytes); diff --git a/zerocopy-derive/tests/struct_from_zeros.rs b/zerocopy-derive/tests/struct_from_zeros.rs index 304025f027..147b04cf1f 100644 --- a/zerocopy-derive/tests/struct_from_zeros.rs +++ b/zerocopy-derive/tests/struct_from_zeros.rs @@ -6,72 +6,67 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -#[macro_use] -mod util; - -use std::{marker::PhantomData, option::IntoIter}; - -use {static_assertions::assert_impl_all, zerocopy::FromZeros}; - -use crate::util::AU16; +include!("include.rs"); // A struct is `FromZeros` if: // - all fields are `FromZeros` -#[derive(FromZeros)] +#[derive(imp::FromZeros)] struct Zst; -assert_impl_all!(Zst: FromZeros); +util_assert_impl_all!(Zst: imp::FromZeros); -#[derive(FromZeros)] +#[derive(imp::FromZeros)] struct One { a: bool, } -assert_impl_all!(One: FromZeros); +util_assert_impl_all!(One: imp::FromZeros); -#[derive(FromZeros)] +#[derive(imp::FromZeros)] struct Two { a: bool, b: Zst, } -assert_impl_all!(Two: FromZeros); +util_assert_impl_all!(Two: imp::FromZeros); -#[derive(FromZeros)] +#[derive(imp::FromZeros)] struct Unsized { a: [u8], } -assert_impl_all!(Unsized: FromZeros); +util_assert_impl_all!(Unsized: imp::FromZeros); -#[derive(FromZeros)] -struct TypeParams<'a, T: ?Sized, I: Iterator> { +#[derive(imp::FromZeros)] +struct TypeParams<'a, T: ?imp::Sized, I: imp::Iterator> { a: I::Item, b: u8, - c: PhantomData<&'a [u8]>, - d: PhantomData<&'static str>, - e: PhantomData, + c: imp::PhantomData<&'a [u8]>, + d: imp::PhantomData<&'static str>, + e: imp::PhantomData, f: T, } -assert_impl_all!(TypeParams<'static, (), IntoIter<()>>: FromZeros); -assert_impl_all!(TypeParams<'static, AU16, IntoIter<()>>: FromZeros); -assert_impl_all!(TypeParams<'static, [AU16], IntoIter<()>>: FromZeros); +util_assert_impl_all!(TypeParams<'static, (), imp::IntoIter<()>>: imp::FromZeros); +util_assert_impl_all!(TypeParams<'static, util::AU16, imp::IntoIter<()>>: imp::FromZeros); +util_assert_impl_all!(TypeParams<'static, [util::AU16], imp::IntoIter<()>>: imp::FromZeros); // Deriving `FromZeros` should work if the struct has bounded parameters. -#[derive(FromZeros)] +#[derive(imp::FromZeros)] #[repr(transparent)] -struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + FromZeros, const N: usize>( +struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::FromZeros, const N: usize>( [T; N], - PhantomData<&'a &'b ()>, + imp::PhantomData<&'a &'b ()>, ) where 'a: 'b, 'b: 'a, - T: 'a + 'b + FromZeros; + T: 'a + 'b + imp::FromZeros; -assert_impl_all!(WithParams<'static, 'static, u8, 42>: FromZeros); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::FromZeros); diff --git a/zerocopy-derive/tests/struct_known_layout.rs b/zerocopy-derive/tests/struct_known_layout.rs index 0ec299168f..8d2588d54c 100644 --- a/zerocopy-derive/tests/struct_known_layout.rs +++ b/zerocopy-derive/tests/struct_known_layout.rs @@ -2,64 +2,56 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -#[macro_use] -mod util; +include!("include.rs"); -use std::{marker::PhantomData, option::IntoIter}; - -use { - static_assertions::assert_impl_all, - zerocopy::{DstLayout, KnownLayout}, -}; - -use crate::util::AU16; - -#[derive(KnownLayout)] +#[derive(imp::KnownLayout)] struct Zst; -assert_impl_all!(Zst: KnownLayout); +util_assert_impl_all!(Zst: imp::KnownLayout); -#[derive(KnownLayout)] +#[derive(imp::KnownLayout)] struct One { a: bool, } -assert_impl_all!(One: KnownLayout); +util_assert_impl_all!(One: imp::KnownLayout); -#[derive(KnownLayout)] +#[derive(imp::KnownLayout)] struct Two { a: bool, b: Zst, } -assert_impl_all!(Two: KnownLayout); +util_assert_impl_all!(Two: imp::KnownLayout); -#[derive(KnownLayout)] -struct TypeParams<'a, T, I: Iterator> { +#[derive(imp::KnownLayout)] +struct TypeParams<'a, T, I: imp::Iterator> { a: I::Item, b: u8, - c: PhantomData<&'a [u8]>, - d: PhantomData<&'static str>, - e: PhantomData, + c: imp::PhantomData<&'a [::core::primitive::u8]>, + d: imp::PhantomData<&'static ::core::primitive::str>, + e: imp::PhantomData, f: T, } -assert_impl_all!(TypeParams<'static, (), IntoIter<()>>: KnownLayout); -assert_impl_all!(TypeParams<'static, AU16, IntoIter<()>>: KnownLayout); +util_assert_impl_all!(TypeParams<'static, (), imp::IntoIter<()>>: imp::KnownLayout); +util_assert_impl_all!(TypeParams<'static, util::AU16, imp::IntoIter<()>>: imp::KnownLayout); // Deriving `KnownLayout` should work if the struct has bounded parameters. -#[derive(KnownLayout)] +#[derive(imp::KnownLayout)] #[repr(C)] -struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + KnownLayout, const N: usize>( +struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::KnownLayout, const N: usize>( [T; N], - PhantomData<&'a &'b ()>, + imp::PhantomData<&'a &'b ()>, ) where 'a: 'b, 'b: 'a, - T: 'a + 'b + KnownLayout; + T: 'a + 'b + imp::KnownLayout; -assert_impl_all!(WithParams<'static, 'static, u8, 42>: KnownLayout); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::KnownLayout); diff --git a/zerocopy-derive/tests/struct_no_cell.rs b/zerocopy-derive/tests/struct_no_cell.rs index bf43bffbdd..ed3bd70e64 100644 --- a/zerocopy-derive/tests/struct_no_cell.rs +++ b/zerocopy-derive/tests/struct_no_cell.rs @@ -2,100 +2,92 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -#[macro_use] -mod util; +include!("include.rs"); -use std::{cell::UnsafeCell, marker::PhantomData, option::IntoIter}; - -use { - static_assertions::{assert_impl_all, assert_not_impl_any}, - zerocopy::NoCell, -}; - -use crate::util::AU16; - -#[derive(NoCell)] +#[derive(imp::NoCell)] struct Zst; -assert_impl_all!(Zst: NoCell); +util_assert_impl_all!(Zst: imp::NoCell); -#[derive(NoCell)] +#[derive(imp::NoCell)] struct One { a: bool, } -assert_impl_all!(One: NoCell); +util_assert_impl_all!(One: imp::NoCell); -#[derive(NoCell)] +#[derive(imp::NoCell)] struct Two { a: bool, b: Zst, } -assert_impl_all!(Two: NoCell); +util_assert_impl_all!(Two: imp::NoCell); -#[derive(NoCell)] +#[derive(imp::NoCell)] struct Three { a: [u8], } -assert_impl_all!(Three: NoCell); +util_assert_impl_all!(Three: imp::NoCell); -#[derive(NoCell)] +#[derive(imp::NoCell)] struct Four<'a> { - field: &'a UnsafeCell, + field: &'a imp::UnsafeCell, } -assert_impl_all!(Four<'static>: NoCell); +util_assert_impl_all!(Four<'static>: imp::NoCell); -#[derive(NoCell)] -struct TypeParams<'a, T, U, I: Iterator> { +#[derive(imp::NoCell)] +struct TypeParams<'a, T, U, I: imp::Iterator> { a: I::Item, b: u8, - c: PhantomData<&'a [u8]>, - d: PhantomData<&'static str>, - e: PhantomData, - f: PhantomData, + c: imp::PhantomData<&'a [::core::primitive::u8]>, + d: imp::PhantomData<&'static ::core::primitive::str>, + e: imp::PhantomData, + f: imp::PhantomData, g: T, } -assert_impl_all!(TypeParams<'static, (), (), IntoIter<()>>: NoCell); -assert_impl_all!(TypeParams<'static, AU16, AU16, IntoIter<()>>: NoCell); -assert_impl_all!(TypeParams<'static, AU16, UnsafeCell, IntoIter<()>>: NoCell); -assert_not_impl_any!(TypeParams<'static, UnsafeCell<()>, (), IntoIter<()>>: NoCell); -assert_not_impl_any!(TypeParams<'static, [UnsafeCell; 0], (), IntoIter<()>>: NoCell); -assert_not_impl_any!(TypeParams<'static, (), (), IntoIter>>: NoCell); +util_assert_impl_all!(TypeParams<'static, (), (), imp::IntoIter<()>>: imp::NoCell); +util_assert_impl_all!(TypeParams<'static, util::AU16, util::AU16, imp::IntoIter<()>>: imp::NoCell); +util_assert_impl_all!(TypeParams<'static, util::AU16, imp::UnsafeCell, imp::IntoIter<()>>: imp::NoCell); +util_assert_not_impl_any!(TypeParams<'static, imp::UnsafeCell<()>, (), imp::IntoIter<()>>: imp::NoCell); +util_assert_not_impl_any!(TypeParams<'static, [imp::UnsafeCell; 0], (), imp::IntoIter<()>>: imp::NoCell); +util_assert_not_impl_any!(TypeParams<'static, (), (), imp::IntoIter>>: imp::NoCell); trait Trait { type Assoc; } -impl Trait for UnsafeCell { +impl Trait for imp::UnsafeCell { type Assoc = T; } -#[derive(NoCell)] +#[derive(imp::NoCell)] struct WithAssocType { field: ::Assoc, } -assert_impl_all!(WithAssocType>: NoCell); +util_assert_impl_all!(WithAssocType>: imp::NoCell); // Deriving `NoCell` should work if the struct has bounded parameters. -#[derive(NoCell)] +#[derive(imp::NoCell)] #[repr(C)] -struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + NoCell, const N: usize>( +struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::NoCell, const N: usize>( [T; N], - PhantomData<&'a &'b ()>, - PhantomData>, - &'a UnsafeCell<()>, + imp::PhantomData<&'a &'b ()>, + imp::PhantomData>, + &'a imp::UnsafeCell<()>, ) where 'a: 'b, 'b: 'a, - T: 'a + 'b + NoCell; + T: 'a + 'b + imp::NoCell; -assert_impl_all!(WithParams<'static, 'static, u8, 42>: NoCell); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::NoCell); diff --git a/zerocopy-derive/tests/struct_to_bytes.rs b/zerocopy-derive/tests/struct_to_bytes.rs index e3e6efc9bc..5c65180e8a 100644 --- a/zerocopy-derive/tests/struct_to_bytes.rs +++ b/zerocopy-derive/tests/struct_to_bytes.rs @@ -6,18 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -mod util; - -use std::{marker::PhantomData, mem::ManuallyDrop, option::IntoIter}; - -use { - static_assertions::{assert_impl_all, assert_not_impl_any}, - zerocopy::IntoBytes, -}; - -use self::util::AU16; +include!("include.rs"); // A struct is `IntoBytes` if: // - all fields are `IntoBytes` @@ -25,48 +18,48 @@ use self::util::AU16; // - no padding (size of struct equals sum of size of field types) // - `repr(packed)` -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(C)] struct CZst; -assert_impl_all!(CZst: IntoBytes); +util_assert_impl_all!(CZst: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(C)] struct C { a: u8, b: u8, - c: AU16, + c: util::AU16, } -assert_impl_all!(C: IntoBytes); +util_assert_impl_all!(C: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(transparent)] struct Transparent { a: u8, b: CZst, } -assert_impl_all!(Transparent: IntoBytes); +util_assert_impl_all!(Transparent: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(transparent)] -struct TransparentGeneric { +struct TransparentGeneric { a: CZst, b: T, } -assert_impl_all!(TransparentGeneric: IntoBytes); -assert_impl_all!(TransparentGeneric<[u64]>: IntoBytes); +util_assert_impl_all!(TransparentGeneric: imp::IntoBytes); +util_assert_impl_all!(TransparentGeneric<[u64]>: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(C, packed)] struct CZstPacked; -assert_impl_all!(CZstPacked: IntoBytes); +util_assert_impl_all!(CZstPacked: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(C, packed)] struct CPacked { a: u8, @@ -80,9 +73,9 @@ struct CPacked { b: u16, } -assert_impl_all!(CPacked: IntoBytes); +util_assert_impl_all!(CPacked: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(C, packed(2))] // The same caveats as for CPacked apply - we're assuming u64 is at least // 4-byte aligned by default. Without packed(2), this should fail, as there @@ -92,24 +85,24 @@ struct CPacked2 { b: u64, } -assert_impl_all!(CPacked2: IntoBytes); +util_assert_impl_all!(CPacked2: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(C, packed)] -struct CPackedGeneric { +struct CPackedGeneric { t: T, // Unsized types stored in `repr(packed)` structs must not be dropped // because dropping them in-place might be unsound depending on the // alignment of the outer struct. Sized types can be dropped by first being // moved to an aligned stack variable, but this isn't possible with unsized // types. - u: ManuallyDrop, + u: imp::ManuallyDrop, } -assert_impl_all!(CPackedGeneric: IntoBytes); -assert_impl_all!(CPackedGeneric: IntoBytes); +util_assert_impl_all!(CPackedGeneric: imp::IntoBytes); +util_assert_impl_all!(CPackedGeneric: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(packed)] struct Packed { a: u8, @@ -123,67 +116,67 @@ struct Packed { b: u16, } -assert_impl_all!(Packed: IntoBytes); +util_assert_impl_all!(Packed: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(packed)] -struct PackedGeneric { +struct PackedGeneric { t: T, // Unsized types stored in `repr(packed)` structs must not be dropped // because dropping them in-place might be unsound depending on the // alignment of the outer struct. Sized types can be dropped by first being // moved to an aligned stack variable, but this isn't possible with unsized // types. - u: ManuallyDrop, + u: imp::ManuallyDrop, } -assert_impl_all!(PackedGeneric: IntoBytes); -assert_impl_all!(PackedGeneric: IntoBytes); +util_assert_impl_all!(PackedGeneric: imp::IntoBytes); +util_assert_impl_all!(PackedGeneric: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(C)] -struct ReprCGenericOneField { +struct ReprCGenericOneField { t: T, } // Even though `ReprCGenericOneField` has generic type arguments, since it only // has one field, we don't require that its field types implement `Unaligned`. -assert_impl_all!(ReprCGenericOneField: IntoBytes); -assert_impl_all!(ReprCGenericOneField<[AU16]>: IntoBytes); +util_assert_impl_all!(ReprCGenericOneField: imp::IntoBytes); +util_assert_impl_all!(ReprCGenericOneField<[util::AU16]>: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(C)] -struct ReprCGenericMultipleFields { +struct ReprCGenericMultipleFields { t: T, u: U, } // Since `ReprCGenericMultipleFields` is generic and has more than one field, // all field types must implement `Unaligned`. -assert_impl_all!(ReprCGenericMultipleFields: IntoBytes); -assert_impl_all!(ReprCGenericMultipleFields: IntoBytes); -assert_not_impl_any!(ReprCGenericMultipleFields: IntoBytes); -assert_not_impl_any!(ReprCGenericMultipleFields: IntoBytes); +util_assert_impl_all!(ReprCGenericMultipleFields: imp::IntoBytes); +util_assert_impl_all!(ReprCGenericMultipleFields: imp::IntoBytes); +util_assert_not_impl_any!(ReprCGenericMultipleFields: imp::IntoBytes); +util_assert_not_impl_any!(ReprCGenericMultipleFields: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(transparent)] struct Unsized { a: [u8], } -assert_impl_all!(Unsized: IntoBytes); +util_assert_impl_all!(Unsized: imp::IntoBytes); // Deriving `IntoBytes` should work if the struct has bounded parameters. -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(transparent)] -struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + IntoBytes, const N: usize>( +struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::IntoBytes, const N: usize>( [T; N], - PhantomData<&'a &'b ()>, + imp::PhantomData<&'a &'b ()>, ) where 'a: 'b, 'b: 'a, - T: 'a + 'b + IntoBytes; + T: 'a + 'b + imp::IntoBytes; -assert_impl_all!(WithParams<'static, 'static, u8, 42>: IntoBytes); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::IntoBytes); diff --git a/zerocopy-derive/tests/struct_try_from_bytes.rs b/zerocopy-derive/tests/struct_try_from_bytes.rs index 786a7ed507..a0ebdf5784 100644 --- a/zerocopy-derive/tests/struct_try_from_bytes.rs +++ b/zerocopy-derive/tests/struct_try_from_bytes.rs @@ -6,70 +6,63 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -mod util; +include!("include.rs"); -use std::{marker::PhantomData, option::IntoIter}; - -use { - static_assertions::assert_impl_all, - zerocopy::{FromBytes, FromZeros, KnownLayout, TryFromBytes}, -}; - -use crate::util::AU16; - -// A struct is `TryFromBytes` if: -// - all fields are `TryFromBytes` +// A struct is `imp::TryFromBytes` if: +// - all fields are `imp::TryFromBytes` #[test] fn zst() { // TODO(#5): Use `try_transmute` in this test once it's available. - let candidate = zerocopy::Ptr::from_ref(&()); + let candidate = ::zerocopy::Ptr::from_ref(&()); let candidate = candidate.forget_aligned().forget_valid(); - let is_bit_valid = <()>::is_bit_valid(candidate); - assert!(is_bit_valid); + let is_bit_valid = <() as imp::TryFromBytes>::is_bit_valid(candidate); + imp::assert!(is_bit_valid); } -#[derive(TryFromBytes, FromZeros, FromBytes)] +#[derive(imp::TryFromBytes, imp::FromZeros, imp::FromBytes)] #[repr(C)] struct One { a: u8, } -assert_impl_all!(One: TryFromBytes); +util_assert_impl_all!(One: imp::TryFromBytes); #[test] fn one() { // TODO(#5): Use `try_transmute` in this test once it's available. - let candidate = zerocopy::Ptr::from_ref(&One { a: 42 }); + let candidate = ::zerocopy::Ptr::from_ref(&One { a: 42 }); let candidate = candidate.forget_aligned().forget_valid(); - let is_bit_valid = One::is_bit_valid(candidate); - assert!(is_bit_valid); + let is_bit_valid = ::is_bit_valid(candidate); + imp::assert!(is_bit_valid); } -#[derive(TryFromBytes, FromZeros)] +#[derive(imp::TryFromBytes, imp::FromZeros)] #[repr(C)] struct Two { a: bool, b: (), } -assert_impl_all!(Two: TryFromBytes); +util_assert_impl_all!(Two: imp::TryFromBytes); #[test] fn two() { // TODO(#5): Use `try_transmute` in this test once it's available. - let candidate = zerocopy::Ptr::from_ref(&Two { a: false, b: () }); + let candidate = ::zerocopy::Ptr::from_ref(&Two { a: false, b: () }); let candidate = candidate.forget_aligned().forget_valid(); - let is_bit_valid = Two::is_bit_valid(candidate); - assert!(is_bit_valid); + let is_bit_valid = ::is_bit_valid(candidate); + imp::assert!(is_bit_valid); } #[test] fn two_bad() { // TODO(#5): Use `try_transmute` in this test once it's available. - let candidate = zerocopy::Ptr::from_ref(&[2u8][..]); + let candidate = ::zerocopy::Ptr::from_ref(&[2u8][..]); let candidate = candidate.forget_aligned().forget_valid(); // SAFETY: @@ -82,22 +75,22 @@ fn two_bad() { // SAFETY: `candidate`'s referent is as-initialized as `Two`. let candidate = unsafe { candidate.assume_initialized() }; - let is_bit_valid = Two::is_bit_valid(candidate); - assert!(!is_bit_valid); + let is_bit_valid = ::is_bit_valid(candidate); + imp::assert!(!is_bit_valid); } -#[derive(TryFromBytes, FromZeros, FromBytes)] +#[derive(imp::TryFromBytes, imp::FromZeros, imp::FromBytes)] #[repr(C)] struct Unsized { a: [u8], } -assert_impl_all!(Unsized: TryFromBytes); +util_assert_impl_all!(Unsized: imp::TryFromBytes); #[test] fn un_sized() { // TODO(#5): Use `try_transmute` in this test once it's available. - let candidate = zerocopy::Ptr::from_ref(&[16, 12, 42][..]); + let candidate = ::zerocopy::Ptr::from_ref(&[16, 12, 42][..]); let candidate = candidate.forget_aligned().forget_valid(); // SAFETY: @@ -110,41 +103,41 @@ fn un_sized() { // SAFETY: `candidate`'s referent is as-initialized as `Two`. let candidate = unsafe { candidate.assume_initialized() }; - let is_bit_valid = Unsized::is_bit_valid(candidate); - assert!(is_bit_valid); + let is_bit_valid = ::is_bit_valid(candidate); + imp::assert!(is_bit_valid); } -#[derive(TryFromBytes, FromZeros, FromBytes)] +#[derive(imp::TryFromBytes, imp::FromZeros, imp::FromBytes)] #[repr(C)] -struct TypeParams<'a, T: ?Sized, I: Iterator> { +struct TypeParams<'a, T: ?imp::Sized, I: imp::Iterator> { a: I::Item, b: u8, - c: PhantomData<&'a [u8]>, - d: PhantomData<&'static str>, - e: PhantomData, + c: imp::PhantomData<&'a [u8]>, + d: imp::PhantomData<&'static str>, + e: imp::PhantomData, f: T, } -assert_impl_all!(TypeParams<'static, (), IntoIter<()>>: TryFromBytes); -assert_impl_all!(TypeParams<'static, AU16, IntoIter<()>>: TryFromBytes); -assert_impl_all!(TypeParams<'static, [AU16], IntoIter<()>>: TryFromBytes); +util_assert_impl_all!(TypeParams<'static, (), imp::IntoIter<()>>: imp::TryFromBytes); +util_assert_impl_all!(TypeParams<'static, util::AU16, imp::IntoIter<()>>: imp::TryFromBytes); +util_assert_impl_all!(TypeParams<'static, [util::AU16], imp::IntoIter<()>>: imp::TryFromBytes); -// Deriving `TryFromBytes` should work if the struct has bounded parameters. +// Deriving `imp::TryFromBytes` should work if the struct has bounded parameters. -#[derive(TryFromBytes, FromZeros, FromBytes)] +#[derive(imp::TryFromBytes, imp::FromZeros, imp::FromBytes)] #[repr(transparent)] -struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + TryFromBytes, const N: usize>( - PhantomData<&'a &'b ()>, +struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::TryFromBytes, const N: usize>( + imp::PhantomData<&'a &'b ()>, [T], ) where 'a: 'b, 'b: 'a, - T: 'a + 'b + TryFromBytes; + T: 'a + 'b + imp::TryFromBytes; -assert_impl_all!(WithParams<'static, 'static, u8, 42>: TryFromBytes); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::TryFromBytes); -#[derive(Debug, PartialEq, Eq, TryFromBytes, KnownLayout)] +#[derive(Debug, PartialEq, Eq, imp::TryFromBytes, imp::KnownLayout)] #[repr(C, packed)] struct CPacked { a: u8, @@ -161,11 +154,11 @@ struct CPacked { #[test] fn c_packed() { let candidate = &[42u8, 0xFF, 0xFF, 0xFF, 0xFF]; - let converted = CPacked::try_from_ref(candidate); - assert_eq!(converted, Some(&CPacked { a: 42, b: u32::MAX })); + let converted = ::try_from_ref(candidate); + imp::assert_eq!(converted, imp::Some(&CPacked { a: 42, b: u32::MAX })); } -#[derive(TryFromBytes, KnownLayout)] +#[derive(imp::TryFromBytes, imp::KnownLayout)] #[repr(C, packed)] struct CPackedUnsized { a: u8, @@ -182,11 +175,11 @@ struct CPackedUnsized { #[test] fn c_packed_unsized() { let candidate = &[42u8, 0xFF, 0xFF, 0xFF, 0xFF]; - let converted = CPackedUnsized::try_from_ref(candidate); - assert!(converted.is_some()); + let converted = ::try_from_ref(candidate); + imp::assert!(converted.is_some()); } -#[derive(TryFromBytes)] +#[derive(imp::TryFromBytes)] #[repr(packed)] struct PackedUnsized { a: u8, @@ -203,14 +196,14 @@ struct PackedUnsized { #[test] fn packed_unsized() { let candidate = &[42u8, 0xFF, 0xFF, 0xFF, 0xFF]; - let converted = CPackedUnsized::try_from_ref(candidate); - assert!(converted.is_some()); + let converted = ::try_from_ref(candidate); + imp::assert!(converted.is_some()); let candidate = &[42u8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; - let converted = CPackedUnsized::try_from_ref(candidate); - assert!(converted.is_none()); + let converted = ::try_from_ref(candidate); + imp::assert!(converted.is_none()); let candidate = &[42u8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; - let converted = CPackedUnsized::try_from_ref(candidate); - assert!(converted.is_some()); + let converted = ::try_from_ref(candidate); + imp::assert!(converted.is_some()); } diff --git a/zerocopy-derive/tests/struct_unaligned.rs b/zerocopy-derive/tests/struct_unaligned.rs index 87b4539f6b..b2d78e4c9a 100644 --- a/zerocopy-derive/tests/struct_unaligned.rs +++ b/zerocopy-derive/tests/struct_unaligned.rs @@ -6,15 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -mod util; - -use std::{marker::PhantomData, option::IntoIter}; - -use {static_assertions::assert_impl_all, zerocopy::Unaligned}; - -use crate::util::AU16; +include!("include.rs"); // A struct is `Unaligned` if: // - `repr(align)` is no more than 1 and either @@ -22,23 +18,23 @@ use crate::util::AU16; // - all fields Unaligned // - `repr(packed)` -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(C)] struct Foo { a: u8, } -assert_impl_all!(Foo: Unaligned); +util_assert_impl_all!(Foo: imp::Unaligned); -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(transparent)] struct Bar { a: u8, } -assert_impl_all!(Bar: Unaligned); +util_assert_impl_all!(Bar: imp::Unaligned); -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(packed)] struct Baz { // NOTE: The `u16` type is not guaranteed to have alignment 2, although it @@ -51,50 +47,50 @@ struct Baz { a: u16, } -assert_impl_all!(Baz: Unaligned); +util_assert_impl_all!(Baz: imp::Unaligned); -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(C, align(1))] struct FooAlign { a: u8, } -assert_impl_all!(FooAlign: Unaligned); +util_assert_impl_all!(FooAlign: imp::Unaligned); -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(transparent)] struct Unsized { a: [u8], } -assert_impl_all!(Unsized: Unaligned); +util_assert_impl_all!(Unsized: imp::Unaligned); -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(C)] -struct TypeParams<'a, T: ?Sized, I: Iterator> { +struct TypeParams<'a, T: ?imp::Sized, I: imp::Iterator> { a: I::Item, b: u8, - c: PhantomData<&'a [u8]>, - d: PhantomData<&'static str>, - e: PhantomData, + c: imp::PhantomData<&'a [::core::primitive::u8]>, + d: imp::PhantomData<&'static ::core::primitive::str>, + e: imp::PhantomData, f: T, } -assert_impl_all!(TypeParams<'static, (), IntoIter<()>>: Unaligned); -assert_impl_all!(TypeParams<'static, u8, IntoIter<()>>: Unaligned); -assert_impl_all!(TypeParams<'static, [u8], IntoIter<()>>: Unaligned); +util_assert_impl_all!(TypeParams<'static, (), imp::IntoIter<()>>: imp::Unaligned); +util_assert_impl_all!(TypeParams<'static, ::core::primitive::u8, imp::IntoIter<()>>: imp::Unaligned); +util_assert_impl_all!(TypeParams<'static, [::core::primitive::u8], imp::IntoIter<()>>: imp::Unaligned); // Deriving `Unaligned` should work if the struct has bounded parameters. -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(transparent)] -struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + Unaligned, const N: usize>( +struct WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::Unaligned, const N: usize>( [T; N], - PhantomData<&'a &'b ()>, + imp::PhantomData<&'a &'b ()>, ) where 'a: 'b, 'b: 'a, - T: 'a + 'b + Unaligned; + T: 'a + 'b + imp::Unaligned; -assert_impl_all!(WithParams<'static, 'static, u8, 42>: Unaligned); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::Unaligned); diff --git a/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr b/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr index 7b75889206..f55bde0c0b 100644 --- a/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr +++ b/zerocopy-derive/tests/ui-msrv/derive_transparent.stderr @@ -1,89 +1,89 @@ -error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied - --> tests/ui-msrv/derive_transparent.rs:37:1 +error[E0277]: the trait bound `NotZerocopy: zerocopy::TryFromBytes` is not satisfied + --> tests/ui-msrv/derive_transparent.rs:34:1 | -37 | assert_impl_all!(TransparentStruct: TryFromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy` +34 | util_assert_impl_all!(TransparentStruct: TryFromBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::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 +note: required because of the requirements on the impl of `zerocopy::TryFromBytes` for `TransparentStruct` + --> tests/ui-msrv/derive_transparent.rs:24:21 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^^^^ -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-msrv/derive_transparent.rs:37:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-msrv/derive_transparent.rs:34:1 | -37 | assert_impl_all!(TransparentStruct: TryFromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) +34 | util_assert_impl_all!(TransparentStruct: TryFromBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + = note: this error originates in the macro `::static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied - --> tests/ui-msrv/derive_transparent.rs:38:1 + --> tests/ui-msrv/derive_transparent.rs:35:1 | -38 | assert_impl_all!(TransparentStruct: FromZeros); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy` +35 | util_assert_impl_all!(TransparentStruct: FromZeros); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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:27:35 + --> tests/ui-msrv/derive_transparent.rs:24:35 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^ -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-msrv/derive_transparent.rs:38:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-msrv/derive_transparent.rs:35:1 | -38 | assert_impl_all!(TransparentStruct: FromZeros); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) +35 | util_assert_impl_all!(TransparentStruct: FromZeros); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + = note: this error originates in the macro `::static_assertions::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 +error[E0277]: the trait bound `NotZerocopy: zerocopy::FromBytes` is not satisfied + --> tests/ui-msrv/derive_transparent.rs:36:1 | -39 | assert_impl_all!(TransparentStruct: FromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy` +36 | util_assert_impl_all!(TransparentStruct: FromBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::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 +note: required because of the requirements on the impl of `zerocopy::FromBytes` for `TransparentStruct` + --> tests/ui-msrv/derive_transparent.rs:24:46 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^ -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-msrv/derive_transparent.rs:39:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-msrv/derive_transparent.rs:36:1 | -39 | assert_impl_all!(TransparentStruct: FromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) +36 | util_assert_impl_all!(TransparentStruct: FromBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + = note: this error originates in the macro `::static_assertions::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 + --> tests/ui-msrv/derive_transparent.rs:37:1 | -40 | assert_impl_all!(TransparentStruct: IntoBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy` +37 | util_assert_impl_all!(TransparentStruct: IntoBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 + --> tests/ui-msrv/derive_transparent.rs:24:10 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^ -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-msrv/derive_transparent.rs:40:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-msrv/derive_transparent.rs:37:1 | -40 | assert_impl_all!(TransparentStruct: IntoBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) +37 | util_assert_impl_all!(TransparentStruct: IntoBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + = note: this error originates in the macro `::static_assertions::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 + --> tests/ui-msrv/derive_transparent.rs:38:1 | -41 | assert_impl_all!(TransparentStruct: Unaligned); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unaligned` is not implemented for `NotZerocopy` +38 | util_assert_impl_all!(TransparentStruct: 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:27:57 + --> tests/ui-msrv/derive_transparent.rs:24:57 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^ -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-msrv/derive_transparent.rs:41:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-msrv/derive_transparent.rs:38:1 | -41 | assert_impl_all!(TransparentStruct: Unaligned); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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) +38 | util_assert_impl_all!(TransparentStruct: Unaligned); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + = note: this error originates in the macro `::static_assertions::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 44811beab6..14dc29d619 100644 --- a/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr +++ b/zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr @@ -6,44 +6,44 @@ warning: unused import: `zerocopy::KnownLayout` | = note: `#[warn(unused_imports)]` on by default -error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied +error[E0277]: the trait bound `NotZerocopy: zerocopy::TryFromBytes` is not satisfied --> tests/ui-msrv/late_compile_pass.rs:28:10 | 28 | #[derive(TryFromBytes)] - | ^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy` + | ^^^^^^^^^^^^ the trait `zerocopy::TryFromBytes` is not implemented for `NotZerocopy` | = 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: FromZeros` is not satisfied +error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied --> tests/ui-msrv/late_compile_pass.rs:37:10 | 37 | #[derive(FromZeros)] - | ^^^^^^^^^ the trait `FromZeros` is not implemented for `NotZerocopy` + | ^^^^^^^^^ the trait `FromZeroes` 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) -error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied +error[E0277]: the trait bound `NotZerocopy: zerocopy::FromBytes` is not satisfied --> tests/ui-msrv/late_compile_pass.rs:46:10 | 46 | #[derive(FromBytes)] - | ^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy` + | ^^^^^^^^^ the trait `zerocopy::FromBytes` is not implemented for `NotZerocopy` | = 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: FromZeros` is not satisfied +error[E0277]: the trait bound `FromBytes1: FromZeroes` is not satisfied --> tests/ui-msrv/late_compile_pass.rs:46:10 | 46 | #[derive(FromBytes)] - | ^^^^^^^^^ the trait `FromZeros` is not implemented for `FromBytes1` + | ^^^^^^^^^ the trait `FromZeroes` is not implemented for `FromBytes1` | -note: required by a bound in `FromBytes` +note: required by a bound in `zerocopy::FromBytes` --> $WORKSPACE/src/lib.rs | | pub unsafe trait FromBytes: FromZeros { - | ^^^^^^^^^ required by this bound in `FromBytes` + | ^^^^^^^^^ required by this bound in `zerocopy::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 diff --git a/zerocopy-derive/tests/ui-msrv/struct.stderr b/zerocopy-derive/tests/ui-msrv/struct.stderr index 2db472f161..80c5fb123e 100644 --- a/zerocopy-derive/tests/ui-msrv/struct.stderr +++ b/zerocopy-derive/tests/ui-msrv/struct.stderr @@ -64,40 +64,40 @@ note: required because it appears within the type `KL02` = help: see issue #48214 = note: this error originates in the derive macro `KnownLayout` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `NotKnownLayoutDst: KnownLayout` is not satisfied +error[E0277]: the trait bound `NotKnownLayoutDst: zerocopy::KnownLayout` is not satisfied --> tests/ui-msrv/struct.rs:41:10 | 41 | #[derive(KnownLayout)] - | ^^^^^^^^^^^ the trait `KnownLayout` is not implemented for `NotKnownLayoutDst` + | ^^^^^^^^^^^ the trait `zerocopy::KnownLayout` is not implemented for `NotKnownLayoutDst` | = help: see issue #48214 = note: this error originates in the derive macro `KnownLayout` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `NotKnownLayout: KnownLayout` is not satisfied +error[E0277]: the trait bound `NotKnownLayout: zerocopy::KnownLayout` is not satisfied --> tests/ui-msrv/struct.rs:47:10 | 47 | #[derive(KnownLayout)] - | ^^^^^^^^^^^ the trait `KnownLayout` is not implemented for `NotKnownLayout` + | ^^^^^^^^^^^ the trait `zerocopy::KnownLayout` is not implemented for `NotKnownLayout` | = help: see issue #48214 = note: this error originates in the derive macro `KnownLayout` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `UnsafeCell<()>: NoCell` is not satisfied +error[E0277]: the trait bound `UnsafeCell<()>: zerocopy::NoCell` is not satisfied --> tests/ui-msrv/struct.rs:55:10 | 55 | #[derive(NoCell)] - | ^^^^^^ the trait `NoCell` is not implemented for `UnsafeCell<()>` + | ^^^^^^ the trait `zerocopy::NoCell` is not implemented for `UnsafeCell<()>` | = help: see issue #48214 = note: this error originates in the derive macro `NoCell` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `UnsafeCell: NoCell` is not satisfied +error[E0277]: the trait bound `UnsafeCell: zerocopy::NoCell` is not satisfied --> tests/ui-msrv/struct.rs:60:10 | 60 | #[derive(NoCell)] - | ^^^^^^ the trait `NoCell` is not implemented for `UnsafeCell` + | ^^^^^^ the trait `zerocopy::NoCell` is not implemented for `UnsafeCell` | - = note: required because of the requirements on the impl of `NoCell` for `[UnsafeCell; 0]` + = note: required because of the requirements on the impl of `zerocopy::NoCell` for `[UnsafeCell; 0]` = help: see issue #48214 = note: this error originates in the derive macro `NoCell` (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 e69450ef9a..6996006410 100644 --- a/zerocopy-derive/tests/ui-msrv/union.stderr +++ b/zerocopy-derive/tests/ui-msrv/union.stderr @@ -30,13 +30,13 @@ error: cannot derive Unaligned with repr(align(N > 1)) 79 | #[repr(align(2), align(4))] | ^^^^^^^^ -error[E0277]: the trait bound `UnsafeCell<()>: NoCell` is not satisfied +error[E0277]: the trait bound `UnsafeCell<()>: zerocopy::NoCell` is not satisfied --> tests/ui-msrv/union.rs:24:10 | 24 | #[derive(NoCell)] - | ^^^^^^ the trait `NoCell` is not implemented for `UnsafeCell<()>` + | ^^^^^^ the trait `zerocopy::NoCell` is not implemented for `UnsafeCell<()>` | - = note: required because of the requirements on the impl of `NoCell` for `ManuallyDrop>` + = note: required because of the requirements on the impl of `zerocopy::NoCell` for `ManuallyDrop>` = help: see issue #48214 = note: this error originates in the derive macro `NoCell` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/zerocopy-derive/tests/ui-nightly/derive_transparent.rs b/zerocopy-derive/tests/ui-nightly/derive_transparent.rs index 32c01f92cd..5375a5526b 100644 --- a/zerocopy-derive/tests/ui-nightly/derive_transparent.rs +++ b/zerocopy-derive/tests/ui-nightly/derive_transparent.rs @@ -8,17 +8,14 @@ extern crate zerocopy; -#[path = "../util.rs"] +#[path = "../include.rs"] mod util; use core::marker::PhantomData; -use { - static_assertions::assert_impl_all, - zerocopy::{FromBytes, FromZeros, IntoBytes, TryFromBytes, Unaligned}, -}; +use zerocopy::{FromBytes, FromZeros, IntoBytes, TryFromBytes, Unaligned}; -use self::util::NotZerocopy; +use self::util::util::NotZerocopy; fn main() {} @@ -34,8 +31,8 @@ struct TransparentStruct { // It should be legal to derive these traits on a transparent struct, but it // must also ensure the traits are only implemented when the inner type // implements them. -assert_impl_all!(TransparentStruct: TryFromBytes); -assert_impl_all!(TransparentStruct: FromZeros); -assert_impl_all!(TransparentStruct: FromBytes); -assert_impl_all!(TransparentStruct: IntoBytes); -assert_impl_all!(TransparentStruct: Unaligned); +util_assert_impl_all!(TransparentStruct: TryFromBytes); +util_assert_impl_all!(TransparentStruct: FromZeros); +util_assert_impl_all!(TransparentStruct: FromBytes); +util_assert_impl_all!(TransparentStruct: IntoBytes); +util_assert_impl_all!(TransparentStruct: Unaligned); diff --git a/zerocopy-derive/tests/ui-nightly/derive_transparent.stderr b/zerocopy-derive/tests/ui-nightly/derive_transparent.stderr index ec92b8eba8..52809f8326 100644 --- a/zerocopy-derive/tests/ui-nightly/derive_transparent.stderr +++ b/zerocopy-derive/tests/ui-nightly/derive_transparent.stderr @@ -1,10 +1,10 @@ -error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied - --> tests/ui-nightly/derive_transparent.rs:37:18 +error[E0277]: the trait bound `NotZerocopy: zerocopy::TryFromBytes` is not satisfied + --> tests/ui-nightly/derive_transparent.rs:34:23 | -37 | assert_impl_all!(TransparentStruct: TryFromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy`, which is required by `TransparentStruct: TryFromBytes` +34 | util_assert_impl_all!(TransparentStruct: TryFromBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::TryFromBytes` is not implemented for `NotZerocopy`, which is required by `TransparentStruct: zerocopy::TryFromBytes` | - = help: the following other types implement trait `TryFromBytes`: + = help: the following other types implement trait `zerocopy::TryFromBytes`: bool char isize @@ -14,23 +14,23 @@ error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied i64 i128 and $N others -note: required for `TransparentStruct` to implement `TryFromBytes` - --> tests/ui-nightly/derive_transparent.rs:27:21 +note: required for `TransparentStruct` to implement `zerocopy::TryFromBytes` + --> tests/ui-nightly/derive_transparent.rs:24:21 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-nightly/derive_transparent.rs:37:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-nightly/derive_transparent.rs:34:1 | -37 | assert_impl_all!(TransparentStruct: TryFromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` - = note: this error originates in the derive macro `TryFromBytes` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) +34 | util_assert_impl_all!(TransparentStruct: TryFromBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` + = note: this error originates in the derive macro `TryFromBytes` which comes from the expansion of the macro `util_assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied - --> tests/ui-nightly/derive_transparent.rs:38:18 + --> tests/ui-nightly/derive_transparent.rs:35:23 | -38 | assert_impl_all!(TransparentStruct: FromZeros); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy`, which is required by `TransparentStruct: FromZeroes` +35 | util_assert_impl_all!(TransparentStruct: FromZeros); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy`, which is required by `TransparentStruct: FromZeroes` | = help: the following other types implement trait `FromZeroes`: bool @@ -43,24 +43,24 @@ error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied i128 and $N others note: required for `TransparentStruct` to implement `FromZeroes` - --> tests/ui-nightly/derive_transparent.rs:27:35 + --> tests/ui-nightly/derive_transparent.rs:24:35 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-nightly/derive_transparent.rs:38:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-nightly/derive_transparent.rs:35:1 | -38 | assert_impl_all!(TransparentStruct: FromZeros); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` - = note: this error originates in the derive macro `FromZeros` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) +35 | util_assert_impl_all!(TransparentStruct: FromZeros); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` + = note: this error originates in the derive macro `FromZeros` which comes from the expansion of the macro `util_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-nightly/derive_transparent.rs:39:18 +error[E0277]: the trait bound `NotZerocopy: zerocopy::FromBytes` is not satisfied + --> tests/ui-nightly/derive_transparent.rs:36:23 | -39 | assert_impl_all!(TransparentStruct: FromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy`, which is required by `TransparentStruct: FromBytes` +36 | util_assert_impl_all!(TransparentStruct: FromBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::FromBytes` is not implemented for `NotZerocopy`, which is required by `TransparentStruct: zerocopy::FromBytes` | - = help: the following other types implement trait `FromBytes`: + = help: the following other types implement trait `zerocopy::FromBytes`: isize i8 i16 @@ -70,23 +70,23 @@ error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied usize u8 and $N others -note: required for `TransparentStruct` to implement `FromBytes` - --> tests/ui-nightly/derive_transparent.rs:27:46 +note: required for `TransparentStruct` to implement `zerocopy::FromBytes` + --> tests/ui-nightly/derive_transparent.rs:24:46 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-nightly/derive_transparent.rs:39:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-nightly/derive_transparent.rs:36:1 | -39 | assert_impl_all!(TransparentStruct: FromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `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) +36 | util_assert_impl_all!(TransparentStruct: FromBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` + = note: this error originates in the derive macro `FromBytes` which comes from the expansion of the macro `util_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-nightly/derive_transparent.rs:40:18 + --> tests/ui-nightly/derive_transparent.rs:37:23 | -40 | assert_impl_all!(TransparentStruct: IntoBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy`, which is required by `TransparentStruct: AsBytes` +37 | util_assert_impl_all!(TransparentStruct: IntoBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy`, which is required by `TransparentStruct: AsBytes` | = help: the following other types implement trait `AsBytes`: bool @@ -99,22 +99,22 @@ error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied i128 and $N others note: required for `TransparentStruct` to implement `AsBytes` - --> tests/ui-nightly/derive_transparent.rs:27:10 + --> tests/ui-nightly/derive_transparent.rs:24:10 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-nightly/derive_transparent.rs:40:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-nightly/derive_transparent.rs:37:1 | -40 | assert_impl_all!(TransparentStruct: IntoBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` - = note: this error originates in the derive macro `IntoBytes` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) +37 | util_assert_impl_all!(TransparentStruct: IntoBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` + = note: this error originates in the derive macro `IntoBytes` which comes from the expansion of the macro `util_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-nightly/derive_transparent.rs:41:18 + --> tests/ui-nightly/derive_transparent.rs:38:23 | -41 | assert_impl_all!(TransparentStruct: Unaligned); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unaligned` is not implemented for `NotZerocopy`, which is required by `TransparentStruct: Unaligned` +38 | util_assert_impl_all!(TransparentStruct: Unaligned); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unaligned` is not implemented for `NotZerocopy`, which is required by `TransparentStruct: Unaligned` | = help: the following other types implement trait `Unaligned`: bool @@ -127,13 +127,13 @@ error[E0277]: the trait bound `NotZerocopy: Unaligned` is not satisfied U32 and $N others note: required for `TransparentStruct` to implement `Unaligned` - --> tests/ui-nightly/derive_transparent.rs:27:57 + --> tests/ui-nightly/derive_transparent.rs:24:57 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-nightly/derive_transparent.rs:41:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-nightly/derive_transparent.rs:38:1 | -41 | assert_impl_all!(TransparentStruct: Unaligned); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `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) +38 | util_assert_impl_all!(TransparentStruct: Unaligned); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` + = note: this error originates in the derive macro `Unaligned` which comes from the expansion of the macro `util_assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/zerocopy-derive/tests/ui-nightly/late_compile_pass.rs b/zerocopy-derive/tests/ui-nightly/late_compile_pass.rs index d6d5ba3808..5f03e217f4 100644 --- a/zerocopy-derive/tests/ui-nightly/late_compile_pass.rs +++ b/zerocopy-derive/tests/ui-nightly/late_compile_pass.rs @@ -9,10 +9,10 @@ #[macro_use] extern crate zerocopy; -#[path = "../util.rs"] +#[path = "../include.rs"] mod util; -use self::util::{NotZerocopy, AU16}; +use self::util::{util::NotZerocopy, util::AU16}; use zerocopy::KnownLayout; fn main() {} diff --git a/zerocopy-derive/tests/ui-nightly/late_compile_pass.stderr b/zerocopy-derive/tests/ui-nightly/late_compile_pass.stderr index 1882b01bfc..055a4bd9b5 100644 --- a/zerocopy-derive/tests/ui-nightly/late_compile_pass.stderr +++ b/zerocopy-derive/tests/ui-nightly/late_compile_pass.stderr @@ -6,13 +6,13 @@ warning: unused import: `zerocopy::KnownLayout` | = note: `#[warn(unused_imports)]` on by default -error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied +error[E0277]: the trait bound `NotZerocopy: zerocopy::TryFromBytes` is not satisfied --> tests/ui-nightly/late_compile_pass.rs:28:10 | 28 | #[derive(TryFromBytes)] - | ^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy` + | ^^^^^^^^^^^^ the trait `zerocopy::TryFromBytes` is not implemented for `NotZerocopy` | - = help: the following other types implement trait `TryFromBytes`: + = help: the following other types implement trait `zerocopy::TryFromBytes`: bool char isize @@ -46,13 +46,13 @@ error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable = note: this error originates in the derive macro `FromZeros` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied +error[E0277]: the trait bound `NotZerocopy: zerocopy::FromBytes` is not satisfied --> tests/ui-nightly/late_compile_pass.rs:46:10 | 46 | #[derive(FromBytes)] - | ^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy` + | ^^^^^^^^^ the trait `zerocopy::FromBytes` is not implemented for `NotZerocopy` | - = help: the following other types implement trait `FromBytes`: + = help: the following other types implement trait `zerocopy::FromBytes`: isize i8 i16 @@ -82,7 +82,7 @@ error[E0277]: the trait bound `FromBytes1: FromZeroes` is not satisfied i64 i128 and $N others -note: required by a bound in `FromBytes` +note: required by a bound in `zerocopy::FromBytes` --> $WORKSPACE/src/lib.rs | | pub unsafe trait FromBytes: FromZeros { diff --git a/zerocopy-derive/tests/ui-nightly/struct.rs b/zerocopy-derive/tests/ui-nightly/struct.rs index 1bfbc55eae..1f0d2566e9 100644 --- a/zerocopy-derive/tests/ui-nightly/struct.rs +++ b/zerocopy-derive/tests/ui-nightly/struct.rs @@ -9,12 +9,12 @@ #[macro_use] extern crate zerocopy; -#[path = "../util.rs"] +#[path = "../include.rs"] mod util; use zerocopy::KnownLayout; -use self::util::AU16; +use self::util::util::AU16; fn main() {} diff --git a/zerocopy-derive/tests/ui-nightly/struct.stderr b/zerocopy-derive/tests/ui-nightly/struct.stderr index fe3e7fd0fc..4efd52d047 100644 --- a/zerocopy-derive/tests/ui-nightly/struct.stderr +++ b/zerocopy-derive/tests/ui-nightly/struct.stderr @@ -66,13 +66,13 @@ note: required because it appears within the type `KL02` = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable = note: this error originates in the derive macro `KnownLayout` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `NotKnownLayoutDst: KnownLayout` is not satisfied +error[E0277]: the trait bound `NotKnownLayoutDst: zerocopy::KnownLayout` is not satisfied --> tests/ui-nightly/struct.rs:41:10 | 41 | #[derive(KnownLayout)] - | ^^^^^^^^^^^ the trait `KnownLayout` is not implemented for `NotKnownLayoutDst` + | ^^^^^^^^^^^ the trait `zerocopy::KnownLayout` is not implemented for `NotKnownLayoutDst` | - = help: the following other types implement trait `KnownLayout`: + = help: the following other types implement trait `zerocopy::KnownLayout`: bool char isize @@ -86,13 +86,13 @@ error[E0277]: the trait bound `NotKnownLayoutDst: KnownLayout` is not satisfied = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable = note: this error originates in the derive macro `KnownLayout` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `NotKnownLayout: KnownLayout` is not satisfied +error[E0277]: the trait bound `NotKnownLayout: zerocopy::KnownLayout` is not satisfied --> tests/ui-nightly/struct.rs:47:10 | 47 | #[derive(KnownLayout)] - | ^^^^^^^^^^^ the trait `KnownLayout` is not implemented for `NotKnownLayout` + | ^^^^^^^^^^^ the trait `zerocopy::KnownLayout` is not implemented for `NotKnownLayout` | - = help: the following other types implement trait `KnownLayout`: + = help: the following other types implement trait `zerocopy::KnownLayout`: bool char isize @@ -106,13 +106,13 @@ error[E0277]: the trait bound `NotKnownLayout: KnownLayout` is not satisfied = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable = note: this error originates in the derive macro `KnownLayout` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `UnsafeCell<()>: NoCell` is not satisfied +error[E0277]: the trait bound `UnsafeCell<()>: zerocopy::NoCell` is not satisfied --> tests/ui-nightly/struct.rs:55:10 | 55 | #[derive(NoCell)] - | ^^^^^^ the trait `NoCell` is not implemented for `UnsafeCell<()>` + | ^^^^^^ the trait `zerocopy::NoCell` is not implemented for `UnsafeCell<()>` | - = help: the following other types implement trait `NoCell`: + = help: the following other types implement trait `zerocopy::NoCell`: bool char isize @@ -126,13 +126,13 @@ error[E0277]: the trait bound `UnsafeCell<()>: NoCell` is not satisfied = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable = note: this error originates in the derive macro `NoCell` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `UnsafeCell: NoCell` is not satisfied +error[E0277]: the trait bound `UnsafeCell: zerocopy::NoCell` is not satisfied --> tests/ui-nightly/struct.rs:60:10 | 60 | #[derive(NoCell)] - | ^^^^^^ the trait `NoCell` is not implemented for `UnsafeCell`, which is required by `[UnsafeCell; 0]: NoCell` + | ^^^^^^ the trait `zerocopy::NoCell` is not implemented for `UnsafeCell`, which is required by `[UnsafeCell; 0]: zerocopy::NoCell` | - = help: the following other types implement trait `NoCell`: + = help: the following other types implement trait `zerocopy::NoCell`: bool char isize @@ -142,7 +142,7 @@ error[E0277]: the trait bound `UnsafeCell: NoCell` is not satisfied i64 i128 and $N others - = note: required for `[UnsafeCell; 0]` to implement `NoCell` + = note: required for `[UnsafeCell; 0]` to implement `zerocopy::NoCell` = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable = note: this error originates in the derive macro `NoCell` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -154,10 +154,10 @@ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `AU16` has a `#[repr(align)]` attribute - --> tests/ui-nightly/../util.rs + --> tests/ui-nightly/../include.rs | - | pub struct AU16(u16); - | ^^^^^^^^^^^^^^^ + | pub struct AU16(pub u16); + | ^^^^^^^^^^^^^^^ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type --> tests/ui-nightly/struct.rs:77:1 @@ -166,10 +166,10 @@ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `AU16` has a `#[repr(align)]` attribute - --> tests/ui-nightly/../util.rs + --> tests/ui-nightly/../include.rs | - | pub struct AU16(u16); - | ^^^^^^^^^^^^^^^ + | pub struct AU16(pub u16); + | ^^^^^^^^^^^^^^^ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type --> tests/ui-nightly/struct.rs:83:1 @@ -178,10 +178,10 @@ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `AU16` has a `#[repr(align)]` attribute - --> tests/ui-nightly/../util.rs + --> tests/ui-nightly/../include.rs | - | pub struct AU16(u16); - | ^^^^^^^^^^^^^^^ + | pub struct AU16(pub u16); + | ^^^^^^^^^^^^^^^ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type --> tests/ui-nightly/struct.rs:89:1 @@ -190,10 +190,10 @@ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `AU16` has a `#[repr(align)]` attribute - --> tests/ui-nightly/../util.rs + --> tests/ui-nightly/../include.rs | - | pub struct AU16(u16); - | ^^^^^^^^^^^^^^^ + | pub struct AU16(pub u16); + | ^^^^^^^^^^^^^^^ error[E0277]: the trait bound `AU16: Unaligned` is not satisfied --> tests/ui-nightly/struct.rs:100:10 diff --git a/zerocopy-derive/tests/ui-nightly/union.rs b/zerocopy-derive/tests/ui-nightly/union.rs index 660eea6e27..a1b182e56b 100644 --- a/zerocopy-derive/tests/ui-nightly/union.rs +++ b/zerocopy-derive/tests/ui-nightly/union.rs @@ -9,10 +9,10 @@ #[macro_use] extern crate zerocopy; -#[path = "../util.rs"] +#[path = "../include.rs"] mod util; -use self::util::AU16; +use self::util::util::AU16; use std::mem::ManuallyDrop; fn main() {} diff --git a/zerocopy-derive/tests/ui-nightly/union.stderr b/zerocopy-derive/tests/ui-nightly/union.stderr index 8bea1d97f7..b516019a43 100644 --- a/zerocopy-derive/tests/ui-nightly/union.stderr +++ b/zerocopy-derive/tests/ui-nightly/union.stderr @@ -30,13 +30,13 @@ error: cannot derive Unaligned with repr(align(N > 1)) 79 | #[repr(align(2), align(4))] | ^^^^^^^^ -error[E0277]: the trait bound `UnsafeCell<()>: NoCell` is not satisfied +error[E0277]: the trait bound `UnsafeCell<()>: zerocopy::NoCell` is not satisfied --> tests/ui-nightly/union.rs:24:10 | 24 | #[derive(NoCell)] - | ^^^^^^ the trait `NoCell` is not implemented for `UnsafeCell<()>`, which is required by `ManuallyDrop>: NoCell` + | ^^^^^^ the trait `zerocopy::NoCell` is not implemented for `UnsafeCell<()>`, which is required by `ManuallyDrop>: zerocopy::NoCell` | - = help: the following other types implement trait `NoCell`: + = help: the following other types implement trait `zerocopy::NoCell`: bool char isize @@ -46,7 +46,7 @@ error[E0277]: the trait bound `UnsafeCell<()>: NoCell` is not satisfied i64 i128 and $N others - = note: required for `ManuallyDrop>` to implement `NoCell` + = note: required for `ManuallyDrop>` to implement `zerocopy::NoCell` = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable = note: this error originates in the derive macro `NoCell` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/zerocopy-derive/tests/ui-stable/derive_transparent.stderr b/zerocopy-derive/tests/ui-stable/derive_transparent.stderr index 3fb2358586..cbad1f1143 100644 --- a/zerocopy-derive/tests/ui-stable/derive_transparent.stderr +++ b/zerocopy-derive/tests/ui-stable/derive_transparent.stderr @@ -1,10 +1,10 @@ -error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied - --> tests/ui-stable/derive_transparent.rs:37:18 +error[E0277]: the trait bound `NotZerocopy: zerocopy::TryFromBytes` is not satisfied + --> tests/ui-stable/derive_transparent.rs:34:23 | -37 | assert_impl_all!(TransparentStruct: TryFromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy` +34 | util_assert_impl_all!(TransparentStruct: TryFromBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::TryFromBytes` is not implemented for `NotZerocopy` | - = help: the following other types implement trait `TryFromBytes`: + = help: the following other types implement trait `zerocopy::TryFromBytes`: bool char isize @@ -14,23 +14,23 @@ error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied i64 i128 and $N others -note: required for `TransparentStruct` to implement `TryFromBytes` - --> tests/ui-stable/derive_transparent.rs:27:21 +note: required for `TransparentStruct` to implement `zerocopy::TryFromBytes` + --> tests/ui-stable/derive_transparent.rs:24:21 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-stable/derive_transparent.rs:37:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-stable/derive_transparent.rs:34:1 | -37 | assert_impl_all!(TransparentStruct: TryFromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` - = note: this error originates in the derive macro `TryFromBytes` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) +34 | util_assert_impl_all!(TransparentStruct: TryFromBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` + = note: this error originates in the derive macro `TryFromBytes` which comes from the expansion of the macro `util_assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied - --> tests/ui-stable/derive_transparent.rs:38:18 + --> tests/ui-stable/derive_transparent.rs:35:23 | -38 | assert_impl_all!(TransparentStruct: FromZeros); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy` +35 | util_assert_impl_all!(TransparentStruct: FromZeros); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy` | = help: the following other types implement trait `FromZeroes`: bool @@ -43,24 +43,24 @@ error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied i128 and $N others note: required for `TransparentStruct` to implement `FromZeroes` - --> tests/ui-stable/derive_transparent.rs:27:35 + --> tests/ui-stable/derive_transparent.rs:24:35 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-stable/derive_transparent.rs:38:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-stable/derive_transparent.rs:35:1 | -38 | assert_impl_all!(TransparentStruct: FromZeros); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` - = note: this error originates in the derive macro `FromZeros` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) +35 | util_assert_impl_all!(TransparentStruct: FromZeros); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` + = note: this error originates in the derive macro `FromZeros` which comes from the expansion of the macro `util_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-stable/derive_transparent.rs:39:18 +error[E0277]: the trait bound `NotZerocopy: zerocopy::FromBytes` is not satisfied + --> tests/ui-stable/derive_transparent.rs:36:23 | -39 | assert_impl_all!(TransparentStruct: FromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy` +36 | util_assert_impl_all!(TransparentStruct: FromBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::FromBytes` is not implemented for `NotZerocopy` | - = help: the following other types implement trait `FromBytes`: + = help: the following other types implement trait `zerocopy::FromBytes`: isize i8 i16 @@ -70,23 +70,23 @@ error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied usize u8 and $N others -note: required for `TransparentStruct` to implement `FromBytes` - --> tests/ui-stable/derive_transparent.rs:27:46 +note: required for `TransparentStruct` to implement `zerocopy::FromBytes` + --> tests/ui-stable/derive_transparent.rs:24:46 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-stable/derive_transparent.rs:39:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-stable/derive_transparent.rs:36:1 | -39 | assert_impl_all!(TransparentStruct: FromBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `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) +36 | util_assert_impl_all!(TransparentStruct: FromBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` + = note: this error originates in the derive macro `FromBytes` which comes from the expansion of the macro `util_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-stable/derive_transparent.rs:40:18 + --> tests/ui-stable/derive_transparent.rs:37:23 | -40 | assert_impl_all!(TransparentStruct: IntoBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy` +37 | util_assert_impl_all!(TransparentStruct: IntoBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy` | = help: the following other types implement trait `AsBytes`: bool @@ -99,22 +99,22 @@ error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied i128 and $N others note: required for `TransparentStruct` to implement `AsBytes` - --> tests/ui-stable/derive_transparent.rs:27:10 + --> tests/ui-stable/derive_transparent.rs:24:10 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-stable/derive_transparent.rs:40:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-stable/derive_transparent.rs:37:1 | -40 | assert_impl_all!(TransparentStruct: IntoBytes); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` - = note: this error originates in the derive macro `IntoBytes` which comes from the expansion of the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) +37 | util_assert_impl_all!(TransparentStruct: IntoBytes); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` + = note: this error originates in the derive macro `IntoBytes` which comes from the expansion of the macro `util_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-stable/derive_transparent.rs:41:18 + --> tests/ui-stable/derive_transparent.rs:38:23 | -41 | assert_impl_all!(TransparentStruct: Unaligned); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unaligned` is not implemented for `NotZerocopy` +38 | util_assert_impl_all!(TransparentStruct: Unaligned); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unaligned` is not implemented for `NotZerocopy` | = help: the following other types implement trait `Unaligned`: bool @@ -127,13 +127,13 @@ error[E0277]: the trait bound `NotZerocopy: Unaligned` is not satisfied U128 and $N others note: required for `TransparentStruct` to implement `Unaligned` - --> tests/ui-stable/derive_transparent.rs:27:57 + --> tests/ui-stable/derive_transparent.rs:24:57 | -27 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] +24 | #[derive(IntoBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)] | ^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro -note: required by a bound in `_::{closure#0}::assert_impl_all` - --> tests/ui-stable/derive_transparent.rs:41:1 +note: required by a bound in `_::{closure#0}::_::{closure#0}::assert_impl_all` + --> tests/ui-stable/derive_transparent.rs:38:1 | -41 | assert_impl_all!(TransparentStruct: Unaligned); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `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) +38 | util_assert_impl_all!(TransparentStruct: Unaligned); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all` + = note: this error originates in the derive macro `Unaligned` which comes from the expansion of the macro `util_assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/zerocopy-derive/tests/ui-stable/late_compile_pass.stderr b/zerocopy-derive/tests/ui-stable/late_compile_pass.stderr index f0c1904ed4..5a9c8147be 100644 --- a/zerocopy-derive/tests/ui-stable/late_compile_pass.stderr +++ b/zerocopy-derive/tests/ui-stable/late_compile_pass.stderr @@ -6,13 +6,13 @@ warning: unused import: `zerocopy::KnownLayout` | = note: `#[warn(unused_imports)]` on by default -error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied +error[E0277]: the trait bound `NotZerocopy: zerocopy::TryFromBytes` is not satisfied --> tests/ui-stable/late_compile_pass.rs:28:10 | 28 | #[derive(TryFromBytes)] - | ^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy` + | ^^^^^^^^^^^^ the trait `zerocopy::TryFromBytes` is not implemented for `NotZerocopy` | - = help: the following other types implement trait `TryFromBytes`: + = help: the following other types implement trait `zerocopy::TryFromBytes`: bool char isize @@ -44,13 +44,13 @@ error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied = help: see issue #48214 = note: this error originates in the derive macro `FromZeros` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied +error[E0277]: the trait bound `NotZerocopy: zerocopy::FromBytes` is not satisfied --> tests/ui-stable/late_compile_pass.rs:46:10 | 46 | #[derive(FromBytes)] - | ^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy` + | ^^^^^^^^^ the trait `zerocopy::FromBytes` is not implemented for `NotZerocopy` | - = help: the following other types implement trait `FromBytes`: + = help: the following other types implement trait `zerocopy::FromBytes`: isize i8 i16 @@ -79,7 +79,7 @@ error[E0277]: the trait bound `FromBytes1: FromZeroes` is not satisfied i64 i128 and $N others -note: required by a bound in `FromBytes` +note: required by a bound in `zerocopy::FromBytes` --> $WORKSPACE/src/lib.rs | | pub unsafe trait FromBytes: FromZeros { diff --git a/zerocopy-derive/tests/ui-stable/struct.stderr b/zerocopy-derive/tests/ui-stable/struct.stderr index 24b102da0b..f923cf372e 100644 --- a/zerocopy-derive/tests/ui-stable/struct.stderr +++ b/zerocopy-derive/tests/ui-stable/struct.stderr @@ -64,13 +64,13 @@ note: required because it appears within the type `KL02` = help: see issue #48214 = note: this error originates in the derive macro `KnownLayout` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `NotKnownLayoutDst: KnownLayout` is not satisfied +error[E0277]: the trait bound `NotKnownLayoutDst: zerocopy::KnownLayout` is not satisfied --> tests/ui-stable/struct.rs:41:10 | 41 | #[derive(KnownLayout)] - | ^^^^^^^^^^^ the trait `KnownLayout` is not implemented for `NotKnownLayoutDst` + | ^^^^^^^^^^^ the trait `zerocopy::KnownLayout` is not implemented for `NotKnownLayoutDst` | - = help: the following other types implement trait `KnownLayout`: + = help: the following other types implement trait `zerocopy::KnownLayout`: bool char isize @@ -83,13 +83,13 @@ error[E0277]: the trait bound `NotKnownLayoutDst: KnownLayout` is not satisfied = help: see issue #48214 = note: this error originates in the derive macro `KnownLayout` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `NotKnownLayout: KnownLayout` is not satisfied +error[E0277]: the trait bound `NotKnownLayout: zerocopy::KnownLayout` is not satisfied --> tests/ui-stable/struct.rs:47:10 | 47 | #[derive(KnownLayout)] - | ^^^^^^^^^^^ the trait `KnownLayout` is not implemented for `NotKnownLayout` + | ^^^^^^^^^^^ the trait `zerocopy::KnownLayout` is not implemented for `NotKnownLayout` | - = help: the following other types implement trait `KnownLayout`: + = help: the following other types implement trait `zerocopy::KnownLayout`: bool char isize @@ -102,13 +102,13 @@ error[E0277]: the trait bound `NotKnownLayout: KnownLayout` is not satisfied = help: see issue #48214 = note: this error originates in the derive macro `KnownLayout` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `UnsafeCell<()>: NoCell` is not satisfied +error[E0277]: the trait bound `UnsafeCell<()>: zerocopy::NoCell` is not satisfied --> tests/ui-stable/struct.rs:55:10 | 55 | #[derive(NoCell)] - | ^^^^^^ the trait `NoCell` is not implemented for `UnsafeCell<()>` + | ^^^^^^ the trait `zerocopy::NoCell` is not implemented for `UnsafeCell<()>` | - = help: the following other types implement trait `NoCell`: + = help: the following other types implement trait `zerocopy::NoCell`: bool char isize @@ -121,13 +121,13 @@ error[E0277]: the trait bound `UnsafeCell<()>: NoCell` is not satisfied = help: see issue #48214 = note: this error originates in the derive macro `NoCell` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `UnsafeCell: NoCell` is not satisfied +error[E0277]: the trait bound `UnsafeCell: zerocopy::NoCell` is not satisfied --> tests/ui-stable/struct.rs:60:10 | 60 | #[derive(NoCell)] - | ^^^^^^ the trait `NoCell` is not implemented for `UnsafeCell` + | ^^^^^^ the trait `zerocopy::NoCell` is not implemented for `UnsafeCell` | - = help: the following other types implement trait `NoCell`: + = help: the following other types implement trait `zerocopy::NoCell`: bool char isize @@ -137,7 +137,7 @@ error[E0277]: the trait bound `UnsafeCell: NoCell` is not satisfied i64 i128 and $N others - = note: required for `[UnsafeCell; 0]` to implement `NoCell` + = note: required for `[UnsafeCell; 0]` to implement `zerocopy::NoCell` = help: see issue #48214 = note: this error originates in the derive macro `NoCell` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -187,10 +187,10 @@ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `AU16` has a `#[repr(align)]` attribute - --> tests/ui-stable/../util.rs + --> tests/ui-stable/../include.rs | - | pub struct AU16(u16); - | ^^^^^^^^^^^^^^^ + | pub struct AU16(pub u16); + | ^^^^^^^^^^^^^^^ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type --> tests/ui-stable/struct.rs:77:1 @@ -199,10 +199,10 @@ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `AU16` has a `#[repr(align)]` attribute - --> tests/ui-stable/../util.rs + --> tests/ui-stable/../include.rs | - | pub struct AU16(u16); - | ^^^^^^^^^^^^^^^ + | pub struct AU16(pub u16); + | ^^^^^^^^^^^^^^^ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type --> tests/ui-stable/struct.rs:83:1 @@ -211,10 +211,10 @@ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `AU16` has a `#[repr(align)]` attribute - --> tests/ui-stable/../util.rs + --> tests/ui-stable/../include.rs | - | pub struct AU16(u16); - | ^^^^^^^^^^^^^^^ + | pub struct AU16(pub u16); + | ^^^^^^^^^^^^^^^ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type --> tests/ui-stable/struct.rs:89:1 @@ -223,10 +223,10 @@ error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `AU16` has a `#[repr(align)]` attribute - --> tests/ui-stable/../util.rs + --> tests/ui-stable/../include.rs | - | pub struct AU16(u16); - | ^^^^^^^^^^^^^^^ + | pub struct AU16(pub u16); + | ^^^^^^^^^^^^^^^ error[E0587]: type has conflicting packed and align representation hints --> tests/ui-stable/struct.rs:139:1 diff --git a/zerocopy-derive/tests/ui-stable/union.stderr b/zerocopy-derive/tests/ui-stable/union.stderr index 24b425452e..a4d9e8049f 100644 --- a/zerocopy-derive/tests/ui-stable/union.stderr +++ b/zerocopy-derive/tests/ui-stable/union.stderr @@ -30,13 +30,13 @@ error: cannot derive Unaligned with repr(align(N > 1)) 79 | #[repr(align(2), align(4))] | ^^^^^^^^ -error[E0277]: the trait bound `UnsafeCell<()>: NoCell` is not satisfied +error[E0277]: the trait bound `UnsafeCell<()>: zerocopy::NoCell` is not satisfied --> tests/ui-stable/union.rs:24:10 | 24 | #[derive(NoCell)] - | ^^^^^^ the trait `NoCell` is not implemented for `UnsafeCell<()>` + | ^^^^^^ the trait `zerocopy::NoCell` is not implemented for `UnsafeCell<()>` | - = help: the following other types implement trait `NoCell`: + = help: the following other types implement trait `zerocopy::NoCell`: bool char isize @@ -46,7 +46,7 @@ error[E0277]: the trait bound `UnsafeCell<()>: NoCell` is not satisfied i64 i128 and $N others - = note: required for `ManuallyDrop>` to implement `NoCell` + = note: required for `ManuallyDrop>` to implement `zerocopy::NoCell` = help: see issue #48214 = note: this error originates in the derive macro `NoCell` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/zerocopy-derive/tests/union_from_bytes.rs b/zerocopy-derive/tests/union_from_bytes.rs index e720b538f9..0bafc5d0e6 100644 --- a/zerocopy-derive/tests/union_from_bytes.rs +++ b/zerocopy-derive/tests/union_from_bytes.rs @@ -6,67 +6,64 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -use std::{marker::PhantomData, option::IntoIter}; +include!("include.rs"); -use { - static_assertions::assert_impl_all, - zerocopy::{FromBytes, FromZeros}, -}; +// A union is `imp::FromBytes` if: +// - all fields are `imp::FromBytes` -// A union is `FromBytes` if: -// - all fields are `FromBytes` - -#[derive(Clone, Copy, FromZeros, FromBytes)] +#[derive(Clone, Copy, imp::FromZeros, imp::FromBytes)] union Zst { a: (), } -assert_impl_all!(Zst: FromBytes); +util_assert_impl_all!(Zst: imp::FromBytes); -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] union One { a: u8, } -assert_impl_all!(One: FromBytes); +util_assert_impl_all!(One: imp::FromBytes); -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] union Two { a: u8, b: Zst, } -assert_impl_all!(Two: FromBytes); +util_assert_impl_all!(Two: imp::FromBytes); -#[derive(FromZeros, FromBytes)] -union TypeParams<'a, T: Copy, I: Iterator> +#[derive(imp::FromZeros, imp::FromBytes)] +union TypeParams<'a, T: imp::Copy, I: imp::Iterator> where - I::Item: Copy, + I::Item: imp::Copy, { a: T, c: I::Item, d: u8, - e: PhantomData<&'a [u8]>, - f: PhantomData<&'static str>, - g: PhantomData, + e: imp::PhantomData<&'a [u8]>, + f: imp::PhantomData<&'static str>, + g: imp::PhantomData, } -assert_impl_all!(TypeParams<'static, (), IntoIter<()>>: FromBytes); +util_assert_impl_all!(TypeParams<'static, (), imp::IntoIter<()>>: imp::FromBytes); -// Deriving `FromBytes` should work if the union has bounded parameters. +// Deriving `imp::FromBytes` should work if the union has bounded parameters. -#[derive(FromZeros, FromBytes)] +#[derive(imp::FromZeros, imp::FromBytes)] #[repr(C)] -union WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + FromBytes, const N: usize> +union WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::FromBytes, const N: usize> where 'a: 'b, 'b: 'a, - T: 'a + 'b + Copy + FromBytes, + T: 'a + 'b + imp::Copy + imp::FromBytes, { a: [T; N], - b: PhantomData<&'a &'b ()>, + b: imp::PhantomData<&'a &'b ()>, } -assert_impl_all!(WithParams<'static, 'static, u8, 42>: FromBytes); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::FromBytes); diff --git a/zerocopy-derive/tests/union_from_zeros.rs b/zerocopy-derive/tests/union_from_zeros.rs index 6f5eb8eae3..12234d5ccf 100644 --- a/zerocopy-derive/tests/union_from_zeros.rs +++ b/zerocopy-derive/tests/union_from_zeros.rs @@ -6,67 +6,64 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -#[macro_use] -mod util; +include!("include.rs"); -use std::{marker::PhantomData, option::IntoIter}; +// A union is `imp::FromZeros` if: +// - all fields are `imp::FromZeros` -use {static_assertions::assert_impl_all, zerocopy::FromZeros}; - -// A union is `FromZeros` if: -// - all fields are `FromZeros` - -#[derive(Clone, Copy, FromZeros)] +#[derive(Clone, Copy, imp::FromZeros)] union Zst { a: (), } -assert_impl_all!(Zst: FromZeros); +util_assert_impl_all!(Zst: imp::FromZeros); -#[derive(FromZeros)] +#[derive(imp::FromZeros)] union One { a: bool, } -assert_impl_all!(One: FromZeros); +util_assert_impl_all!(One: imp::FromZeros); -#[derive(FromZeros)] +#[derive(imp::FromZeros)] union Two { a: bool, b: Zst, } -assert_impl_all!(Two: FromZeros); +util_assert_impl_all!(Two: imp::FromZeros); -#[derive(FromZeros)] -union TypeParams<'a, T: Copy, I: Iterator> +#[derive(imp::FromZeros)] +union TypeParams<'a, T: imp::Copy, I: imp::Iterator> where - I::Item: Copy, + I::Item: imp::Copy, { a: T, c: I::Item, d: u8, - e: PhantomData<&'a [u8]>, - f: PhantomData<&'static str>, - g: PhantomData, + e: imp::PhantomData<&'a [u8]>, + f: imp::PhantomData<&'static str>, + g: imp::PhantomData, } -assert_impl_all!(TypeParams<'static, (), IntoIter<()>>: FromZeros); +util_assert_impl_all!(TypeParams<'static, (), imp::IntoIter<()>>: imp::FromZeros); -// Deriving `FromZeros` should work if the union has bounded parameters. +// Deriving `imp::FromZeros` should work if the union has bounded parameters. -#[derive(FromZeros)] +#[derive(imp::FromZeros)] #[repr(C)] -union WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + FromZeros, const N: usize> +union WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::FromZeros, const N: usize> where 'a: 'b, 'b: 'a, - T: 'a + 'b + Copy + FromZeros, + T: 'a + 'b + imp::Copy + imp::FromZeros, { a: [T; N], - b: PhantomData<&'a &'b ()>, + b: imp::PhantomData<&'a &'b ()>, } -assert_impl_all!(WithParams<'static, 'static, u8, 42>: FromZeros); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::FromZeros); diff --git a/zerocopy-derive/tests/union_known_layout.rs b/zerocopy-derive/tests/union_known_layout.rs index bd43ba10db..c309869d18 100644 --- a/zerocopy-derive/tests/union_known_layout.rs +++ b/zerocopy-derive/tests/union_known_layout.rs @@ -2,64 +2,61 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -#[macro_use] -mod util; +include!("include.rs"); -use std::{marker::PhantomData, option::IntoIter}; - -use {static_assertions::assert_impl_all, zerocopy::KnownLayout}; - -#[derive(Clone, Copy, KnownLayout)] +#[derive(Clone, Copy, imp::KnownLayout)] union Zst { a: (), } -assert_impl_all!(Zst: KnownLayout); +util_assert_impl_all!(Zst: imp::KnownLayout); -#[derive(KnownLayout)] +#[derive(imp::KnownLayout)] union One { a: bool, } -assert_impl_all!(One: KnownLayout); +util_assert_impl_all!(One: imp::KnownLayout); -#[derive(KnownLayout)] +#[derive(imp::KnownLayout)] union Two { a: bool, b: Zst, } -assert_impl_all!(Two: KnownLayout); +util_assert_impl_all!(Two: imp::KnownLayout); -#[derive(KnownLayout)] -union TypeParams<'a, T: Copy, I: Iterator> +#[derive(imp::KnownLayout)] +union TypeParams<'a, T: imp::Copy, I: imp::Iterator> where - I::Item: Copy, + I::Item: imp::Copy, { a: T, c: I::Item, d: u8, - e: PhantomData<&'a [u8]>, - f: PhantomData<&'static str>, - g: PhantomData, + e: imp::PhantomData<&'a [u8]>, + f: imp::PhantomData<&'static str>, + g: imp::PhantomData, } -assert_impl_all!(TypeParams<'static, (), IntoIter<()>>: KnownLayout); +util_assert_impl_all!(TypeParams<'static, (), imp::IntoIter<()>>: imp::KnownLayout); -// Deriving `KnownLayout` should work if the union has bounded parameters. +// Deriving `imp::KnownLayout` should work if the union has bounded parameters. -#[derive(KnownLayout)] +#[derive(imp::KnownLayout)] #[repr(C)] -union WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + KnownLayout, const N: usize> +union WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::KnownLayout, const N: usize> where 'a: 'b, 'b: 'a, - T: 'a + 'b + Copy + KnownLayout, + T: 'a + 'b + imp::Copy + imp::KnownLayout, { a: [T; N], - b: PhantomData<&'a &'b ()>, + b: imp::PhantomData<&'a &'b ()>, } -assert_impl_all!(WithParams<'static, 'static, u8, 42>: KnownLayout); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::KnownLayout); diff --git a/zerocopy-derive/tests/union_no_cell.rs b/zerocopy-derive/tests/union_no_cell.rs index c46a99c72b..657dfdfc64 100644 --- a/zerocopy-derive/tests/union_no_cell.rs +++ b/zerocopy-derive/tests/union_no_cell.rs @@ -2,66 +2,63 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -#[macro_use] -mod util; +include!("include.rs"); -use std::{cell::UnsafeCell, marker::PhantomData, option::IntoIter}; - -use {static_assertions::assert_impl_all, zerocopy::NoCell}; - -#[derive(Clone, Copy, NoCell)] +#[derive(Clone, Copy, imp::NoCell)] union Zst { a: (), } -assert_impl_all!(Zst: NoCell); +util_assert_impl_all!(Zst: imp::NoCell); -#[derive(NoCell)] +#[derive(imp::NoCell)] union One { a: bool, } -assert_impl_all!(One: NoCell); +util_assert_impl_all!(One: imp::NoCell); -#[derive(NoCell)] +#[derive(imp::NoCell)] union Two { a: bool, b: Zst, } -assert_impl_all!(Two: NoCell); +util_assert_impl_all!(Two: imp::NoCell); -#[derive(NoCell)] -union TypeParams<'a, T: Copy, I: Iterator> +#[derive(imp::NoCell)] +union TypeParams<'a, T: imp::Copy, I: imp::Iterator> where - I::Item: Copy, + I::Item: imp::Copy, { a: T, c: I::Item, d: u8, - e: PhantomData<&'a [u8]>, - f: PhantomData<&'static str>, - g: PhantomData, + e: imp::PhantomData<&'a [::core::primitive::u8]>, + f: imp::PhantomData<&'static ::core::primitive::str>, + g: imp::PhantomData, } -assert_impl_all!(TypeParams<'static, (), IntoIter<()>>: NoCell); +util_assert_impl_all!(TypeParams<'static, (), imp::IntoIter<()>>: imp::NoCell); -// Deriving `NoCell` should work if the union has bounded parameters. +// Deriving `imp::NoCell` should work if the union has bounded parameters. -#[derive(NoCell)] +#[derive(imp::NoCell)] #[repr(C)] -union WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + NoCell, const N: usize> +union WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::NoCell, const N: usize> where 'a: 'b, 'b: 'a, - T: 'a + 'b + Copy + NoCell, + T: 'a + 'b + imp::Copy + imp::NoCell, { a: [T; N], - b: PhantomData<&'a &'b ()>, - c: PhantomData>, - d: &'a UnsafeCell<()>, + b: imp::PhantomData<&'a &'b ()>, + c: imp::PhantomData>, + d: &'a imp::UnsafeCell<()>, } -assert_impl_all!(WithParams<'static, 'static, u8, 42>: NoCell); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::NoCell); diff --git a/zerocopy-derive/tests/union_to_bytes.rs b/zerocopy-derive/tests/union_to_bytes.rs index 189329a751..e1acba355d 100644 --- a/zerocopy-derive/tests/union_to_bytes.rs +++ b/zerocopy-derive/tests/union_to_bytes.rs @@ -6,39 +6,39 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -use std::{marker::PhantomData, option::IntoIter}; +include!("include.rs"); -use {static_assertions::assert_impl_all, zerocopy::IntoBytes}; - -// A union is `IntoBytes` if: -// - all fields are `IntoBytes` +// A union is `imp::IntoBytes` if: +// - all fields are `imp::IntoBytes` // - `repr(C)` or `repr(transparent)` and // - no padding (size of union equals size of each field type) // - `repr(packed)` -#[derive(IntoBytes, Clone, Copy)] +#[derive(imp::IntoBytes, Clone, Copy)] #[repr(C)] union CZst { a: (), } -assert_impl_all!(CZst: IntoBytes); +util_assert_impl_all!(CZst: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(C)] union C { a: u8, b: u8, } -assert_impl_all!(C: IntoBytes); +util_assert_impl_all!(C: imp::IntoBytes); // Transparent unions are unstable; see issue #60405 // for more information. -// #[derive(IntoBytes)] +// #[derive(imp::IntoBytes)] // #[repr(transparent)] // union Transparent { // a: u8, @@ -47,24 +47,24 @@ assert_impl_all!(C: IntoBytes); // is_as_bytes!(Transparent); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(C, packed)] union CZstPacked { a: (), } -assert_impl_all!(CZstPacked: IntoBytes); +util_assert_impl_all!(CZstPacked: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(C, packed)] union CPacked { a: u8, b: i8, } -assert_impl_all!(CPacked: IntoBytes); +util_assert_impl_all!(CPacked: imp::IntoBytes); -#[derive(IntoBytes)] +#[derive(imp::IntoBytes)] #[repr(C, packed)] union CMultibytePacked { a: i32, @@ -72,4 +72,4 @@ union CMultibytePacked { c: f32, } -assert_impl_all!(CMultibytePacked: IntoBytes); +util_assert_impl_all!(CMultibytePacked: imp::IntoBytes); diff --git a/zerocopy-derive/tests/union_try_from_bytes.rs b/zerocopy-derive/tests/union_try_from_bytes.rs index 669a6a74e1..dbfdc4069c 100644 --- a/zerocopy-derive/tests/union_try_from_bytes.rs +++ b/zerocopy-derive/tests/union_try_from_bytes.rs @@ -6,65 +6,58 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -mod util; +include!("include.rs"); -use std::{marker::PhantomData, option::IntoIter}; +// A struct is `imp::TryFromBytes` if: +// - any of its fields are `imp::TryFromBytes` -use { - static_assertions::assert_impl_all, - zerocopy::{FromBytes, FromZeros, KnownLayout, TryFromBytes}, -}; - -use crate::util::AU16; - -// A struct is `TryFromBytes` if: -// - any of its fields are `TryFromBytes` - -#[derive(TryFromBytes, FromZeros, FromBytes)] +#[derive(imp::TryFromBytes, imp::FromZeros, imp::FromBytes)] union One { a: u8, } -assert_impl_all!(One: TryFromBytes); +util_assert_impl_all!(One: imp::TryFromBytes); #[test] fn one() { // TODO(#5): Use `try_transmute` in this test once it's available. - let candidate = zerocopy::Ptr::from_ref(&One { a: 42 }); + let candidate = ::zerocopy::Ptr::from_ref(&One { a: 42 }); let candidate = candidate.forget_aligned().forget_valid(); - let is_bit_valid = One::is_bit_valid(candidate); + let is_bit_valid = ::is_bit_valid(candidate); assert!(is_bit_valid); } -#[derive(TryFromBytes, FromZeros)] +#[derive(imp::TryFromBytes, imp::FromZeros)] #[repr(C)] union Two { a: bool, b: bool, } -assert_impl_all!(Two: TryFromBytes); +util_assert_impl_all!(Two: imp::TryFromBytes); #[test] fn two() { // TODO(#5): Use `try_transmute` in this test once it's available. - let candidate_a = zerocopy::Ptr::from_ref(&Two { a: false }); + let candidate_a = ::zerocopy::Ptr::from_ref(&Two { a: false }); let candidate_a = candidate_a.forget_aligned().forget_valid(); - let is_bit_valid = Two::is_bit_valid(candidate_a); + let is_bit_valid = ::is_bit_valid(candidate_a); assert!(is_bit_valid); - let candidate_b = zerocopy::Ptr::from_ref(&Two { b: true }); + let candidate_b = ::zerocopy::Ptr::from_ref(&Two { b: true }); let candidate_b = candidate_b.forget_aligned().forget_valid(); - let is_bit_valid = Two::is_bit_valid(candidate_b); + let is_bit_valid = ::is_bit_valid(candidate_b); assert!(is_bit_valid); } #[test] fn two_bad() { // TODO(#5): Use `try_transmute` in this test once it's available. - let candidate = zerocopy::Ptr::from_ref(&[2u8][..]); + let candidate = ::zerocopy::Ptr::from_ref(&[2u8][..]); let candidate = candidate.forget_aligned().forget_valid(); // SAFETY: @@ -77,11 +70,11 @@ fn two_bad() { // SAFETY: `candidate`'s referent is as-initialized as `Two`. let candidate = unsafe { candidate.assume_initialized() }; - let is_bit_valid = Two::is_bit_valid(candidate); + let is_bit_valid = ::is_bit_valid(candidate); assert!(!is_bit_valid); } -#[derive(TryFromBytes, FromZeros)] +#[derive(imp::TryFromBytes, imp::FromZeros)] #[repr(C)] union BoolAndZst { a: bool, @@ -91,7 +84,7 @@ union BoolAndZst { #[test] fn bool_and_zst() { // TODO(#5): Use `try_transmute` in this test once it's available. - let candidate = zerocopy::Ptr::from_ref(&[2u8][..]); + let candidate = ::zerocopy::Ptr::from_ref(&[2u8][..]); let candidate = candidate.forget_aligned().forget_valid(); // SAFETY: @@ -104,40 +97,40 @@ fn bool_and_zst() { // SAFETY: `candidate`'s referent is fully initialized. let candidate = unsafe { candidate.assume_initialized() }; - let is_bit_valid = BoolAndZst::is_bit_valid(candidate); + let is_bit_valid = ::is_bit_valid(candidate); assert!(is_bit_valid); } -#[derive(TryFromBytes, FromZeros, FromBytes)] +#[derive(imp::TryFromBytes, imp::FromZeros, imp::FromBytes)] #[repr(C)] -union TypeParams<'a, T: Copy, I: Iterator> +union TypeParams<'a, T: imp::Copy, I: imp::Iterator> where - I::Item: Copy, + I::Item: imp::Copy, { a: I::Item, b: u8, - c: PhantomData<&'a [u8]>, - d: PhantomData<&'static str>, - e: PhantomData, + c: imp::PhantomData<&'a [u8]>, + d: imp::PhantomData<&'static str>, + e: imp::PhantomData, f: T, } -assert_impl_all!(TypeParams<'static, (), IntoIter<()>>: TryFromBytes); -assert_impl_all!(TypeParams<'static, AU16, IntoIter<()>>: TryFromBytes); -assert_impl_all!(TypeParams<'static, [AU16; 2], IntoIter<()>>: TryFromBytes); +util_assert_impl_all!(TypeParams<'static, (), imp::IntoIter<()>>: imp::TryFromBytes); +util_assert_impl_all!(TypeParams<'static, util::AU16, imp::IntoIter<()>>: imp::TryFromBytes); +util_assert_impl_all!(TypeParams<'static, [util::AU16; 2], imp::IntoIter<()>>: imp::TryFromBytes); -// Deriving `TryFromBytes` should work if the union has bounded parameters. +// Deriving `imp::TryFromBytes` should work if the union has bounded parameters. -#[derive(TryFromBytes, FromZeros, FromBytes)] +#[derive(imp::TryFromBytes, imp::FromZeros, imp::FromBytes)] #[repr(C)] -union WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + TryFromBytes, const N: usize> +union WithParams<'a: 'b, 'b: 'a, T: 'a + 'b + imp::TryFromBytes, const N: usize> where 'a: 'b, 'b: 'a, - T: 'a + 'b + TryFromBytes + Copy, + T: 'a + 'b + imp::TryFromBytes + imp::Copy, { - a: PhantomData<&'a &'b ()>, + a: imp::PhantomData<&'a &'b ()>, b: T, } -assert_impl_all!(WithParams<'static, 'static, u8, 42>: TryFromBytes); +util_assert_impl_all!(WithParams<'static, 'static, u8, 42>: imp::TryFromBytes); diff --git a/zerocopy-derive/tests/union_unaligned.rs b/zerocopy-derive/tests/union_unaligned.rs index 5ba3ac76ac..49aaa9a076 100644 --- a/zerocopy-derive/tests/union_unaligned.rs +++ b/zerocopy-derive/tests/union_unaligned.rs @@ -6,11 +6,11 @@ // This file may not be copied, modified, or distributed except according to // those terms. +// See comment in `include.rs` for why we disable the prelude. +#![no_implicit_prelude] #![allow(warnings)] -use std::{marker::PhantomData, option::IntoIter}; - -use {static_assertions::assert_impl_all, zerocopy::Unaligned}; +include!("include.rs"); // A union is `Unaligned` if: // - `repr(align)` is no more than 1 and either @@ -18,13 +18,13 @@ use {static_assertions::assert_impl_all, zerocopy::Unaligned}; // - all fields `Unaligned` // - `repr(packed)` -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(C)] union Foo { - a: u8, + a: imp::u8, } -assert_impl_all!(Foo: Unaligned); +util_assert_impl_all!(Foo: imp::Unaligned); // Transparent unions are unstable; see issue #60405 // for more information. @@ -37,7 +37,7 @@ assert_impl_all!(Foo: Unaligned); // is_unaligned!(Bar); -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(packed)] union Baz { // NOTE: The `u16` type is not guaranteed to have alignment 2, although it @@ -50,28 +50,28 @@ union Baz { a: u16, } -assert_impl_all!(Baz: Unaligned); +util_assert_impl_all!(Baz: imp::Unaligned); -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(C, align(1))] union FooAlign { - a: u8, + a: imp::u8, } -assert_impl_all!(FooAlign: Unaligned); +util_assert_impl_all!(FooAlign: imp::Unaligned); -#[derive(Unaligned)] +#[derive(imp::Unaligned)] #[repr(C)] -union TypeParams<'a, T: Copy, I: Iterator> +union TypeParams<'a, T: imp::Copy, I: imp::Iterator> where - I::Item: Copy, + I::Item: imp::Copy, { a: T, c: I::Item, d: u8, - e: PhantomData<&'a [u8]>, - f: PhantomData<&'static str>, - g: PhantomData, + e: imp::PhantomData<&'a [imp::u8]>, + f: imp::PhantomData<&'static imp::str>, + g: imp::PhantomData, } -assert_impl_all!(TypeParams<'static, (), IntoIter<()>>: Unaligned); +util_assert_impl_all!(TypeParams<'static, (), imp::IntoIter<()>>: imp::Unaligned); diff --git a/zerocopy-derive/tests/util.rs b/zerocopy-derive/tests/util.rs deleted file mode 100644 index ec8d0b9a39..0000000000 --- a/zerocopy-derive/tests/util.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2019 The Fuchsia Authors -// -// Licensed under a BSD-style license , Apache License, Version 2.0 -// , or the MIT -// license , at your option. -// This file may not be copied, modified, or distributed except according to -// those terms. - -use zerocopy::{FromBytes, FromZeros, IntoBytes, KnownLayout, NoCell, TryFromBytes}; - -/// A type that doesn't implement any zerocopy traits. -pub struct NotZerocopy(T); - -/// A `u16` with alignment 2. -/// -/// Though `u16` has alignment 2 on some platforms, it's not guaranteed. By -/// contrast, `AU16` is guaranteed to have alignment 2. -#[derive(KnownLayout, NoCell, TryFromBytes, FromZeros, FromBytes, IntoBytes, Copy, Clone)] -#[repr(C, align(2))] -pub struct AU16(u16);