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

Boxes can not be cast to dyn* #102427

Closed
Tracked by #102425
eholk opened this issue Sep 28, 2022 · 1 comment · Fixed by #102641
Closed
Tracked by #102425

Boxes can not be cast to dyn* #102427

eholk opened this issue Sep 28, 2022 · 1 comment · Fixed by #102641
Assignees
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. F-dyn_star `#![feature(dyn_star)]` requires-nightly This issue requires a nightly compiler in some way.

Comments

@eholk
Copy link
Contributor

eholk commented Sep 28, 2022

Example:

#![feature(dyn_star)]
#![allow(incomplete_features)]

use std::fmt::Display;

fn make_dyn_star() -> dyn* Display {
    Box::new(42) as dyn* Display
}

fn main() {
    let x = make_dyn_star();

    println!("{x}");
}

This fails in LLVM:

Invalid InsertValueInst operands!
  %15 = insertvalue { i64, ptr } undef, ptr %2, 0
in function _ZN7scratch13make_dyn_star17h90da983991b1d3f6E
LLVM ERROR: Broken function found, compilation aborted!
@eholk eholk added the F-dyn_star `#![feature(dyn_star)]` label Sep 28, 2022
@eholk eholk changed the title Boxes can not be coerced to dyn* Boxes can not be casted to dyn* Sep 28, 2022
@eholk eholk changed the title Boxes can not be casted to dyn* Boxes can not be cast to dyn* Sep 28, 2022
@Rageking8
Copy link
Contributor

@rustbot label +C-bug +A-LLVM +requires-nightly

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. labels Sep 29, 2022
@eholk eholk self-assigned this Oct 4, 2022
JohnTitor added a commit to JohnTitor/rust that referenced this issue Oct 12, 2022
Support casting boxes to dyn*

Boxes have a pointer type at codegen time which LLVM does not allow to be transparently converted to an integer. Work around this by inserting a `ptrtoint` instruction if the argument is a pointer.

r? `@compiler-errors`

Fixes rust-lang#102427
@bors bors closed this as completed in 6755c2a Oct 13, 2022
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. F-dyn_star `#![feature(dyn_star)]` requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants