Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] Fix UI tests with missing imports #706

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 15 additions & 6 deletions tests/ui-msrv/transmute-mut-src-generic.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
error[E0405]: cannot find trait `FromBytes` in this scope
--> tests/ui-msrv/transmute-mut-src-generic.rs:15:31
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> tests/ui-msrv/transmute-mut-src-generic.rs:17:5
|
15 | fn transmute_mut<T: AsBytes + FromBytes + NoCell>(t: &mut T) -> &mut u8 {
| ^^^^^^^^^ not found in this scope
17 | transmute_mut!(t)
| ^^^^^^^^^^^^^^^^^
|
help: consider importing this trait
= note: source type: `T` (this type does not have a fixed size)
= note: target type: `u8` (8 bits)
= note: this error originates in the macro `$crate::assert_size_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> tests/ui-msrv/transmute-mut-src-generic.rs:17:5
|
11 | use zerocopy::FromBytes;
17 | transmute_mut!(t)
| ^^^^^^^^^^^^^^^^^
|
= note: source type: `AlignOf<T>` (size can vary because of T)
= note: target type: `MaxAlignsOf<T, u8>` (size can vary because of T)
= note: this error originates in the macro `$crate::assert_align_gt_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
2 changes: 1 addition & 1 deletion tests/ui-nightly/transmute-mut-src-generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

extern crate zerocopy;

use zerocopy::{transmute_mut, AsBytes, NoCell};
use zerocopy::{transmute_mut, AsBytes, FromBytes, NoCell};

fn main() {}

Expand Down
21 changes: 15 additions & 6 deletions tests/ui-nightly/transmute-mut-src-generic.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
error[E0405]: cannot find trait `FromBytes` in this scope
--> tests/ui-nightly/transmute-mut-src-generic.rs:15:31
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> tests/ui-nightly/transmute-mut-src-generic.rs:17:5
|
15 | fn transmute_mut<T: AsBytes + FromBytes + NoCell>(t: &mut T) -> &mut u8 {
| ^^^^^^^^^ not found in this scope
17 | transmute_mut!(t)
| ^^^^^^^^^^^^^^^^^
|
help: consider importing this trait
= note: source type: `T` (this type does not have a fixed size)
= note: target type: `u8` (8 bits)
= note: this error originates in the macro `$crate::assert_size_eq` which comes from the expansion of the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> tests/ui-nightly/transmute-mut-src-generic.rs:17:5
|
11 + use zerocopy::FromBytes;
17 | transmute_mut!(t)
| ^^^^^^^^^^^^^^^^^
|
= note: source type: `AlignOf<T>` (size can vary because of T)
= note: target type: `MaxAlignsOf<T, u8>` (size can vary because of T)
= note: this error originates in the macro `$crate::assert_align_gt_eq` which comes from the expansion of the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
21 changes: 15 additions & 6 deletions tests/ui-stable/transmute-mut-src-generic.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
error[E0405]: cannot find trait `FromBytes` in this scope
--> tests/ui-stable/transmute-mut-src-generic.rs:15:31
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> tests/ui-stable/transmute-mut-src-generic.rs:17:5
|
15 | fn transmute_mut<T: AsBytes + FromBytes + NoCell>(t: &mut T) -> &mut u8 {
| ^^^^^^^^^ not found in this scope
17 | transmute_mut!(t)
| ^^^^^^^^^^^^^^^^^
|
help: consider importing this trait
= note: source type: `T` (this type does not have a fixed size)
= note: target type: `u8` (8 bits)
= note: this error originates in the macro `$crate::assert_size_eq` which comes from the expansion of the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> tests/ui-stable/transmute-mut-src-generic.rs:17:5
|
11 + use zerocopy::FromBytes;
17 | transmute_mut!(t)
| ^^^^^^^^^^^^^^^^^
|
= note: source type: `AlignOf<T>` (size can vary because of T)
= note: target type: `MaxAlignsOf<T, u8>` (size can vary because of T)
= note: this error originates in the macro `$crate::assert_align_gt_eq` which comes from the expansion of the macro `transmute_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
113 changes: 57 additions & 56 deletions zerocopy-derive/tests/ui-msrv/derive_transparent.stderr
Original file line number Diff line number Diff line change
@@ -1,88 +1,89 @@
<<<<<<< HEAD
error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> tests/ui-msrv/derive_transparent.rs:37:1
|
37 | assert_impl_all!(TransparentStruct<NotZerocopy>: FromZeros);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy`
37 | assert_impl_all!(TransparentStruct<NotZerocopy>: TryFromBytes);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy`
|
note: required because of the requirements on the impl of `FromZeroes` for `TransparentStruct<NotZerocopy>`
note: required because of the requirements on the impl of `TryFromBytes` for `TransparentStruct<NotZerocopy>`
--> tests/ui-msrv/derive_transparent.rs:27:19
|
27 | #[derive(AsBytes, FromZeros, FromBytes, Unaligned)]
| ^^^^^^^^^
27 | #[derive(AsBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)]
| ^^^^^^^^^^^^
note: required by a bound in `_::{closure#0}::assert_impl_all`
--> tests/ui-msrv/derive_transparent.rs:37:1
|
37 | assert_impl_all!(TransparentStruct<NotZerocopy>: FromZeros);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all`
37 | assert_impl_all!(TransparentStruct<NotZerocopy>: 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)

error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied
error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied
--> tests/ui-msrv/derive_transparent.rs:38:1
=======
error: cannot find derive macro `TryFromBytes` in this scope
--> tests/ui-msrv/derive_transparent.rs:27:19
|
27 | #[derive(AsBytes, TryFromBytes, FromZeroes, FromBytes, Unaligned)]
| ^^^^^^^^^^^^ help: a derive macro with a similar name exists: `FromBytes`
>>>>>>> [derive] Support `derive(TryFromBytes)` for structs
|
::: src/lib.rs
38 | assert_impl_all!(TransparentStruct<NotZerocopy>: FromZeros);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy`
|
<<<<<<< HEAD
note: required because of the requirements on the impl of `FromBytes` for `TransparentStruct<NotZerocopy>`
--> tests/ui-msrv/derive_transparent.rs:27:30
note: required because of the requirements on the impl of `FromZeroes` for `TransparentStruct<NotZerocopy>`
--> tests/ui-msrv/derive_transparent.rs:27:33
|
27 | #[derive(AsBytes, FromZeros, FromBytes, Unaligned)]
| ^^^^^^^^^
27 | #[derive(AsBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)]
| ^^^^^^^^^
note: required by a bound in `_::{closure#0}::assert_impl_all`
--> tests/ui-msrv/derive_transparent.rs:38:1
|
38 | assert_impl_all!(TransparentStruct<NotZerocopy>: FromBytes);
38 | assert_impl_all!(TransparentStruct<NotZerocopy>: 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)
=======
| pub fn derive_from_bytes(ts: proc_macro::TokenStream) -> proc_macro::TokenStream {
| -------------------------------------------------------------------------------- similarly named derive macro `FromBytes` defined here
|
= note: consider importing one of these items:
zerocopy::TryFromBytes
zerocopy_derive::TryFromBytes
>>>>>>> [derive] Support `derive(TryFromBytes)` for structs

error[E0405]: cannot find trait `TryFromBytes` in this scope
--> tests/ui-msrv/derive_transparent.rs:37:50
error[E0277]: the trait bound `NotZerocopy: FromBytes` is not satisfied
--> tests/ui-msrv/derive_transparent.rs:39:1
|
37 | assert_impl_all!(TransparentStruct<NotZerocopy>: TryFromBytes);
| ^^^^^^^^^^^^
39 | assert_impl_all!(TransparentStruct<NotZerocopy>: FromBytes);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FromBytes` is not implemented for `NotZerocopy`
|
<<<<<<< HEAD
27 | #[derive(AsBytes, FromZeros, FromBytes, Unaligned)]
| ^^^^^^^
note: required because of the requirements on the impl of `FromBytes` for `TransparentStruct<NotZerocopy>`
--> tests/ui-msrv/derive_transparent.rs:27:44
|
27 | #[derive(AsBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)]
| ^^^^^^^^^
note: required by a bound in `_::{closure#0}::assert_impl_all`
--> tests/ui-msrv/derive_transparent.rs:39:1
=======
::: $WORKSPACE/src/lib.rs
>>>>>>> [derive] Support `derive(TryFromBytes)` for structs
|
| pub unsafe trait FromBytes: FromZeroes {
| -------------------------------------- similarly named trait `FromBytes` defined here
39 | assert_impl_all!(TransparentStruct<NotZerocopy>: 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)

error[E0277]: the trait bound `NotZerocopy: AsBytes` is not satisfied
--> tests/ui-msrv/derive_transparent.rs:40:1
|
help: a trait with a similar name exists
40 | assert_impl_all!(TransparentStruct<NotZerocopy>: AsBytes);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `AsBytes` is not implemented for `NotZerocopy`
|
<<<<<<< HEAD
note: required because of the requirements on the impl of `Unaligned` for `TransparentStruct<NotZerocopy>`
--> tests/ui-msrv/derive_transparent.rs:27:41
note: required because of the requirements on the impl of `AsBytes` for `TransparentStruct<NotZerocopy>`
--> tests/ui-msrv/derive_transparent.rs:27:10
|
27 | #[derive(AsBytes, FromZeros, FromBytes, Unaligned)]
| ^^^^^^^^^
27 | #[derive(AsBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)]
| ^^^^^^^
note: required by a bound in `_::{closure#0}::assert_impl_all`
--> tests/ui-msrv/derive_transparent.rs:40:1
=======
37 | assert_impl_all!(TransparentStruct<NotZerocopy>: FromBytes);
| ~~~~~~~~~
help: consider importing this trait
|
14 | use zerocopy::TryFromBytes;
>>>>>>> [derive] Support `derive(TryFromBytes)` for structs
40 | assert_impl_all!(TransparentStruct<NotZerocopy>: AsBytes);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `_::{closure#0}::assert_impl_all`
= note: this error originates in the macro `assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `NotZerocopy: Unaligned` is not satisfied
--> tests/ui-msrv/derive_transparent.rs:41:1
|
41 | assert_impl_all!(TransparentStruct<NotZerocopy>: Unaligned);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Unaligned` is not implemented for `NotZerocopy`
|
note: required because of the requirements on the impl of `Unaligned` for `TransparentStruct<NotZerocopy>`
--> tests/ui-msrv/derive_transparent.rs:27:55
|
27 | #[derive(AsBytes, TryFromBytes, FromZeros, FromBytes, Unaligned)]
| ^^^^^^^^^
note: required by a bound in `_::{closure#0}::assert_impl_all`
--> tests/ui-msrv/derive_transparent.rs:41:1
|
41 | assert_impl_all!(TransparentStruct<NotZerocopy>: 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)
37 changes: 9 additions & 28 deletions zerocopy-derive/tests/ui-msrv/enum.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -67,54 +67,39 @@ error: TryFromBytes not supported on enum types
| |_^

error: must have a non-align #[repr(...)] attribute in order to guarantee this type's memory layout
<<<<<<< HEAD
--> tests/ui-msrv/enum.rs:42:21
--> tests/ui-msrv/enum.rs:42:35
|
42 | #[derive(FromZeros, FromBytes)]
| ^^^^^^^^^
|
= note: this error originates in the derive macro `FromBytes` (in Nightly builds, run with -Z macro-backtrace for more info)

error: only C-like enums can implement FromZeros
=======
--> tests/ui-msrv/enum.rs:42:36
|
42 | #[derive(TryFromBytes, FromZeroes, FromBytes)]
| ^^^^^^^^^
42 | #[derive(TryFromBytes, FromZeros, FromBytes)]
| ^^^^^^^^^
|
= note: this error originates in the derive macro `FromBytes` (in Nightly builds, run with -Z macro-backtrace for more info)

error: TryFromBytes not supported on enum types
--> tests/ui-msrv/enum.rs:70:1
|
70 | / enum FromZeroes1 {
70 | / enum FromZeros1 {
71 | | A(u8),
72 | | }
| |_^

error: only C-like enums can implement FromZeroes
>>>>>>> [derive] Support `derive(TryFromBytes)` for structs
error: only C-like enums can implement FromZeros
--> tests/ui-msrv/enum.rs:70:1
|
70 | / enum FromZeros1 {
71 | | A(u8),
72 | | }
| |_^

<<<<<<< HEAD
error: only C-like enums can implement FromZeros
=======
Comment on lines -104 to -106
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh. The fact that this slipped through suggests that these tests aren't actually getting validated...

error: TryFromBytes not supported on enum types
--> tests/ui-msrv/enum.rs:75:1
|
75 | / enum FromZeroes2 {
75 | / enum FromZeros2 {
76 | | A,
77 | | B(u8),
78 | | }
| |_^

error: only C-like enums can implement FromZeroes
>>>>>>> [derive] Support `derive(TryFromBytes)` for structs
error: only C-like enums can implement FromZeros
--> tests/ui-msrv/enum.rs:75:1
|
75 | / enum FromZeros2 {
Expand All @@ -123,20 +108,16 @@ error: only C-like enums can implement FromZeroes
78 | | }
| |_^

<<<<<<< HEAD
error: FromZeros only supported on enums with a variant that has a discriminant of `0`
=======
error: TryFromBytes not supported on enum types
--> tests/ui-msrv/enum.rs:81:1
|
81 | / enum FromZeroes3 {
81 | / enum FromZeros3 {
82 | | A = 1,
83 | | B,
84 | | }
| |_^

error: FromZeroes only supported on enums with a variant that has a discriminant of `0`
>>>>>>> [derive] Support `derive(TryFromBytes)` for structs
error: FromZeros only supported on enums with a variant that has a discriminant of `0`
--> tests/ui-msrv/enum.rs:81:1
|
81 | / enum FromZeros3 {
Expand Down
9 changes: 2 additions & 7 deletions zerocopy-derive/tests/ui-msrv/late_compile_pass.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ warning: unused import: `zerocopy::KnownLayout`
error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
--> tests/ui-msrv/late_compile_pass.rs:28:10
|
<<<<<<< HEAD
28 | #[derive(FromZeros)]
| ^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy`
=======
28 | #[derive(TryFromBytes)]
| ^^^^^^^^^^^^ the trait `TryFromBytes` is not implemented for `NotZerocopy`
|
Expand All @@ -22,9 +18,8 @@ error[E0277]: the trait bound `NotZerocopy: TryFromBytes` is not satisfied
error[E0277]: the trait bound `NotZerocopy: FromZeroes` is not satisfied
--> tests/ui-msrv/late_compile_pass.rs:37:10
|
37 | #[derive(FromZeroes)]
| ^^^^^^^^^^ the trait `FromZeroes` is not implemented for `NotZerocopy`
>>>>>>> [derive] Support `derive(TryFromBytes)` for structs
37 | #[derive(FromZeros)]
| ^^^^^^^^^ 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)
Expand Down
2 changes: 1 addition & 1 deletion zerocopy-derive/tests/ui-nightly/derive_transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use core::marker::PhantomData;

use {
static_assertions::assert_impl_all,
zerocopy::{AsBytes, FromBytes, FromZeros, Unaligned},
zerocopy::{AsBytes, FromBytes, FromZeros, TryFromBytes, Unaligned},
};

use self::util::NotZerocopy;
Expand Down