Sisu
E0144

break or continue naming no loop label around it

ErrorUnsafe fix

Built from the repository at commit a8614dc.

A name after continue must be the loop label of a loop around it. A name after break in a for, while or while let that names nothing in scope, but is close to the loop label of a loop around it, is reported as that loop label misspelled.

Why

continue takes no value, so a name after it can only be a loop label. After break, a name that is no loop label begins the value, which only a loop takes; in another loop, a name close to a loop label is far more likely a misspelling of it. The help offers the loop label with the similar name. A jump never leaves its function, so only the loops around it in its own function have loop labels it can name.

Broken

fn main() {
    outer: for x in [1, 2] {
        for y in [3, 4] {
            if x + y == 5 {
                continue outr
            }
            print(y)
        }
    }
}

What sisu says

error[E0144]: no loop label `outr` around this `continue`
 --> E0144.sisu:5:26
  |
5 |                 continue outr
  |                          ^^^^
  |
help: a loop label with a similar name exists: `outer`
  |
5 |                 continue outer
  |                             +

sisu: 1 error
sisu: for more on a code, run `sisu explain <code>`: E0144

Fixed

fn main() {
    outer: for x in [1, 2] {
        for y in [3, 4] {
            if x + y == 5 {
                continue outer
            }
            print(y)
        }
    }
}

Related

  • E0141: break with a value in a loop that has none.
  • E0033: an unknown name, whose help also offers the loop labels around it.
  • E0038: break or continue outside a loop.