Skip to content
Playground(another site)

bynk.parse.match_ends_block

Error A match ends the block it is in, because a block has no expression statements; a second match straight after it cannot follow.

A block has no expression statements, so a match is its final value and nothing can follow it; a second match straight after the first is refused. Bind the first with let _ = match …. If the steps are fallible and each depends on the one before, let … else flattens them without nesting.

Example

fn grade(a: Int, b: Int) -> Int {
match a { … }
match b { … } // ✗ a `match` ends its block
}
fn grade(a: Int, b: Int) -> Int {
let _ = match a { … } // ✓ bound, so the block goes on
match b { … }
}

In the Book

See also

  • The grammar rule it governs: block.
  • Every code in its category, Parser, on the diagnostic index.
  • bynk explain bynk.parse.match_ends_block shows the same from the installed toolchain, without a network.