Skip to content

Guaranteed early breaks out of try blocks can't infer never type #160931

Description

@CenTdemeern1

I tried this code:

#![feature(try_blocks)]

fn bug_repro() {
    None = try {
        return; // The semicolon is important!
    };
}
#![feature(try_blocks)]

fn bug_repro() {
    None = try {
        None?;
        return;
    };
}

I expected to see this happen: The code compiles. This pattern is irrefutable

Instead, this happened: The pattern is marked as refutable and this code doesn't compile

Meta

rustc --version --verbose:

rustc 1.99.0-nightly (12c36e253 2026-08-10)
binary: rustc
commit-hash: 12c36e2539c54397c51d6ea4401defd8768a4f5b
commit-date: 2026-08-10
host: aarch64-apple-darwin
release: 1.99.0-nightly
LLVM version: 23.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions