Skip to content

MIR validation ICE: Use of local which has no storage #118990

Closed
@saethlin

Description

@saethlin
struct CompileError;

impl Drop for CompileError {
    fn drop(&mut self) {}
}

impl CompileError {
    fn throw(&self) {}
}

fn main() {
    'code: {
        break 'code;
        CompileError.throw()
    };
}

Build with

-Zvalidate-mir
error: internal compiler error: broken MIR in Item(DefId(0:9 ~ ice[5cf9]::main)) (before pass CheckPackedRef) at bb4[0]:
                                use of local _3, which has no storage here
  --> src/main.rs:15:6
   |
15 |     };
   |      ^

// MIR for `main` after built

fn main() -> () {
    let mut _0: ();
    let _1: ();
    let mut _2: &CompileError;
    let _3: CompileError;

    bb0: {
        StorageLive(_1);
        _1 = const ();
        goto -> bb3;
    }

    bb1: {
        StorageLive(_2);
        StorageLive(_3);
        _3 = CompileError;
        _2 = &_3;
        _1 = CompileError::throw(move _2) -> [return: bb2, unwind: bb6];
    }

    bb2: {
        StorageDead(_2);
        goto -> bb4;
    }

    bb3: {
        goto -> bb4;
    }

    bb4: {
        drop(_3) -> [return: bb5, unwind: bb7];
    }

    bb5: {
        StorageDead(_3);
        StorageDead(_1);
        _0 = const ();
        return;
    }

    bb6 (cleanup): {
        drop(_3) -> [return: bb7, unwind terminate(cleanup)];
    }

    bb7 (cleanup): {
        resume;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    -Zvalidate-mirUnstable option: MIR validationA-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️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