Skip to content

Can't derive a fixed-size arrays. #13981

Closed
@KokaKiwi

Description

@KokaKiwi

When compiling this:

#[deriving(Eq)]
struct Toto {
    data: [u8, ..20],
}

fn main() {
}

rustc output an error:

$ rustc main.rs
main.rs:4:5: 4:21 error: mismatched types: expected `&&[u8]` but found `&[u8, .. 20]` (expected &-ptr but found vector)
main.rs:4     data: [u8, ..20],
              ^~~~~~~~~~~~~~~~
note: in expansion of #[deriving]
main.rs:2:1: 3:7 note: expansion site
main.rs:4:5: 4:21 error: mismatched types: expected `&&[u8]` but found `&[u8, .. 20]` (expected &-ptr but found vector)
main.rs:4     data: [u8, ..20],
              ^~~~~~~~~~~~~~~~
note: in expansion of #[deriving]
main.rs:2:1: 3:7 note: expansion site
error: aborting due to 2 previous errors

It seems to me that there is no reason to not allow this, so I reported it.

My rustc version:

$ rustc --version
rustc 0.11-pre-nightly (abdacec 2014-05-04 23:16:40 -0700)
host: x86_64-unknown-linux-gnu

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions