Skip to content

Incorrect non-exhaustive matching for fixed length arrays #8311

Description

@stepancheg
fn foo(p: [u8, ..4]) {
    match p {
        [a, b, c, d] => {},
    };
}

Compiler reports non-exhaustive matching:

/.../tmp3.rs:2:4: 4:5 error: non-exhaustive patterns: vectors of length 0 not covered
/.../tmp3.rs:2     match p {
/.../tmp3.rs:3         [a, b, c, d] => {},
/.../tmp3.rs:4     };
error: aborting due to previous error

It is not possible p to have size 0.

Fixed length vectors should also be allowed in let statements:

let [a, b, c] = [1, 2, 3]; // currently reports error: refutable pattern in local binding

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions