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

non-Copy array elements error message #63

Open
pickx opened this issue Jul 23, 2023 · 1 comment
Open

non-Copy array elements error message #63

pickx opened this issue Jul 23, 2023 · 1 comment

Comments

@pickx
Copy link
Collaborator

pickx commented Jul 23, 2023

#[bitsize(1)]
#[derive(FromBits)]
enum A {
    C,
    D,
}

#[bitsize(2)]
#[derive(FromBits)]
struct Foo {
    a: [A; 2],
}
error[E0508]: cannot move out of type `[A; 2]`, a non-copy array
  --> src/main.rs:10:1
   |
10 | #[bitsize(2)]
   | ^^^^^^^^^^^^^
   | |
   | cannot move out of here
   | move occurs because `value[_]` has type `A`, which does not implement the `Copy` trait
   |
   = note: this error originates in the attribute macro `bilge::bitsize_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider borrowing here
   |
10 | &#[bitsize(2)]
   | +

removing all attributes from Foo makes this error go away. also "consider borrowing here" is pretty hilarious.

other than the message, not sure if this is an actual issue (adding #[derive(Copy, Clone)] fixes this)

@hecatia-elegua
Copy link
Owner

It's probably possible to check for Copy on the array element. I've noted we only support copyable elements somewhere, we might not need to bother.

@hecatia-elegua hecatia-elegua changed the title "cannot move out of type" when struct's field is an array non-Copy array elements error message Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants