Skip to content

mismatched types: expected fn&() -> ! but found fn&() -> _|_ #3681

Closed
@ben0x539

Description

@ben0x539

This fails:

fn foo(f: fn() -> !) {}

fn main() {
    foo(|| {fail });
}

with

foo.rs:4:7: 4:18 error: mismatched types: expected `fn&() -> !` but found `fn&() -> _|_` (expected non-returning function, found non-returning function)
foo.rs:4     foo(|| {fail });
                ^~~~~~~~~~~

While this works:

fn foo(f: fn() -> !) {}

fn main() {
    foo(fn() -> ! { fail });
}

I don't know what is going on there but I feel the first snippet should work too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions