Skip to content

ICE when returning from block in const #38458

Closed
@a2aaron

Description

@a2aaron

A friend was teaching me Rust and showing me the distinction between return and the value of an expression, and when I tried to put a return in a top level const, we got a panic.

Here's a minimal reproducing case.

const x: () = {
    return;
};

fn main() {}

Playground

Fails with:

rustc 1.13.0 (2c6933acc 2016-11-07)
error: internal compiler error: unexpected panic

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

thread 'rustc' panicked at 'assertion failed: match self.hir.tcx().region_maps.code_extent_data(self.scopes[1].extent) {
    CodeExtentData::ParameterScope { .. } => true,
    _ => false,
}', ../src/librustc_mir/build/scope.rs:435
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Metadata

Metadata

Assignees

No one assigned

    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