Skip to content

Missing unreachable code/arm warning, when a match guard is diverging #134734

Open
@WaffleLapkin

Description

@WaffleLapkin

I tried this code:

fn main() {
    match () {
        _ if loop {} => (),
        _ => (),
    }
    println!("nya :3");
}

(playground)

I expected to see this happen: compiler to emit a warning that the first arm and later code is unreachable (since loop{} never terminates and has type !).

Instead, this happened: the code compiles without warnings.

Meta

rustc version: 1.84.0-beta.4 (2024-12-07 202008a1b8de96d2e5b6)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.L-unreachable_codeLint: unreachable_codeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions