Skip to content

Unreachable code warning even when no code follows #89779

Closed
@tamird

Description

@tamird

#85556 introduced an unreachable code warning after uninhabited expressions; unfortunately that warning fires even when no code follows the expression.

This makes it impossible to use patterns such as:

fn foo() -> Result<std::convert::Infallible, u64> {
    Err(5)
}

fn main() { 
    match foo().expect("should") {}
}

where the match is being used in the manner suggested by @nikomatsakis in a blog post.

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