Skip to content

Beta miscompiles match when a pattern has a range including signed minimum #58067

Closed
@tspiteri

Description

@tspiteri
fn main() {
    let x = match 1i8 {
        -0x80..=-1 => -99,
        0..=10 => 0,
        _ => 99,
    };
    println!("{}", x);
}

This prints -99 instead of 0.

Changing the first pattern to -0x80 | -0x7f..=-1 => -99, will work around the issue.

Changing it to -0x80..=-0x7f | -0x7e..=-1 reintroduces the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-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