Skip to content

Compiler rejects cast in match arm #11791

Closed
@bnoordhuis

Description

@bnoordhuis

At commit a5ab960. I would expect the following to work:

fn main() {
    match -1 as u32 {
        -1 as u32 => None,
        val => Some(val),
    };
}

But the compiler rejects it with the following error:

$ rustc t.rs
t.rs:3:12: 3:14 error: expected `=>` but found `as`
t.rs:3         -1 as u32  => None,

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