Skip to content

internal compiler error (rust 1.0.0-beta) with early return #24353

Closed
@alserio

Description

@alserio

The following code produces an ICE on playpen with rust 1.0.0-beta or nightly:

fn main() -> () {
    let _ = f();
}

fn f() -> usize {
    if true {
        return 1;      
    }                   
    let x = 0;
    x
}  
error: internal compiler error: trans_local_var: no datum for local/arg 26 found
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/beta-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:190

playpen: application terminated with error code 101

The code compiles when the if condition is false (or not immediately true), when the last line uses an explicit return or when the value is returned without let expression.

Metadata

Metadata

Assignees

Labels

I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions