Skip to content

ICE involving catch_expr and never_type #43335

Closed
@crumblingstatue

Description

@crumblingstatue
#![feature(catch_expr, never_type)]

struct Error {
    cause: &'static str,
}

fn oops() -> Result<(), Error> {
    Err(Error { cause: "epic fail" } )
}

fn main() {
    let Err(Error { cause }): Result<!, Error> = do catch {
        oops()?;
        return; // OK
    };
    eprintln!("Nuclear meltdown initiated: {}", cause);
}
error: internal compiler error: broken MIR (_1 = ()): bad assignment (! = ()): Sorts(ExpectedFound { expected: !, found: () })
  --> src/main.rs:11:11
   |
11 |   fn main() {
   |  ___________^
12 | |     let Err(Error { cause }): Result<!, Error> = do catch {
13 | |         oops()?;
14 | |         return; // OK
15 | |     };
16 | |     eprintln!("Nuclear meltdown initiated: {}", cause);
17 | | }
   | |_^

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-try_blocks`#![feature(try_blocks)]`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