Skip to content

LLVM error with trait objects #47638

Closed
Closed
@matthewjasper

Description

@matthewjasper

The following code

fn id<'c, 'b>(f: &'c &'b Fn(&i32)) -> &'c &'b Fn(&'static i32) {
    f
}

fn main() {
    let f: &Fn(&i32) = &|x| {};
    id(&f);
}

gives the following error on beta (1.24) and nightly (1.25 2018-01-17). It compiles successfully on stable.

Function return type does not match operand type of return inst!
  ret { %"core::ops::function::Fn<(&i32), Output=()>.0"*, {}* }* %3, !dbg !36
 { %"core::ops::function::Fn<(&i32), Output=()>"*, {}* }*LLVM ERROR: Broken function found, compilation aborted!

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions