Skip to content

Unclear error message about missing lifetime when wrapping closure references #22760

Closed
@knz

Description

@knz

The following code:

struct A; struct B; 
let id : &Fn(B)->B = &|x|{x}; 
let di : &Fn(A)->&Fn(B)->B = &|discard:A|{id};

produces the following error message, which is utterly non-informative about how to fix the problem:

<anon>:14:76: 14:85 error: missing lifetime specifier [E0106]
<anon>:14         struct A; struct B; let id : &Fn(B)->B = &|x|{x}; let di : &Fn(A)->&Fn(B)->B = &|discard:A|{id};
                                                                                     ^~~~~~~~~
<anon>:14:76: 14:85 help: this function's return type contains a borrowed value, but the signature does not say which one of argument 1's 0 elided lifetimes it is borrowed from
<anon>:14         struct A; struct B; let id : &Fn(B)->B = &|x|{x}; let di : &Fn(A)->&Fn(B)->B = &|discard:A|{id};
                                                                                     ^~~~~~~~~

In particular "which one of argument 1's 0 elided lifetimes it is borrowed from" is particularly confusing.

Version: rustc 1.0.0-dev (2b01a37ec 2015-02-21) (built 2015-02-21)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lifetimesArea: Lifetimes / regions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions