Sisu
E0145

Loop label on something that is not a loop

Error

Built from the repository at commit a8614dc.

Only loop, while, while let and for take a loop label. A name: before if, match or a block is an error, and so is a loop label named _, whose fix deletes it.

Why

A loop label lets a break or continue name its loop, and an if, a match or a block has no break of its own. To leave a block early, move it into a function and return, or into a loop that ends with break. _ means "no name" in Sisu, and a loop label that no jump can name has no use, so _: is deleted.

Broken

fn main() {
    let ready = true
    check: if ready {
        print("ready")
    }
}

What sisu says

error[E0145]: only a loop can take a loop label
 --> E0145.sisu:3:5
  |
3 |     check: if ready {
  |     ^^^^^^ -- this is not `loop`, `while` or `for`
  |
  = help: write the loop label before a loop, or delete it

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

Fixed

fn main() {
    let ready = true
    if ready {
        print("ready")
    }
}

Related

  • W0008: a loop label that is never used.