Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match matches in strange dependence of surrounding patterns #16975

Closed
nwin opened this issue Sep 3, 2014 · 3 comments
Closed

Match matches in strange dependence of surrounding patterns #16975

nwin opened this issue Sep 3, 2014 · 3 comments

Comments

@nwin
Copy link
Contributor

nwin commented Sep 3, 2014

The following code

fn main() {
    let a = vec![16u8];
    match (a.as_slice(), "a") {
        ([8], "a")
        |([8, _], "a") => {},
        ([16], "a")
        |([16, _], "a") => { println!("matched") },
        // (_, _) => fail!(), // Fails if this line is used
        _ => fail!() // prints matched if this line is used

    }
}

fails, if the comment is swapped between the two last lines.

But (_, _) only matches when I use |([8, _], "a") in the first pattern and if I use a [16] instead of [8] as a value for a. I don't think this behaves as intended.

@alexcrichton
Copy link
Member

cc @jakub-

@ghost
Copy link

ghost commented Sep 4, 2014

This is a dupe of #16648 and fixed in #16883.

@alexcrichton
Copy link
Member

Thanks @jakub-!

bors added a commit to rust-lang-ci/rust that referenced this issue Mar 31, 2024
Prompt the user to reload the window when enabling test explorer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants