Skip to content

Commit

Permalink
[derive] Disable prelude when testing; fix bugs
Browse files Browse the repository at this point in the history
This has the effect of ensuring that derive-emitted code will fail to
compile if it spuriously relies on certain identifiers being in scope -
namely, identifiers which are part of the prelude.

Disabling the prelude surfaced a few bugs which are also fixed in this
commit.

Makes progress on #11
  • Loading branch information
joshlf authored and jswrenn committed Feb 16, 2024
1 parent d39a5d4 commit 61dcf2e
Show file tree
Hide file tree
Showing 92 changed files with 1,216 additions and 1,169 deletions.
4 changes: 2 additions & 2 deletions src/macro_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>())*
};
}

Expand All @@ -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>())*
};
}

Expand Down
12 changes: 6 additions & 6 deletions tests/ui-msrv/include_value_not_from_bytes.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error[E0277]: the trait bound `NotZerocopy<u32>: FromBytes` is not satisfied
--> tests/ui-msrv/include_value_not_from_bytes.rs:13:42
error[E0277]: the trait bound `NotZerocopy<u32>: zerocopy::FromBytes` is not satisfied
--> tests/ui-msrv/include_value_not_from_bytes.rs:15:42
|
13 | const NOT_FROM_BYTES: NotZerocopy<u32> = include_value!("../../testdata/include_value/data");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy<u32>`
15 | const NOT_FROM_BYTES: NotZerocopy<u32> = include_value!("../../testdata/include_value/data");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::FromBytes` is not implemented for `NotZerocopy<u32>`
|
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<u32> = include_value!("../../testdata/include_value/data");
15 | const NOT_FROM_BYTES: NotZerocopy<u32> = 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)
12 changes: 6 additions & 6 deletions tests/ui-msrv/transmute-dst-not-frombytes.stderr
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 8 additions & 8 deletions tests/ui-msrv/transmute-mut-alignment-increase.stderr
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
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)
= note: target type: `MaxAlignsOf<[u8; 2], AU16>` (16 bits)
= 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 <https://github.com/rust-lang/rust/issues/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
Expand Down
4 changes: 2 additions & 2 deletions tests/ui-msrv/transmute-mut-dst-not-intobytes.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0277]: the trait bound `Dst: IntoBytes` is not satisfied
error[E0277]: the trait bound `Dst: AsBytes` is not satisfied
--> tests/ui-msrv/transmute-mut-dst-not-intobytes.rs:24:36
|
24 | const DST_NOT_AS_BYTES: &mut Dst = transmute_mut!(&mut Src);
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `Dst`
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `Dst`
|
note: required by `AssertDstIsIntoBytes`
--> tests/ui-msrv/transmute-mut-dst-not-intobytes.rs:24:36
Expand Down
8 changes: 4 additions & 4 deletions tests/ui-msrv/transmute-mut-src-not-intobytes.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0277]: the trait bound `Src: IntoBytes` is not satisfied
error[E0277]: the trait bound `Src: AsBytes` is not satisfied
--> tests/ui-msrv/transmute-mut-src-not-intobytes.rs:24:36
|
24 | const SRC_NOT_AS_BYTES: &mut Dst = transmute_mut!(&mut Src);
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `Src`
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `Src`
|
note: required by `AssertSrcIsIntoBytes`
--> tests/ui-msrv/transmute-mut-src-not-intobytes.rs:24:36
Expand All @@ -11,11 +11,11 @@ note: required by `AssertSrcIsIntoBytes`
| ^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `Src: IntoBytes` is not satisfied
error[E0277]: the trait bound `Src: AsBytes` is not satisfied
--> tests/ui-msrv/transmute-mut-src-not-intobytes.rs:24:36
|
24 | const SRC_NOT_AS_BYTES: &mut Dst = transmute_mut!(&mut Src);
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `Src`
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `Src`
|
note: required by a bound in `AssertSrcIsIntoBytes`
--> tests/ui-msrv/transmute-mut-src-not-intobytes.rs:24:36
Expand Down
8 changes: 4 additions & 4 deletions tests/ui-msrv/transmute-ptr-to-usize.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error[E0277]: the trait bound `*const usize: AsBytes` is not satisfied
error[E0277]: the trait bound `*const usize: IntoBytes` is not satisfied
--> tests/ui-msrv/transmute-ptr-to-usize.rs:20:30
|
20 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `*const usize`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `*const usize`
|
note: required by `AssertIsIntoBytes`
--> tests/ui-msrv/transmute-ptr-to-usize.rs:20:30
Expand All @@ -11,11 +11,11 @@ note: required by `AssertIsIntoBytes`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `transmute` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `*const usize: AsBytes` is not satisfied
error[E0277]: the trait bound `*const usize: IntoBytes` is not satisfied
--> tests/ui-msrv/transmute-ptr-to-usize.rs:20:30
|
20 | const POINTER_VALUE: usize = transmute!(&0usize as *const usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `*const usize`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoBytes` is not implemented for `*const usize`
|
note: required by a bound in `AssertIsIntoBytes`
--> tests/ui-msrv/transmute-ptr-to-usize.rs:20:30
Expand Down
4 changes: 2 additions & 2 deletions tests/ui-msrv/transmute-ref-alignment-increase.stderr
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
12 changes: 6 additions & 6 deletions tests/ui-msrv/transmute-ref-dst-not-frombytes.stderr
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 6 additions & 6 deletions tests/ui-msrv/transmute-ref-dst-not-nocell.stderr
Original file line number Diff line number Diff line change
@@ -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)
24 changes: 12 additions & 12 deletions tests/ui-msrv/transmute-ref-src-not-intobytes.stderr
Original file line number Diff line number Diff line change
@@ -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)
24 changes: 12 additions & 12 deletions tests/ui-msrv/transmute-ref-src-not-nocell.stderr
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions tests/ui-msrv/transmute-size-decrease.stderr
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/ui-msrv/transmute-size-increase.stderr
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
16 changes: 8 additions & 8 deletions tests/ui-msrv/transmute-src-not-intobytes.stderr
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
error[E0277]: the trait bound `NotZerocopy<AU16>: 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<AU16>`
|
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<AU16>: 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<AU16>`
|
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)
4 changes: 3 additions & 1 deletion tests/ui-nightly/include_value_not_from_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>: !FromBytes`.
Expand Down
Loading

0 comments on commit 61dcf2e

Please sign in to comment.