Skip to content

[ICE]: llvm error: ResumeInst needs to be in a function with a personality #159980

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -Zmir-opt-level=0 -Zverify-llvm-ir=yes -Clink-dead-code=true
use std::ops::Deref;
trait Foo {
    fn method(&self) {}
}
impl Foo for u32 {}

fn via_deref_nested() -> Box<impl Deref<Target = impl Foo>> {
    if false {
        via_deref_nested().method();
    }

    Box::new(Box::new(1u32))
}

fn main() {}

original:

//! The recursive method call yields the opaque type. We want
//! to use the trait candidate for `impl Foo` here while not
//! applying it for the `impl Deref`.

//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@ check-pass

use std::ops::Deref;
trait Foo {
    fn method(&self) {}
}
impl Foo for u32 {}
fn via_deref() -> impl Deref<Target = impl Foo> {
    if false {
        if false {
        via_deref_nested().method();
    }
    }

    Box::new(1u32)
}

fn via_deref_nested() -> Box<impl Deref<Target = impl Foo>> {
    if false {
        via_deref_nested().method();
    }

    Box::new(Box::new(1u32))
}

fn main() {}

Version information

rustc 1.99.0-nightly (5d4886964 2026-07-26)
binary: rustc
commit-hash: 5d4886964b04e1aa6aca158a677183a778e2950d
commit-date: 2026-07-26
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=0 -Zverify-llvm-ir=yes -Clink-dead-code=true

Program output

warning: trait `Foo` is never used
 --> /tmp/icemaker_global_tempdir.rPGSLcie4PU1/rustc_testrunner_tmpdir_reporting.qXYPqbNhVFid/mvce.rs:2:7
  |
2 | trait Foo {
  |       ^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: function `via_deref_nested` is never used
 --> /tmp/icemaker_global_tempdir.rPGSLcie4PU1/rustc_testrunner_tmpdir_reporting.qXYPqbNhVFid/mvce.rs:7:4
  |
7 | fn via_deref_nested() -> Box<impl Deref<Target = impl Foo>> {
  |    ^^^^^^^^^^^^^^^^

ResumeInst needs to be in a function with a personality.
  resume { ptr, i32 } %12
rustc-LLVM ERROR: Broken module found, compilation aborted!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-llvm-errorImpact: An error from LLVM is directly exposed by valid codeT-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