bytemuck icon indicating copy to clipboard operation
bytemuck copied to clipboard

Make `AnyBitPattern` derive work for generic structs

Open cky opened this issue 2 years ago • 6 comments

(Note: despite the similar titles, this PR is not related to #83 at all. This PR is specific to the changes introduced in #91.)

When using AnyBitPattern derive, an automatic derive for Zeroable is created as well. However, the latter derive is missing generic parameters for the struct, which means you get errors like the following:

error[E0107]: missing generics for struct `AnyBitPatternTest`
   --> tests/basic.rs:107:8
    |
107 | struct AnyBitPatternTest<A: AnyBitPattern, B: AnyBitPattern> {
    |        ^^^^^^^^^^^^^^^^^ expected 2 generic arguments
    |
note: struct defined here, with 2 generic parameters: `A`, `B`
   --> tests/basic.rs:107:8
    |
107 | struct AnyBitPatternTest<A: AnyBitPattern, B: AnyBitPattern> {
    |        ^^^^^^^^^^^^^^^^^ -                 -
help: add missing generic arguments
    |
107 | struct AnyBitPatternTest<A, B><A: AnyBitPattern, B: AnyBitPattern> {
    |        ~~~~~~~~~~~~~~~~~~~~~~~

The help text is worse than useless, because the suggested fix makes things worse.

cky avatar Apr 21 '22 02:04 cky

@fu5ha you get to review this one!

Lokathor avatar Apr 21 '22 05:04 Lokathor

Not sure why this is failing on nightly tho

fu5ha avatar Apr 21 '22 06:04 fu5ha

Wonder if it's using the old macro expansion? Certainly the error message suggests so. Didn't you run into similar CI bogosity in #91?

cky avatar Apr 21 '22 06:04 cky

Just so I know I haven't gone nuts, here's the nightly and miri runs on my computer: https://gist.github.com/cky/f80cc8b82632bd10deaebcb1a5668172

cky avatar Apr 21 '22 06:04 cky

Is there a way to rerun the CI? I could technically push an empty commit just to trigger one but if there's a way to actually just rerun, I'd rather not junk up the branch with empty commits. ;-)

cky avatar Apr 22 '22 20:04 cky

I'll try a close and re-open.

Lokathor avatar Apr 22 '22 20:04 Lokathor

@cky sorry I haven't looked at this one in ages. It seems by now there's a small conflict in a test file. Do you want to fix that up and then I think we can merge this?

Lokathor avatar Mar 21 '23 15:03 Lokathor