Skip to content

Document when the return type of a block expression implicitly becomes ! #1033

Open
@smarnach

Description

@smarnach

The reference currently states

The type of a block is the type of the final expression, or () if the final expression is omitted.

However, the type of this block appears to be !:

{
    loop {}
    5;
}

whereas the type of this block is i32

{
    loop {}
    5
}

So it looks like the presence of an expression of type ! changes the default type of the block from () to !.

As a side note, the doucmentation could also make clearer that "omitting the final expression" essentially means terminating the block with a semicolon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugIncorrect statements, terminology, or rendering issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions