-
Notifications
You must be signed in to change notification settings - Fork 108
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
[derive] Improve IntoBytes error messages #1712
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ proc-macro = true | |
[dependencies] | ||
proc-macro2 = "1.0.1" | ||
quote = "1.0.10" | ||
syn = "2.0.46" | ||
syn = { version = "2.0.46", features = ["full"] } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @djkoloski Do you have a sense of how we could implement using the same trick that you pulled to avoid the I tested locally on a MacBook Pro on low battery mode, and found that the |
||
|
||
[dev-dependencies] | ||
dissimilar = "1.0.9" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -413,41 +413,53 @@ help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | |
9 + #![feature(trivial_bounds)] | ||
| | ||
|
||
error[E0277]: the trait bound `HasPadding<IntoBytes1, true>: ShouldBe<false>` is not satisfied | ||
error[E0277]: `IntoBytes1` has inter-field padding | ||
--> tests/ui-nightly/enum.rs:533:10 | ||
| | ||
533 | #[derive(IntoBytes)] | ||
| ^^^^^^^^^ the trait `ShouldBe<false>` is not implemented for `HasPadding<IntoBytes1, true>` | ||
| ^^^^^^^^^ types with padding cannot implement `IntoBytes` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is ridiculously good. I wonder if we could even say how many bytes of inter-field padding there with const generics, but that's just yak shaving. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Filed #1717 to track |
||
| | ||
= help: the trait `ShouldBe<true>` is implemented for `HasPadding<IntoBytes1, true>` | ||
= help: the trait `PaddingFree<IntoBytes1, true>` is not implemented for `()` | ||
= note: consider using `zerocopy::Unalign` to lower the alignment of individual fields | ||
= note: consider adding explicit fields where padding would be | ||
= note: consider using `#[repr(packed)]` to remove inter-field padding | ||
= help: the trait `PaddingFree<IntoBytes1, false>` is implemented for `()` | ||
= help: see issue #48214 | ||
= note: this error originates in the derive macro `IntoBytes` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | ||
| | ||
9 + #![feature(trivial_bounds)] | ||
| | ||
|
||
error[E0277]: the trait bound `HasPadding<IntoBytes2, true>: ShouldBe<false>` is not satisfied | ||
error[E0277]: `IntoBytes2` has inter-field padding | ||
--> tests/ui-nightly/enum.rs:544:10 | ||
| | ||
544 | #[derive(IntoBytes)] | ||
| ^^^^^^^^^ the trait `ShouldBe<false>` is not implemented for `HasPadding<IntoBytes2, true>` | ||
| ^^^^^^^^^ types with padding cannot implement `IntoBytes` | ||
| | ||
= help: the trait `ShouldBe<true>` is implemented for `HasPadding<IntoBytes2, true>` | ||
= help: the trait `PaddingFree<IntoBytes2, true>` is not implemented for `()` | ||
= note: consider using `zerocopy::Unalign` to lower the alignment of individual fields | ||
= note: consider adding explicit fields where padding would be | ||
= note: consider using `#[repr(packed)]` to remove inter-field padding | ||
= help: the trait `PaddingFree<IntoBytes2, false>` is implemented for `()` | ||
= help: see issue #48214 | ||
= note: this error originates in the derive macro `IntoBytes` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | ||
| | ||
9 + #![feature(trivial_bounds)] | ||
| | ||
|
||
error[E0277]: the trait bound `HasPadding<IntoBytes3, true>: ShouldBe<false>` is not satisfied | ||
error[E0277]: `IntoBytes3` has inter-field padding | ||
--> tests/ui-nightly/enum.rs:550:10 | ||
| | ||
550 | #[derive(IntoBytes)] | ||
| ^^^^^^^^^ the trait `ShouldBe<false>` is not implemented for `HasPadding<IntoBytes3, true>` | ||
| ^^^^^^^^^ types with padding cannot implement `IntoBytes` | ||
| | ||
= help: the trait `ShouldBe<true>` is implemented for `HasPadding<IntoBytes3, true>` | ||
= help: the trait `PaddingFree<IntoBytes3, true>` is not implemented for `()` | ||
= note: consider using `zerocopy::Unalign` to lower the alignment of individual fields | ||
= note: consider adding explicit fields where padding would be | ||
= note: consider using `#[repr(packed)]` to remove inter-field padding | ||
= help: the trait `PaddingFree<IntoBytes3, false>` is implemented for `()` | ||
= help: see issue #48214 | ||
= note: this error originates in the derive macro `IntoBytes` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
help: add `#![feature(trivial_bounds)]` to the crate attributes to enable | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fallback is arguably an improvement over the previous error!