Skip to content

linkage errors with explicit named lifetimes parameters to a function #5243

Closed
@ben0x539

Description

@ben0x539

I don't really understand what's going on here. Offending code:

struct S<'self> {
    v: &int
}

fn f<'lt>(_s: &S<'lt>) {}

fn main() {
    f(& S { v: &42 });
}

Compiler output:

$ rustc bar.rs
Global is external, but doesn't have external or dllimport or weak linkage!
void ({}*, { i64, %tydesc*, i8*, i8*, i8 } addrspace(1)*, %"~struct S[#0]"*)* @_ZN1f17_12d56ae62635eef43_00E
invalid linkage type for function declaration
void ({}*, { i64, %tydesc*, i8*, i8*, i8 } addrspace(1)*, %"~struct S[#0]"*)* @_ZN1f17_12d56ae62635eef43_00E
Broken module found, compilation aborted!
Stack dump:
0.  Running pass 'Function Pass Manager' on module 'bar.rc'.
Aborted

Compiles if f is declared as fn f(...) rather than fn f<'lt>(). I'm not sure how explicit I'm supposed to be with lifetime parameters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions