Skip to content

match should fail when there's no matching branch #14325

Closed
@ghost

Description

This program incorrectly prints "second branch" even though the match expression should fail.

extern crate core;
use core::mem;

enum Value {
    Val1,
    Val2
}

fn main() {
    let mut value = Val2;
    unsafe { *mem::transmute::<&mut Value, &mut int>(&mut value) += 10; }

    match value {
        Val1 => println!("first branch"),
        Val2 => println!("second branch")
    }
}

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