Function rustc_ast::util::classify::expr_is_complete

source ·
pub fn expr_is_complete(e: &Expr) -> bool
Expand description

This classification determines whether various syntactic positions break out of parsing the current expression (true) or continue parsing more of the same expression (false).

For example, it’s relevant in the parsing of match arms:

match ... {
    // Is this calling $e as a function, or is it the start of a new arm
    // with a tuple pattern?
    _ => $e (
            ^                                                          )

    // Is this an Index operation, or new arm with a slice pattern?
    _ => $e [
            ^                                                          ]

    // Is this a binary operator, or leading vert in a new arm? Same for
    // other punctuation which can either be a binary operator in
    // expression or unary operator in pattern, such as `&` and `-`.
    _ => $e |
            ^
}

If $e is something like {} or if … {}, then terminate the current arm and parse a new arm.

If $e is something like path::to or (…), continue parsing the same arm.

Almost the same classification is used as an early bail-out for parsing statements. See expr_requires_semi_to_be_stmt.