Skip to content

Regression in match patterns in beta #57894

Closed
@Razican

Description

@Razican

Hello, the pattern matching in match arms seems to have different behavior in stable than in beta/nightly.

I tried this code:

use std::i8;

fn main() {
    let a = Some(-50_i8);
    match a {
        Some(c @ i8::MIN...-101) | Some(c @ 101...i8::MAX) => println!("out of bounds, {}", c),
        _ => println!("OK"),
    }
}

I expected to see this happen: In all chains, it should print "OK".

Instead, this happened: It prints "OK" in stable, but it prints "out of bounds, -50" in beta/nightly.

Example in the playground

I understand that this code is not very idiomatic, but still, I think that the behavior should be consistent between Rust versions.

Metadata

Metadata

Assignees

Labels

P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions