Skip to content

unreachable warning when an unreachable!() macro is called #79157

Open
@gilescope

Description

@gilescope

I think we should suppress warnings that unreachable!() macros are unreachable. I had some nested logic with early returns and while at the moment it could not get to the end of the function, I could predict that some changes to the logic might miss a branch and then it would get to the end of the function - I wanted to catch that future mistake with an unreaachable!() macro. If we don't warn about unreachable unreachable!'s then I think that will make rust a safer language to code in as we can code more defensively.

warning: unreachable statement
    --> src/<snip>.rs:1298:5
     |
1190 |                         return None;
     |                         ----------- any code following this expression is unreachable
...
1298 |     unreachable!("Case missed. Should have early returned above.");
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-control-flowArea: Control flowA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions