Skip to content

Cannot store a closure using <'a> || lifetime syntax or inside generic types #11211

Closed
@huonw

Description

@huonw
struct Foo<'a> {
    x: <'a> ||
}
fn main() {}
store-closure.rs:2:7: 2:14 error: missing lifetime specifier
store-closure.rs:2     x: <'a> ||
                          ^~~~~~~

This & #11209 means that it is impossible to store closures inside another generic type e.g. an Option< closure >:

struct Foo<'a> {
    x: Option< <'a> ||>
}
fn main() {}
store-closure.rs:2:15: 2:22 error: missing lifetime specifier
store-closure.rs:2     x: Option< <'a> ||>
                                  ^~~~~~~
struct Foo<'a> {
    x: Option< 'a ||>
}
fn main() {}
store-closure.rs:2:18: 2:20 error: expected `,` or `>` after lifetime name, got: OROR
store-closure.rs:2     x: Option< 'a ||>
                                     ^~

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