Skip to content

inflexibility with diverging functions #10352

Closed
@thestinger

Description

@thestinger

The following code compiles, since the return type is inferred to be Option<()>:

fn main() {
    Some(5).map(|_| ());
}

However, this will not compile because rustc cannot infer a type:

fn main() {
    Some(5).map(|_| fail!());
}

If we used something like Void instead of !, the return type would obviously be Option<Void> here. However, since ! isn't allowed anywhere but a function signature this is a pain.

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