Skip to content

[MIR] broken MIR (bad assignment) for non-returning closure #32959

Closed

Description

This code:

fn main() {
    let o: Option<u32> = None;

    let foo = || -> ! {
        loop {}
    };

    o.unwrap_or_else(|| {
        foo();
    });
}

Will yield this warning:

main.rs:8:25: 10:6 warning: broken MIR (return = ()): bad assignment (u32 = ()): Sorts(ExpectedFound { expected: u32, found: () })
main.rs: 8     o.unwrap_or_else(|| {
main.rs: 9         foo();
main.rs:10     });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlT-langRelevant to the language team, which will review and decide on the PR/issue.Relevant to the language 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