Skip to content

CastKind::ClosureFnPointer implemented wrong #413

Closed
@bjorn3

Description

@bjorn3
test compile
set is_pic
target x86_64-apple-darwin

function u0:0() system_v {
; symbol _ZN22closure_to_fn_coercion4main17hcc5f764723193903E
; instance Instance { def: Item(DefId(0/0:3 ~ closure_to_fn_coercion[317d]::main[0])), substs: [] }
; sig ([]; c_variadic: false)->()

; ssa {_4: (empty), _0: NOT_SSA, _2: NOT_SSA, _3: NOT_SSA, _1: (empty)}
; msg   loc.idx    param    pass mode            ssa flags  ty
; ret    _0      -          NoPass               NOT_SSA    ()
; zst    _2: [closure@rust/src/test/run-pass/functions-closures/closure-to-fn-coercion.rs:4:29: 4:42] size=0 align=1, 8

    ss0 = explicit_slot 1 ; _3: u8 size=1 align=1,1
    sig0 = (i64, i8) -> i8 system_v
    sig1 = (i8) -> i8 system_v
    fn0 = colocated u0:9 sig0 ; Instance { def: ClosureOnceShim { call_once: DefId(2/0:1000 ~ core[5e67]::ops[0]::function[0]::FnOnce[0]::call_once[0]) }, substs: [[closure@rust/src/test/run-pass/functions-closures/closure-to-fn-coercion.rs:4:29: 4:42], (u8,)] }

                                ebb0:
                                    v0 = iconst.i64 45
                                    v1 = stack_addr.i64 ss0
                                    jump ebb1

                                ebb1:
                                    nop 
; _1 = move _2 as fn(u8) -> u8 (ClosureFnPointer)
@0001                               v2 = func_addr.i64 fn0
; _4 = _1
; 
; _3 = move _4(const 31u8)
@0004                               v3 = iconst.i8 31
@0004                               v4 = call_indirect sig1, v2(v3)
@0004                               store v4, v1
@0004                               jump ebb2

                                ebb2:
@0004                               nop 
; 
; return
@0007                               return
}

The signature of fn0 doesn't match the expected signature. Somehow fn0 has a signature with a self param, while it shouldn't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions