Skip to content

&[T, ..N] casts to *T instead of *[T, ..N] in structs #14893

Closed
@mahkoh

Description

@mahkoh

Consider the following code:

struct X {
    y: [u8, ..2],
}

fn main() {
    let x1 = X { y: [0, 0] };

    let p1: *u8 = &x1.y as *_;
    let t1: *[u8, ..2] = &x1.y as *_;
    let h1: *[u8, ..2] = &x1.y as *[u8, ..2];
}

The second cast is an error. The other casts work.

Consider the following code:

fn main() {
    let mut x1 = X { y: [0, 0] };

    let p1: *mut u8 = &mut x1.y as *mut _;
    let t1: *mut [u8, ..2] = &mut x1.y as *mut _;
    let h1: *mut [u8, ..2] = &mut x1.y as *mut [u8, ..2];
}

The first cast is an error. The other casts work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions