Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM Error: broken function found #71659

Closed
RustyYato opened this issue Apr 29, 2020 · 1 comment · Fixed by #77956
Closed

LLVM Error: broken function found #71659

RustyYato opened this issue Apr 29, 2020 · 1 comment · Fixed by #77956
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RustyYato
Copy link
Contributor

Code

playground

#![feature(unsize)]

use core::marker::Unsize;

pub trait CastTo<T: ?Sized>: Unsize<T> {
    fn cast_to(&self) -> &T;
}

impl<T: ?Sized, U: ?Sized + Unsize<T>> CastTo<T> for U {
    fn cast_to(&self) -> &T {
        self
    }
}

impl<T: ?Sized> Cast for T {}
pub trait Cast {
    fn cast<T: ?Sized>(&self) -> &T
    where
        Self: CastTo<T>,
    {
        self
    }
}

pub trait Foo: CastTo<[i32]> {}
impl Foo for [i32; 0] {}

fn main() {
    let x: &dyn Foo = &[];
    let x = x.cast::<[i32]>();
}

Meta

rustc --version --verbose:

rustc 1.44.0-nightly (7f3df5772 2020-04-16)
binary: rustc
commit-hash: 7f3df5772439eee1c512ed2eb540beef1124d236
commit-date: 2020-04-16
host: x86_64-pc-windows-msvc
release: 1.44.0-nightly
LLVM version: 9.0

Error output

   Compiling trait-cast v0.1.0 (E:\Programming\Rust\trait-cast)
warning: unused variable: `x`
  --> src\main.rs:30:9
   |
30 |     let x = x.cast::<[i32]>();
   |         ^ help: if this is intentional, prefix it with an underscore: `_x`
   |
   = note: `#[warn(unused_variables)]` on by default

Invalid InsertValueInst operands!
  %8 = insertvalue { [0 x i32]*, i64 } %7, [3 x i64]* %1, 1, !dbg !59
in function _ZN10trait_cast4Cast4cast17hfff2a44740d96fd4E
LLVM ERROR: Broken function found, compilation aborted!
error: could not compile `trait-cast`.

To learn more, run the command again with --verbose.

Backtrace

N/a there was no backtrace

@RustyYato RustyYato added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 29, 2020
@wesleywiser wesleywiser added the requires-nightly This issue requires a nightly compiler in some way. label Apr 29, 2020
@RustyYato RustyYato changed the title LLVM Error: broken function founda LLVM Error: broken function found Apr 29, 2020
@JohnTitor JohnTitor added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label May 6, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label May 6, 2020
@JohnTitor
Copy link
Member

Triage: This is no longer ICE with the latest nightly, marking as E-needs-test.

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 7, 2020
@bors bors closed this as completed in cbc42a0 Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants