Skip to content

Missing "unreachable" warning for flow control in function argument #30289

@diwic

Description

@diwic

Consider this code:

fn foo(a: Option<i32>) -> i32 {
    a.unwrap_or({return 0 }) + 5
}   

In this case 0 is always returned (regardless of the value of a), which is probably not what the user intended. Because unwrap_or is never called, this should trigger an "unreachable code" or "dead code" warning, but it does not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions